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

Side by Side Diff: chrome/browser/android/ntp/most_visited_sites.cc

Issue 1957313003: Remove PopularSites' dependencies on //chrome/.... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 #include "chrome/browser/android/ntp/most_visited_sites.h" 5 #include "chrome/browser/android/ntp/most_visited_sites.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 MostVisitedSites::Suggestion::Suggestion(Suggestion&&) = default; 170 MostVisitedSites::Suggestion::Suggestion(Suggestion&&) = default;
171 MostVisitedSites::Suggestion& 171 MostVisitedSites::Suggestion&
172 MostVisitedSites::Suggestion::operator=(Suggestion&&) = default; 172 MostVisitedSites::Suggestion::operator=(Suggestion&&) = default;
173 173
174 MostVisitedSites::MostVisitedSites( 174 MostVisitedSites::MostVisitedSites(
175 PrefService* prefs, 175 PrefService* prefs,
176 const TemplateURLService* template_url_service, 176 const TemplateURLService* template_url_service,
177 variations::VariationsService* variations_service, 177 variations::VariationsService* variations_service,
178 net::URLRequestContextGetter* download_context, 178 net::URLRequestContextGetter* download_context,
179 const base::FilePath& popular_sites_directory,
179 scoped_refptr<history::TopSites> top_sites, 180 scoped_refptr<history::TopSites> top_sites,
180 SuggestionsService* suggestions, 181 SuggestionsService* suggestions,
181 bool is_child_profile, 182 bool is_child_profile,
182 Profile* profile) 183 Profile* profile)
183 : profile_(profile), prefs_(prefs), 184 : profile_(profile),
185 prefs_(prefs),
184 template_url_service_(template_url_service), 186 template_url_service_(template_url_service),
185 variations_service_(variations_service), 187 variations_service_(variations_service),
186 download_context_(download_context), top_sites_(top_sites), 188 download_context_(download_context),
187 suggestions_service_(suggestions), is_child_profile_(is_child_profile), 189 popular_sites_directory_(popular_sites_directory),
188 observer_(nullptr), num_sites_(0), received_most_visited_sites_(false), 190 top_sites_(top_sites),
189 received_popular_sites_(false), recorded_uma_(false), 191 suggestions_service_(suggestions),
190 scoped_observer_(this), mv_source_(SUGGESTIONS_SERVICE), 192 is_child_profile_(is_child_profile),
193 observer_(nullptr),
194 num_sites_(0),
195 received_most_visited_sites_(false),
196 received_popular_sites_(false),
197 recorded_uma_(false),
198 scoped_observer_(this),
199 mv_source_(SUGGESTIONS_SERVICE),
191 weak_ptr_factory_(this) { 200 weak_ptr_factory_(this) {
192 SupervisedUserService* supervised_user_service = 201 SupervisedUserService* supervised_user_service =
193 SupervisedUserServiceFactory::GetForProfile(profile_); 202 SupervisedUserServiceFactory::GetForProfile(profile_);
194 supervised_user_service->AddObserver(this); 203 supervised_user_service->AddObserver(this);
195 } 204 }
196 205
197 MostVisitedSites::~MostVisitedSites() { 206 MostVisitedSites::~MostVisitedSites() {
198 SupervisedUserService* supervised_user_service = 207 SupervisedUserService* supervised_user_service =
199 SupervisedUserServiceFactory::GetForProfile(profile_); 208 SupervisedUserServiceFactory::GetForProfile(profile_);
200 supervised_user_service->RemoveObserver(this); 209 supervised_user_service->RemoveObserver(this);
201 } 210 }
202 211
203 void MostVisitedSites::SetMostVisitedURLsObserver( 212 void MostVisitedSites::SetMostVisitedURLsObserver(
204 MostVisitedSites::Observer* observer, int num_sites) { 213 MostVisitedSites::Observer* observer, int num_sites) {
205 DCHECK(observer); 214 DCHECK(observer);
206 observer_ = observer; 215 observer_ = observer;
207 num_sites_ = num_sites; 216 num_sites_ = num_sites;
208 217
209 if (ShouldShowPopularSites() && 218 if (ShouldShowPopularSites() &&
210 NeedPopularSites(prefs_, num_sites_)) { 219 NeedPopularSites(prefs_, num_sites_)) {
211 popular_sites_.reset(new PopularSites( 220 popular_sites_.reset(new PopularSites(
212 prefs_, 221 prefs_, template_url_service_, variations_service_, download_context_,
213 template_url_service_, 222 popular_sites_directory_, GetPopularSitesCountry(),
214 variations_service_, 223 GetPopularSitesVersion(), false,
215 download_context_,
216 GetPopularSitesCountry(),
217 GetPopularSitesVersion(),
218 false,
219 base::Bind(&MostVisitedSites::OnPopularSitesAvailable, 224 base::Bind(&MostVisitedSites::OnPopularSitesAvailable,
220 base::Unretained(this)))); 225 base::Unretained(this))));
221 } else { 226 } else {
222 received_popular_sites_ = true; 227 received_popular_sites_ = true;
223 } 228 }
224 229
225 if (top_sites_) { 230 if (top_sites_) {
226 // TopSites updates itself after a delay. To ensure up-to-date results, 231 // TopSites updates itself after a delay. To ensure up-to-date results,
227 // force an update now. 232 // force an update now.
228 top_sites_->SyncWithHistory(); 233 top_sites_->SyncWithHistory();
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 778
774 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} 779 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {}
775 780
776 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 781 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
777 ChangeReason change_reason) { 782 ChangeReason change_reason) {
778 if (mv_source_ == TOP_SITES) { 783 if (mv_source_ == TOP_SITES) {
779 // The displayed suggestions are invalidated. 784 // The displayed suggestions are invalidated.
780 InitiateTopSitesQuery(); 785 InitiateTopSitesQuery();
781 } 786 }
782 } 787 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/most_visited_sites.h ('k') | chrome/browser/android/ntp/most_visited_sites_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698