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

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

Issue 1930413002: Pull g_browser_process out of PopularSites. (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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } // namespace 170 } // namespace
171 171
172 MostVisitedSites::Suggestion::Suggestion() : provider_index(-1) {} 172 MostVisitedSites::Suggestion::Suggestion() : provider_index(-1) {}
173 173
174 MostVisitedSites::Suggestion::~Suggestion() {} 174 MostVisitedSites::Suggestion::~Suggestion() {}
175 175
176 MostVisitedSites::Suggestion::Suggestion(Suggestion&&) = default; 176 MostVisitedSites::Suggestion::Suggestion(Suggestion&&) = default;
177 MostVisitedSites::Suggestion& 177 MostVisitedSites::Suggestion&
178 MostVisitedSites::Suggestion::operator=(Suggestion&&) = default; 178 MostVisitedSites::Suggestion::operator=(Suggestion&&) = default;
179 179
180 MostVisitedSites::MostVisitedSites(Profile* profile) 180 MostVisitedSites::MostVisitedSites(Profile* profile,
181 : profile_(profile), top_sites_(TopSitesFactory::GetForProfile(profile)), 181 variations::VariationsService* variations_service)
182 : profile_(profile),
183 variations_service_(variations_service),
184 top_sites_(TopSitesFactory::GetForProfile(profile)),
182 suggestions_service_(SuggestionsServiceFactory::GetForProfile(profile_)), 185 suggestions_service_(SuggestionsServiceFactory::GetForProfile(profile_)),
183 observer_(nullptr), num_sites_(0), 186 observer_(nullptr), num_sites_(0), received_most_visited_sites_(false),
184 received_most_visited_sites_(false), received_popular_sites_(false), 187 received_popular_sites_(false), recorded_uma_(false),
185 recorded_uma_(false), scoped_observer_(this), weak_ptr_factory_(this) { 188 scoped_observer_(this), weak_ptr_factory_(this) {
186 // Register the thumbnails debugging page. 189 // Register the thumbnails debugging page.
187 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); 190 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_));
188 191
189 SupervisedUserService* supervised_user_service = 192 SupervisedUserService* supervised_user_service =
190 SupervisedUserServiceFactory::GetForProfile(profile_); 193 SupervisedUserServiceFactory::GetForProfile(profile_);
191 supervised_user_service->AddObserver(this); 194 supervised_user_service->AddObserver(this);
192 } 195 }
193 196
194 MostVisitedSites::~MostVisitedSites() { 197 MostVisitedSites::~MostVisitedSites() {
195 SupervisedUserService* supervised_user_service = 198 SupervisedUserService* supervised_user_service =
196 SupervisedUserServiceFactory::GetForProfile(profile_); 199 SupervisedUserServiceFactory::GetForProfile(profile_);
197 supervised_user_service->RemoveObserver(this); 200 supervised_user_service->RemoveObserver(this);
198 } 201 }
199 202
200 void MostVisitedSites::SetMostVisitedURLsObserver( 203 void MostVisitedSites::SetMostVisitedURLsObserver(
201 MostVisitedSites::Observer* observer, int num_sites) { 204 MostVisitedSites::Observer* observer, int num_sites) {
202 observer_ = observer; 205 observer_ = observer;
203 num_sites_ = num_sites; 206 num_sites_ = num_sites;
204 207
205 if (ShouldShowPopularSites() && 208 if (ShouldShowPopularSites() &&
206 NeedPopularSites(profile_->GetPrefs(), num_sites_)) { 209 NeedPopularSites(profile_->GetPrefs(), num_sites_)) {
207 popular_sites_.reset(new PopularSites( 210 popular_sites_.reset(new PopularSites(
208 profile_->GetPrefs(), 211 profile_->GetPrefs(),
209 TemplateURLServiceFactory::GetForProfile(profile_), 212 TemplateURLServiceFactory::GetForProfile(profile_),
213 variations_service_,
210 profile_->GetRequestContext(), 214 profile_->GetRequestContext(),
211 GetPopularSitesCountry(), 215 GetPopularSitesCountry(),
212 GetPopularSitesVersion(), 216 GetPopularSitesVersion(),
213 false, 217 false,
214 base::Bind(&MostVisitedSites::OnPopularSitesAvailable, 218 base::Bind(&MostVisitedSites::OnPopularSitesAvailable,
215 base::Unretained(this)))); 219 base::Unretained(this))));
216 } else { 220 } else {
217 received_popular_sites_ = true; 221 received_popular_sites_ = true;
218 } 222 }
219 223
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 780
777 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {} 781 void MostVisitedSites::TopSitesLoaded(TopSites* top_sites) {}
778 782
779 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 783 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
780 ChangeReason change_reason) { 784 ChangeReason change_reason) {
781 if (mv_source_ == TOP_SITES) { 785 if (mv_source_ == TOP_SITES) {
782 // The displayed suggestions are invalidated. 786 // The displayed suggestions are invalidated.
783 InitiateTopSitesQuery(); 787 InitiateTopSitesQuery();
784 } 788 }
785 } 789 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698