Replace the deprecated __attribute__((no_address_safety_analysis))
[chromium-blink-merge.git] / chrome / common / instant_types.h
blob8ef078b8eb5e89f74d99e067d7a0f620e0aad220
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 "chrome/common/autocomplete_match_type.h"
14 #include "content/public/common/page_transition_types.h"
15 #include "url/gurl.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 {
24 InstantSuggestion();
25 InstantSuggestion(const string16& in_text,
26 const std::string& in_metadata);
27 ~InstantSuggestion();
29 // Full suggested text.
30 string16 text;
32 // JSON metadata from the server response which produced this suggestion.
33 std::string metadata;
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().
42 string16 provider;
44 // The type of the result.
45 AutocompleteMatchType::Type type;
47 // The description (title), same as AutocompleteMatch::description.
48 string16 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.
62 int 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.
93 struct RGBAColor {
94 RGBAColor();
95 ~RGBAColor();
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.
101 uint8 r;
102 uint8 g;
103 uint8 b;
104 uint8 a;
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|
140 // is valid.
141 ThemeBackgroundImageAlignment image_horizontal_alignment;
143 // The theme background image vertical alignment is only valid if |theme_id|
144 // is valid.
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.
152 uint16 image_height;
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.
159 bool logo_alternate;
162 struct InstantMostVisitedItem {
163 // The URL of the Most Visited item.
164 GURL url;
166 // The title of the Most Visited page. May be empty, in which case the |url|
167 // is used as the title.
168 string16 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_