OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 5 #ifndef COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
6 #define COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 6 #define COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 // in C++. | 88 // in C++. |
89 // | 89 // |
90 // TODO(sfiera): finalize interface. | 90 // TODO(sfiera): finalize interface. |
91 class MostVisitedSites : public history::TopSitesObserver, | 91 class MostVisitedSites : public history::TopSitesObserver, |
92 public MostVisitedSitesSupervisor::Observer { | 92 public MostVisitedSitesSupervisor::Observer { |
93 public: | 93 public: |
94 struct Suggestion; | 94 struct Suggestion; |
95 using SuggestionsVector = std::vector<Suggestion>; | 95 using SuggestionsVector = std::vector<Suggestion>; |
96 using PopularSitesVector = std::vector<PopularSites::Site>; | 96 using PopularSitesVector = std::vector<PopularSites::Site>; |
97 | 97 |
98 // The visual type of a most visited tile. | |
99 // | |
100 // These values must stay in sync with the MostVisitedTileType enum | |
101 // in histograms.xml. | |
102 // | |
103 // A Java counterpart will be generated for this enum. | |
104 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp | |
105 enum MostVisitedTileType { | |
106 // The icon or thumbnail hasn't loaded yet. | |
107 NONE, | |
108 // The item displays a site's actual favicon or touch icon. | |
109 ICON_REAL, | |
110 // The item displays a color derived from the site's favicon or touch icon. | |
111 ICON_COLOR, | |
112 // The item displays a default gray box in place of an icon. | |
113 ICON_DEFAULT, | |
114 NUM_TILE_TYPES, | |
115 }; | |
Marc Treib
2016/06/29 08:19:32
Any particular reason for moving this into the hea
dewittj
2016/06/30 17:48:54
A few reasons. This enum is exposed to Java, maki
Marc Treib
2016/07/01 10:01:03
Acknowledged.
| |
116 | |
98 // The source of the Most Visited sites. | 117 // The source of the Most Visited sites. |
99 enum MostVisitedSource { TOP_SITES, SUGGESTIONS_SERVICE, POPULAR, WHITELIST }; | 118 // A Java counterpart will be generated for this enum. |
119 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp | |
120 enum MostVisitedSource { | |
121 // Item comes from the regional top sites list. | |
Marc Treib
2016/06/29 08:19:32
Nope, these are the *personal* top sites.
Bernhard Bauer
2016/06/29 10:17:43
(The regional ones are called "popular sites" 😃)
dewittj
2016/06/30 17:48:54
Done.
| |
122 TOP_SITES, | |
123 // Item comes from the suggestions service. | |
124 SUGGESTIONS_SERVICE, | |
125 // Item is most popular. | |
Marc Treib
2016/06/29 08:19:32
These are the regionally popular ones.
dewittj
2016/06/30 17:48:54
Done.
| |
126 POPULAR, | |
127 // Item on static whitelist | |
Marc Treib
2016/06/29 08:19:32
s/static/supervised user/ ?
(These whitelists exis
dewittj
2016/06/30 17:48:54
Done.
| |
128 WHITELIST | |
129 }; | |
100 | 130 |
101 // The observer to be notified when the list of most visited sites changes. | 131 // The observer to be notified when the list of most visited sites changes. |
102 class Observer { | 132 class Observer { |
103 public: | 133 public: |
104 virtual void OnMostVisitedURLsAvailable( | 134 virtual void OnMostVisitedURLsAvailable( |
105 const SuggestionsVector& suggestions) = 0; | 135 const SuggestionsVector& suggestions) = 0; |
106 virtual void OnPopularURLsAvailable(const PopularSitesVector& sites) = 0; | 136 virtual void OnPopularURLsAvailable(const PopularSitesVector& sites) = 0; |
107 | 137 |
108 protected: | 138 protected: |
109 virtual ~Observer() {} | 139 virtual ~Observer() {} |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 | 172 |
143 ~MostVisitedSites() override; | 173 ~MostVisitedSites() override; |
144 | 174 |
145 // Does not take ownership of |observer|, which must outlive this object and | 175 // Does not take ownership of |observer|, which must outlive this object and |
146 // must not be null. | 176 // must not be null. |
147 void SetMostVisitedURLsObserver(Observer* observer, int num_sites); | 177 void SetMostVisitedURLsObserver(Observer* observer, int num_sites); |
148 | 178 |
149 using ThumbnailCallback = base::Callback< | 179 using ThumbnailCallback = base::Callback< |
150 void(bool /* is_local_thumbnail */, const SkBitmap* /* bitmap */)>; | 180 void(bool /* is_local_thumbnail */, const SkBitmap* /* bitmap */)>; |
151 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); | 181 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); |
152 void RecordTileTypeMetrics(const std::vector<int>& tile_types); | |
153 void RecordOpenedMostVisitedItem(int index, int tile_type); | 182 void RecordOpenedMostVisitedItem(int index, int tile_type); |
154 | 183 |
155 // MostVisitedSitesSupervisor::Observer implementation. | 184 // MostVisitedSitesSupervisor::Observer implementation. |
156 void OnBlockedSitesChanged() override; | 185 void OnBlockedSitesChanged() override; |
157 | 186 |
158 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 187 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
159 | 188 |
160 private: | 189 private: |
161 friend class MostVisitedSitesTest; | 190 friend class MostVisitedSitesTest; |
162 | 191 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 | 291 |
263 // For callbacks may be run after destruction. | 292 // For callbacks may be run after destruction. |
264 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; | 293 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; |
265 | 294 |
266 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); | 295 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); |
267 }; | 296 }; |
268 | 297 |
269 } // namespace ntp_tiles | 298 } // namespace ntp_tiles |
270 | 299 |
271 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ | 300 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ |
OLD | NEW |