Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: components/ntp_tiles/most_visited_sites.h

Issue 2105933002: NTP: Fix metrics recording crash by plumbing the necessary data to Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address treib@ comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/ntp_tiles/BUILD.gn ('k') | components/ntp_tiles/most_visited_sites.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 };
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 personal top sites list.
122 TOP_SITES,
123 // Item comes from the suggestions service.
124 SUGGESTIONS_SERVICE,
125 // Item is regionally popular.
126 POPULAR,
127 // Item is on an custodian-managed whitelist.
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
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); 182 void RecordTileTypeMetrics(const std::vector<int>& tile_types,
183 const std::vector<int>& sources,
184 const std::vector<int>& provider_indices);
153 void RecordOpenedMostVisitedItem(int index, int tile_type); 185 void RecordOpenedMostVisitedItem(int index, int tile_type);
154 186
155 // MostVisitedSitesSupervisor::Observer implementation. 187 // MostVisitedSitesSupervisor::Observer implementation.
156 void OnBlockedSitesChanged() override; 188 void OnBlockedSitesChanged() override;
157 189
158 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 190 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
159 191
160 private: 192 private:
161 friend class MostVisitedSitesTest; 193 friend class MostVisitedSitesTest;
162 194
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 294
263 // For callbacks may be run after destruction. 295 // For callbacks may be run after destruction.
264 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; 296 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_;
265 297
266 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 298 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
267 }; 299 };
268 300
269 } // namespace ntp_tiles 301 } // namespace ntp_tiles
270 302
271 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ 303 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_
OLDNEW
« no previous file with comments | « components/ntp_tiles/BUILD.gn ('k') | components/ntp_tiles/most_visited_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698