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