1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_INSTANT_TYPES_H_
6 #define CHROME_COMMON_INSTANT_TYPES_H_
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "chrome/common/autocomplete_match_type.h"
14 #include "content/public/common/page_transition_types.h"
17 // ID used by Instant code to refer to objects (e.g. Autocomplete results, Most
18 // Visited items) that the Instant page needs access to.
19 typedef int InstantRestrictedID
;
21 // A wrapper to hold Instant suggested text and its metadata. Used to tell the
22 // server what suggestion to prefetch.
23 struct InstantSuggestion
{
25 InstantSuggestion(const string16
& in_text
,
26 const std::string
& in_metadata
);
29 // Full suggested text.
32 // JSON metadata from the server response which produced this suggestion.
36 // Omnibox dropdown matches provided by the native autocomplete providers.
37 struct InstantAutocompleteResult
{
38 InstantAutocompleteResult();
39 ~InstantAutocompleteResult();
41 // The provider name, as returned by AutocompleteProvider::GetName().
44 // The type of the result.
45 AutocompleteMatchType::Type type
;
47 // The description (title), same as AutocompleteMatch::description.
50 // The URL of the match, same as AutocompleteMatch::destination_url.
51 string16 destination_url
;
53 // The search query for this match. Only set for matches coming from
54 // SearchProvider. Populated using AutocompleteMatch::contents.
55 string16 search_query
;
57 // The transition type to use when the user opens this match. Same as
58 // AutocompleteMatch::transition.
59 content::PageTransition transition
;
61 // The relevance score of this match, same as AutocompleteMatch::relevance.
64 // The index of the match in AutocompleteResult. Used to get the instant
65 // suggestion metadata details. Set to kNoMatchIndex if the
66 // suggestion is displayed on the Instant NTP and set to a positive value if
67 // the suggestion is displayed on the Local NTP.
68 size_t autocomplete_match_index
;
71 // An InstantAutocompleteResult along with its assigned restricted ID.
72 typedef std::pair
<InstantRestrictedID
, InstantAutocompleteResult
>
73 InstantAutocompleteResultIDPair
;
75 // The alignment of the theme background image.
76 enum ThemeBackgroundImageAlignment
{
77 THEME_BKGRND_IMAGE_ALIGN_CENTER
,
78 THEME_BKGRND_IMAGE_ALIGN_LEFT
,
79 THEME_BKGRND_IMAGE_ALIGN_TOP
,
80 THEME_BKGRND_IMAGE_ALIGN_RIGHT
,
81 THEME_BKGRND_IMAGE_ALIGN_BOTTOM
,
84 // The tiling of the theme background image.
85 enum ThemeBackgroundImageTiling
{
86 THEME_BKGRND_IMAGE_NO_REPEAT
,
87 THEME_BKGRND_IMAGE_REPEAT_X
,
88 THEME_BKGRND_IMAGE_REPEAT_Y
,
89 THEME_BKGRND_IMAGE_REPEAT
,
92 // The RGBA color components for the text and links of the theme.
97 bool operator==(const RGBAColor
& rhs
) const;
99 // The color in RGBA format where the R, G, B and A values
100 // are between 0 and 255 inclusive and always valid.
107 // Theme background settings for the NTP.
108 struct ThemeBackgroundInfo
{
109 ThemeBackgroundInfo();
110 ~ThemeBackgroundInfo();
112 bool operator==(const ThemeBackgroundInfo
& rhs
) const;
114 // True if the default theme is selected.
115 bool using_default_theme
;
117 // The theme background color in RGBA format always valid.
118 RGBAColor background_color
;
120 // The theme text color in RGBA format.
121 RGBAColor text_color
;
123 // The theme link color in RGBA format.
124 RGBAColor link_color
;
126 // The theme text color light in RGBA format.
127 RGBAColor text_color_light
;
129 // The theme color for the header in RGBA format.
130 RGBAColor header_color
;
132 // The theme color for the section border in RGBA format.
133 RGBAColor section_border_color
;
135 // The theme id for the theme background image.
136 // Value is only valid if there's a custom theme background image.
137 std::string theme_id
;
139 // The theme background image horizontal alignment is only valid if |theme_id|
141 ThemeBackgroundImageAlignment image_horizontal_alignment
;
143 // The theme background image vertical alignment is only valid if |theme_id|
145 ThemeBackgroundImageAlignment image_vertical_alignment
;
147 // The theme background image tiling is only valid if |theme_id| is valid.
148 ThemeBackgroundImageTiling image_tiling
;
150 // The theme background image height.
151 // Value is only valid if |theme_id| is valid.
154 // True if theme has attribution logo.
155 // Value is only valid if |theme_id| is valid.
156 bool has_attribution
;
158 // True if theme has an alternate logo.
162 struct InstantMostVisitedItem
{
163 // The URL of the Most Visited item.
166 // The title of the Most Visited page. May be empty, in which case the |url|
167 // is used as the title.
171 // An InstantMostVisitedItem along with its assigned restricted ID.
172 typedef std::pair
<InstantRestrictedID
, InstantMostVisitedItem
>
173 InstantMostVisitedItemIDPair
;
175 #endif // CHROME_COMMON_INSTANT_TYPES_H_