Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / common / instant_types.h
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.
4
5 #ifndef CHROME_COMMON_INSTANT_TYPES_H_
6 #define CHROME_COMMON_INSTANT_TYPES_H_
7
8 #include <string>
9 #include <utility>
10
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "content/public/common/page_transition_types.h"
14 #include "url/gurl.h"
15
16 // ID used by Instant code to refer to objects (e.g. Autocomplete results, Most
17 // Visited items) that the Instant page needs access to.
18 typedef int InstantRestrictedID;
19
20 // A wrapper to hold Instant suggested text and its metadata. Used to tell the
21 // server what suggestion to prefetch.
22 struct InstantSuggestion {
23   InstantSuggestion();
24   InstantSuggestion(const base::string16& in_text,
25                     const std::string& in_metadata);
26   ~InstantSuggestion();
27
28   // Full suggested text.
29   base::string16 text;
30
31   // JSON metadata from the server response which produced this suggestion.
32   std::string metadata;
33 };
34
35 // The alignment of the theme background image.
36 enum ThemeBackgroundImageAlignment {
37   THEME_BKGRND_IMAGE_ALIGN_CENTER,
38   THEME_BKGRND_IMAGE_ALIGN_LEFT,
39   THEME_BKGRND_IMAGE_ALIGN_TOP,
40   THEME_BKGRND_IMAGE_ALIGN_RIGHT,
41   THEME_BKGRND_IMAGE_ALIGN_BOTTOM,
42 };
43
44 // The tiling of the theme background image.
45 enum ThemeBackgroundImageTiling {
46   THEME_BKGRND_IMAGE_NO_REPEAT,
47   THEME_BKGRND_IMAGE_REPEAT_X,
48   THEME_BKGRND_IMAGE_REPEAT_Y,
49   THEME_BKGRND_IMAGE_REPEAT,
50 };
51
52 // The RGBA color components for the text and links of the theme.
53 struct RGBAColor {
54   RGBAColor();
55   ~RGBAColor();
56
57   bool operator==(const RGBAColor& rhs) const;
58
59   // The color in RGBA format where the R, G, B and A values
60   // are between 0 and 255 inclusive and always valid.
61   uint8 r;
62   uint8 g;
63   uint8 b;
64   uint8 a;
65 };
66
67 // Theme background settings for the NTP.
68 struct ThemeBackgroundInfo {
69   ThemeBackgroundInfo();
70   ~ThemeBackgroundInfo();
71
72   bool operator==(const ThemeBackgroundInfo& rhs) const;
73
74   // True if the default theme is selected.
75   bool using_default_theme;
76
77   // The theme background color in RGBA format always valid.
78   RGBAColor background_color;
79
80   // The theme text color in RGBA format.
81   RGBAColor text_color;
82
83   // The theme link color in RGBA format.
84   RGBAColor link_color;
85
86   // The theme text color light in RGBA format.
87   RGBAColor text_color_light;
88
89   // The theme color for the header in RGBA format.
90   RGBAColor header_color;
91
92   // The theme color for the section border in RGBA format.
93   RGBAColor section_border_color;
94
95   // The theme id for the theme background image.
96   // Value is only valid if there's a custom theme background image.
97   std::string theme_id;
98
99   // The theme background image horizontal alignment is only valid if |theme_id|
100   // is valid.
101   ThemeBackgroundImageAlignment image_horizontal_alignment;
102
103   // The theme background image vertical alignment is only valid if |theme_id|
104   // is valid.
105   ThemeBackgroundImageAlignment image_vertical_alignment;
106
107   // The theme background image tiling is only valid if |theme_id| is valid.
108   ThemeBackgroundImageTiling image_tiling;
109
110   // The theme background image height.
111   // Value is only valid if |theme_id| is valid.
112   uint16 image_height;
113
114   // True if theme has attribution logo.
115   // Value is only valid if |theme_id| is valid.
116   bool has_attribution;
117
118   // True if theme has an alternate logo.
119   bool logo_alternate;
120 };
121
122 struct InstantMostVisitedItem {
123   // The URL of the Most Visited item.
124   GURL url;
125
126   // The title of the Most Visited page.  May be empty, in which case the |url|
127   // is used as the title.
128   base::string16 title;
129 };
130
131 // An InstantMostVisitedItem along with its assigned restricted ID.
132 typedef std::pair<InstantRestrictedID, InstantMostVisitedItem>
133     InstantMostVisitedItemIDPair;
134
135 #endif  // CHROME_COMMON_INSTANT_TYPES_H_