summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/search/instant_types.h
blob: 99916b21c4df9d4705551f546c1f710b34df29bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_COMMON_SEARCH_INSTANT_TYPES_H_
#define CHROME_COMMON_SEARCH_INSTANT_TYPES_H_

#include <stdint.h>

#include <string>
#include <utility>
#include <vector>

#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/ntp_tiles/tile_source.h"
#include "components/ntp_tiles/tile_title_source.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_palette.h"
#include "url/gurl.h"

// ID used by Instant code to refer to objects (e.g. Autocomplete results, Most
// Visited items) that the Instant page needs access to.
typedef int InstantRestrictedID;

// The alignment of the theme background image.
enum ThemeBackgroundImageAlignment {
  THEME_BKGRND_IMAGE_ALIGN_CENTER,
  THEME_BKGRND_IMAGE_ALIGN_LEFT,
  THEME_BKGRND_IMAGE_ALIGN_TOP,
  THEME_BKGRND_IMAGE_ALIGN_RIGHT,
  THEME_BKGRND_IMAGE_ALIGN_BOTTOM,

  THEME_BKGRND_IMAGE_ALIGN_LAST = THEME_BKGRND_IMAGE_ALIGN_BOTTOM,
};

// The tiling of the theme background image.
enum ThemeBackgroundImageTiling {
  THEME_BKGRND_IMAGE_NO_REPEAT,
  THEME_BKGRND_IMAGE_REPEAT_X,
  THEME_BKGRND_IMAGE_REPEAT_Y,
  THEME_BKGRND_IMAGE_REPEAT,

  THEME_BKGRND_IMAGE_LAST = THEME_BKGRND_IMAGE_REPEAT,
};

// Theme background settings for the NTP.
struct ThemeBackgroundInfo {
  ThemeBackgroundInfo();
  ThemeBackgroundInfo(const ThemeBackgroundInfo& other);
  ~ThemeBackgroundInfo();

  bool operator==(const ThemeBackgroundInfo& rhs) const;

  // True if the default theme is selected.
  bool using_default_theme = true;

  // True if the system theme uses a light-on-dark color scheme instead of
  // dark-on-light.
  bool using_dark_colors = false;

  // Url of the custom background selected by the user.
  GURL custom_background_url;

  // First attribution string for custom background.
  std::string custom_background_attribution_line_1;

  // Second attribution string for custom background.
  std::string custom_background_attribution_line_2;

  // Url to learn more info about the custom background.
  GURL custom_background_attribution_action_url;

  // Id of the collection being used for "daily refresh".
  std::string collection_id;

  // The theme background color. Always valid.
  SkColor background_color = gfx::kPlaceholderColor;

  // The theme text color.
  SkColor text_color = gfx::kPlaceholderColor;

  // The theme text color light.
  SkColor text_color_light = gfx::kPlaceholderColor;

  // The theme id for the theme background image.
  // Value is only valid if there's a custom theme background image.
  std::string theme_id;

  // The theme background image horizontal alignment is only valid if |theme_id|
  // is valid.
  ThemeBackgroundImageAlignment image_horizontal_alignment =
      THEME_BKGRND_IMAGE_ALIGN_CENTER;

  // The theme background image vertical alignment is only valid if |theme_id|
  // is valid.
  ThemeBackgroundImageAlignment image_vertical_alignment =
      THEME_BKGRND_IMAGE_ALIGN_CENTER;

  // The theme background image tiling is only valid if |theme_id| is valid.
  ThemeBackgroundImageTiling image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT;

  // True if theme has attribution logo.
  // Value is only valid if |theme_id| is valid.
  bool has_attribution = false;

  // True if theme has an alternate logo.
  bool logo_alternate = false;

  // True if theme has NTP image.
  bool has_theme_image = false;

  // The theme name.
  std::string theme_name;

  // The color id for Chrome Colors. It is -1 if Chrome Colors is not set, 0
  // when Chrome Colors is set but not from predefined color list, and > 0 if
  // Chrome Colors is set from predefined color list.
  int color_id = -1;

  // The dark color for Chrome Colors. Valid only if Chrome Colors is set.
  SkColor color_dark = gfx::kPlaceholderColor;

  // The light color for Chrome Colors. Valid only if Chrome Colors is set.
  SkColor color_light = gfx::kPlaceholderColor;

  // The picked custom color for Chrome Colors. Valid only if Chrome Colors is
  // set.
  SkColor color_picked = gfx::kPlaceholderColor;

  // Color used for alternative Google logo on NTP.
  SkColor logo_color = gfx::kPlaceholderColor;

  // Color for NTP shortcut backgrounds.
  SkColor shortcut_color = gfx::kPlaceholderColor;
};

struct InstantMostVisitedItem {
  InstantMostVisitedItem();
  InstantMostVisitedItem(const InstantMostVisitedItem& other);
  ~InstantMostVisitedItem();

  // The URL of the Most Visited item.
  GURL url;

  // The title of the Most Visited page.  May be empty, in which case the |url|
  // is used as the title.
  base::string16 title;

  // The external URL of the favicon associated with this page.
  GURL favicon;

  // The source of the item's |title|.
  ntp_tiles::TileTitleSource title_source;

  // The source of the item, e.g. server-side or client-side.
  ntp_tiles::TileSource source;

  // The timestamp representing when the tile data (e.g. URL) was generated
  // originally, regardless of the impression timestamp.
  base::Time data_generation_time;
};

struct InstantMostVisitedInfo {
  InstantMostVisitedInfo();
  InstantMostVisitedInfo(const InstantMostVisitedInfo& other);
  ~InstantMostVisitedInfo();

  std::vector<InstantMostVisitedItem> items;

  // True if the source of the |items| is custom links (i.e.
  // ntp_tiles::TileSource::CUSTOM_LINKS). Required since the source cannot be
  // checked if |items| is empty.
  bool items_are_custom_links = false;

  // True if Most Visited functionality is enabled instead of customizable
  // shortcuts.
  bool use_most_visited = false;

  // True if the items are visible and not hidden by the user.
  bool is_visible = true;
};

// An InstantMostVisitedItem along with its assigned restricted ID.
typedef std::pair<InstantRestrictedID, InstantMostVisitedItem>
    InstantMostVisitedItemIDPair;

#endif  // CHROME_COMMON_SEARCH_INSTANT_TYPES_H_