Fix some interleaving issues in EmbeddedWorkerInstance.
[chromium-blink-merge.git] / chrome / common / instant_types.h
blobd8672b137c7f1d2aa1011c0aee4064db7661c73f
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_
8 #include <string>
9 #include <utility>
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "url/gurl.h"
15 // ID used by Instant code to refer to objects (e.g. Autocomplete results, Most
16 // Visited items) that the Instant page needs access to.
17 typedef int InstantRestrictedID;
19 // A wrapper to hold Instant suggested text and its metadata. Used to tell the
20 // server what suggestion to prefetch.
21 struct InstantSuggestion {
22 InstantSuggestion();
23 InstantSuggestion(const base::string16& in_text,
24 const std::string& in_metadata);
25 ~InstantSuggestion();
27 // Full suggested text.
28 base::string16 text;
30 // JSON metadata from the server response which produced this suggestion.
31 std::string metadata;
34 // The alignment of the theme background image.
35 enum ThemeBackgroundImageAlignment {
36 THEME_BKGRND_IMAGE_ALIGN_CENTER,
37 THEME_BKGRND_IMAGE_ALIGN_LEFT,
38 THEME_BKGRND_IMAGE_ALIGN_TOP,
39 THEME_BKGRND_IMAGE_ALIGN_RIGHT,
40 THEME_BKGRND_IMAGE_ALIGN_BOTTOM,
42 THEME_BKGRND_IMAGE_ALIGN_LAST = THEME_BKGRND_IMAGE_ALIGN_BOTTOM,
45 // The tiling of the theme background image.
46 enum ThemeBackgroundImageTiling {
47 THEME_BKGRND_IMAGE_NO_REPEAT,
48 THEME_BKGRND_IMAGE_REPEAT_X,
49 THEME_BKGRND_IMAGE_REPEAT_Y,
50 THEME_BKGRND_IMAGE_REPEAT,
52 THEME_BKGRND_IMAGE_LAST = THEME_BKGRND_IMAGE_REPEAT,
55 // The RGBA color components for the text and links of the theme.
56 struct RGBAColor {
57 RGBAColor();
58 ~RGBAColor();
60 bool operator==(const RGBAColor& rhs) const;
62 // The color in RGBA format where the R, G, B and A values
63 // are between 0 and 255 inclusive and always valid.
64 uint8 r;
65 uint8 g;
66 uint8 b;
67 uint8 a;
70 // Theme background settings for the NTP.
71 struct ThemeBackgroundInfo {
72 ThemeBackgroundInfo();
73 ~ThemeBackgroundInfo();
75 bool operator==(const ThemeBackgroundInfo& rhs) const;
77 // True if the default theme is selected.
78 bool using_default_theme;
80 // The theme background color in RGBA format always valid.
81 RGBAColor background_color;
83 // The theme text color in RGBA format.
84 RGBAColor text_color;
86 // The theme link color in RGBA format.
87 RGBAColor link_color;
89 // The theme text color light in RGBA format.
90 RGBAColor text_color_light;
92 // The theme color for the header in RGBA format.
93 RGBAColor header_color;
95 // The theme color for the section border in RGBA format.
96 RGBAColor section_border_color;
98 // The theme id for the theme background image.
99 // Value is only valid if there's a custom theme background image.
100 std::string theme_id;
102 // The theme background image horizontal alignment is only valid if |theme_id|
103 // is valid.
104 ThemeBackgroundImageAlignment image_horizontal_alignment;
106 // The theme background image vertical alignment is only valid if |theme_id|
107 // is valid.
108 ThemeBackgroundImageAlignment image_vertical_alignment;
110 // The theme background image tiling is only valid if |theme_id| is valid.
111 ThemeBackgroundImageTiling image_tiling;
113 // The theme background image height.
114 // Value is only valid if |theme_id| is valid.
115 uint16 image_height;
117 // True if theme has attribution logo.
118 // Value is only valid if |theme_id| is valid.
119 bool has_attribution;
121 // True if theme has an alternate logo.
122 bool logo_alternate;
125 struct InstantMostVisitedItem {
126 InstantMostVisitedItem();
127 ~InstantMostVisitedItem();
129 // The URL of the Most Visited item.
130 GURL url;
132 // The title of the Most Visited page. May be empty, in which case the |url|
133 // is used as the title.
134 base::string16 title;
136 // The external URL of the thumbnail associated with this page.
137 GURL thumbnail;
139 // The external URL of the favicon associated with this page.
140 GURL favicon;
143 // An InstantMostVisitedItem along with its assigned restricted ID.
144 typedef std::pair<InstantRestrictedID, InstantMostVisitedItem>
145 InstantMostVisitedItemIDPair;
147 // Embedded search request logging stats params.
148 extern const char kSearchQueryKey[];
149 extern const char kOriginalQueryKey[];
150 extern const char kRLZParameterKey[];
151 extern const char kInputEncodingKey[];
152 extern const char kAssistedQueryStatsKey[];
154 // A wrapper to hold embedded search request params. Used to tell the server
155 // about the search query logging stats at the query submission time.
156 struct EmbeddedSearchRequestParams {
157 EmbeddedSearchRequestParams();
158 // Extracts the request params from the |url| and initializes the member
159 // variables.
160 explicit EmbeddedSearchRequestParams(const GURL& url);
161 ~EmbeddedSearchRequestParams();
163 // Submitted search query.
164 base::string16 search_query;
166 // User typed query.
167 base::string16 original_query;
169 // RLZ parameter.
170 base::string16 rlz_parameter_value;
172 // Character input encoding type.
173 base::string16 input_encoding;
175 // The optional assisted query stats, aka AQS, used for logging purposes.
176 // This string contains impressions of all autocomplete matches shown
177 // at the query submission time. For privacy reasons, we require the
178 // search provider to support HTTPS protocol in order to receive the AQS
179 // param.
180 // For more details, see http://goto.google.com/binary-clients-logging.
181 base::string16 assisted_query_stats;
183 #endif // CHROME_COMMON_INSTANT_TYPES_H_