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

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

Issue 2897293002: Adding CrHome-specific implementation for home page tile. (Closed)
Patch Set: Refactor tests and initialization Created 3 years, 6 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
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Construct a MostVisitedSites instance. 104 // Construct a MostVisitedSites instance.
105 // 105 //
106 // |prefs| and |suggestions| are required and may not be null. |top_sites|, 106 // |prefs| and |suggestions| are required and may not be null. |top_sites|,
107 // |popular_sites|, |supervisor| and |home_page_client| are optional and if 107 // |popular_sites|, |supervisor| and |home_page_client| are optional and if
108 // null, the associated features will be disabled. 108 // null, the associated features will be disabled.
109 MostVisitedSites(PrefService* prefs, 109 MostVisitedSites(PrefService* prefs,
110 scoped_refptr<history::TopSites> top_sites, 110 scoped_refptr<history::TopSites> top_sites,
111 suggestions::SuggestionsService* suggestions, 111 suggestions::SuggestionsService* suggestions,
112 std::unique_ptr<PopularSites> popular_sites, 112 std::unique_ptr<PopularSites> popular_sites,
113 std::unique_ptr<IconCacher> icon_cacher, 113 std::unique_ptr<IconCacher> icon_cacher,
114 std::unique_ptr<MostVisitedSitesSupervisor> supervisor,
115 std::unique_ptr<HomePageClient> home_page_client);
116
117 // TODO(fhorschig): Adjust all factories and delete this.
118 // Constructs a MostVisitedSites instance without HomePageClient.
119 MostVisitedSites(PrefService* prefs,
120 scoped_refptr<history::TopSites> top_sites,
121 suggestions::SuggestionsService* suggestions,
122 std::unique_ptr<PopularSites> popular_sites,
123 std::unique_ptr<IconCacher> icon_cacher,
124 std::unique_ptr<MostVisitedSitesSupervisor> supervisor); 114 std::unique_ptr<MostVisitedSitesSupervisor> supervisor);
125 115
126 ~MostVisitedSites() override; 116 ~MostVisitedSites() override;
127 117
128 // Returns true if this object was created with a non-null provider for the 118 // Returns true if this object was created with a non-null provider for the
129 // given NTP tile source. That source may or may not actually provide tiles, 119 // given NTP tile source. That source may or may not actually provide tiles,
130 // depending on its configuration and the priority of different sources. 120 // depending on its configuration and the priority of different sources.
131 bool DoesSourceExist(TileSource source) const; 121 bool DoesSourceExist(TileSource source) const;
132 122
133 // Returns the corresponding object passed at construction. 123 // Returns the corresponding object passed at construction.
134 history::TopSites* top_sites() { return top_sites_.get(); } 124 history::TopSites* top_sites() { return top_sites_.get(); }
135 suggestions::SuggestionsService* suggestions() { 125 suggestions::SuggestionsService* suggestions() {
136 return suggestions_service_; 126 return suggestions_service_;
137 } 127 }
138 PopularSites* popular_sites() { return popular_sites_.get(); } 128 PopularSites* popular_sites() { return popular_sites_.get(); }
139 MostVisitedSitesSupervisor* supervisor() { return supervisor_.get(); } 129 MostVisitedSitesSupervisor* supervisor() { return supervisor_.get(); }
140 130
141 // Sets the observer, and immediately fetches the current suggestions. 131 // Sets the observer, and immediately fetches the current suggestions.
142 // Does not take ownership of |observer|, which must outlive this object and 132 // Does not take ownership of |observer|, which must outlive this object and
143 // must not be null. 133 // must not be null.
144 void SetMostVisitedURLsObserver(Observer* observer, size_t num_sites); 134 void SetMostVisitedURLsObserver(Observer* observer, size_t num_sites);
145 135
136 // Sets the client that provides platform-specific home page preferences.
137 // When used to replace an existing client, the new client will first be used
138 // during the construction of a new tile set.
139 void SetHomePageClient(std::unique_ptr<HomePageClient> client);
140
146 // Requests an asynchronous refresh of the suggestions. Notifies the observer 141 // Requests an asynchronous refresh of the suggestions. Notifies the observer
147 // if the request resulted in the set of tiles changing. 142 // if the request resulted in the set of tiles changing.
148 void Refresh(); 143 void Refresh();
149 144
150 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url); 145 void AddOrRemoveBlacklistedUrl(const GURL& url, bool add_url);
151 void ClearBlacklistedUrls(); 146 void ClearBlacklistedUrls();
152 147
153 // MostVisitedSitesSupervisor::Observer implementation. 148 // MostVisitedSitesSupervisor::Observer implementation.
154 void OnBlockedSitesChanged() override; 149 void OnBlockedSitesChanged() override;
155 150
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void TopSitesLoaded(history::TopSites* top_sites) override; 217 void TopSitesLoaded(history::TopSites* top_sites) override;
223 void TopSitesChanged(history::TopSites* top_sites, 218 void TopSitesChanged(history::TopSites* top_sites,
224 ChangeReason change_reason) override; 219 ChangeReason change_reason) override;
225 220
226 PrefService* prefs_; 221 PrefService* prefs_;
227 scoped_refptr<history::TopSites> top_sites_; 222 scoped_refptr<history::TopSites> top_sites_;
228 suggestions::SuggestionsService* suggestions_service_; 223 suggestions::SuggestionsService* suggestions_service_;
229 std::unique_ptr<PopularSites> const popular_sites_; 224 std::unique_ptr<PopularSites> const popular_sites_;
230 std::unique_ptr<IconCacher> const icon_cacher_; 225 std::unique_ptr<IconCacher> const icon_cacher_;
231 std::unique_ptr<MostVisitedSitesSupervisor> supervisor_; 226 std::unique_ptr<MostVisitedSitesSupervisor> supervisor_;
232 std::unique_ptr<HomePageClient> const home_page_client_; 227 std::unique_ptr<HomePageClient> home_page_client_;
233 228
234 Observer* observer_; 229 Observer* observer_;
235 230
236 // The maximum number of most visited sites to return. 231 // The maximum number of most visited sites to return.
237 size_t num_sites_; 232 size_t num_sites_;
238 233
239 std::unique_ptr< 234 std::unique_ptr<
240 suggestions::SuggestionsService::ResponseCallbackList::Subscription> 235 suggestions::SuggestionsService::ResponseCallbackList::Subscription>
241 suggestions_subscription_; 236 suggestions_subscription_;
242 237
(...skipping 11 matching lines...) Expand all
254 // For callbacks may be run after destruction, used exclusively for TopSites 249 // For callbacks may be run after destruction, used exclusively for TopSites
255 // (since it's used to detect whether there's a query in flight). 250 // (since it's used to detect whether there's a query in flight).
256 base::WeakPtrFactory<MostVisitedSites> top_sites_weak_ptr_factory_; 251 base::WeakPtrFactory<MostVisitedSites> top_sites_weak_ptr_factory_;
257 252
258 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 253 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
259 }; 254 };
260 255
261 } // namespace ntp_tiles 256 } // namespace ntp_tiles
262 257
263 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_ 258 #endif // COMPONENTS_NTP_TILES_MOST_VISITED_SITES_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/most_visited_sites_bridge.cc ('k') | components/ntp_tiles/most_visited_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698