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

Side by Side Diff: chrome/browser/sync/chrome_sync_client.cc

Issue 1647833006: [Sync] Request dependency services in sync client with implicit access type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/sync/chrome_sync_client.h" 5 #include "chrome/browser/sync/chrome_sync_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 ~SyncSessionsClientImpl() override {} 133 ~SyncSessionsClientImpl() override {}
134 134
135 // SyncSessionsClient implementation. 135 // SyncSessionsClient implementation.
136 bookmarks::BookmarkModel* GetBookmarkModel() override { 136 bookmarks::BookmarkModel* GetBookmarkModel() override {
137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
138 return BookmarkModelFactory::GetForProfile(profile_); 138 return BookmarkModelFactory::GetForProfile(profile_);
139 } 139 }
140 favicon::FaviconService* GetFaviconService() override { 140 favicon::FaviconService* GetFaviconService() override {
141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
142 return FaviconServiceFactory::GetForProfile( 142 return FaviconServiceFactory::GetForProfile(
143 profile_, ServiceAccessType::EXPLICIT_ACCESS); 143 profile_, ServiceAccessType::IMPLICIT_ACCESS);
144 } 144 }
145 history::HistoryService* GetHistoryService() override { 145 history::HistoryService* GetHistoryService() override {
146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
147 return HistoryServiceFactory::GetForProfile( 147 return HistoryServiceFactory::GetForProfile(
148 profile_, ServiceAccessType::EXPLICIT_ACCESS); 148 profile_, ServiceAccessType::EXPLICIT_ACCESS);
skym 2016/01/28 20:20:55 What about here?
pavely 2016/01/28 22:30:53 Done.
149 } 149 }
150 bool ShouldSyncURL(const GURL& url) const override { 150 bool ShouldSyncURL(const GURL& url) const override {
151 if (url == GURL(chrome::kChromeUIHistoryURL)) { 151 if (url == GURL(chrome::kChromeUIHistoryURL)) {
152 // The history page is treated specially as we want it to trigger syncable 152 // The history page is treated specially as we want it to trigger syncable
153 // events for UI purposes. 153 // events for UI purposes.
154 return true; 154 return true;
155 } 155 }
156 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) && 156 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) &&
157 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile(); 157 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile();
158 } 158 }
(...skipping 22 matching lines...) Expand all
181 sync_sessions_client_(new SyncSessionsClientImpl(profile)), 181 sync_sessions_client_(new SyncSessionsClientImpl(profile)),
182 browsing_data_remover_observer_(NULL), 182 browsing_data_remover_observer_(NULL),
183 weak_ptr_factory_(this) {} 183 weak_ptr_factory_(this) {}
184 184
185 ChromeSyncClient::~ChromeSyncClient() { 185 ChromeSyncClient::~ChromeSyncClient() {
186 } 186 }
187 187
188 void ChromeSyncClient::Initialize() { 188 void ChromeSyncClient::Initialize() {
189 DCHECK_CURRENTLY_ON(BrowserThread::UI); 189 DCHECK_CURRENTLY_ON(BrowserThread::UI);
190 190
191 web_data_service_ = WebDataServiceFactory::GetAutofillWebDataForProfile( 191 web_data_service_ = WebDataServiceFactory::GetAutofillWebDataForProfile(
skym 2016/01/28 20:20:55 Kinda odd we cache some (webdata/password), but fe
pavely 2016/01/28 22:30:53 Don't know why. Maybe factory needs to be called o
192 profile_, ServiceAccessType::EXPLICIT_ACCESS); 192 profile_, ServiceAccessType::IMPLICIT_ACCESS);
193 // TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here?
194 password_store_ = PasswordStoreFactory::GetForProfile( 193 password_store_ = PasswordStoreFactory::GetForProfile(
195 profile_, ServiceAccessType::EXPLICIT_ACCESS); 194 profile_, ServiceAccessType::IMPLICIT_ACCESS);
196 195
197 // Component factory may already be set in tests. 196 // Component factory may already be set in tests.
198 if (!GetSyncApiComponentFactory()) { 197 if (!GetSyncApiComponentFactory()) {
199 const GURL sync_service_url = GetSyncServiceURL( 198 const GURL sync_service_url = GetSyncServiceURL(
200 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel()); 199 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel());
201 ProfileOAuth2TokenService* token_service = 200 ProfileOAuth2TokenService* token_service =
202 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 201 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
203 net::URLRequestContextGetter* url_request_context_getter = 202 net::URLRequestContextGetter* url_request_context_getter =
204 profile_->GetRequestContext(); 203 profile_->GetRequestContext();
205 204
206 component_factory_.reset(new ProfileSyncComponentsFactoryImpl( 205 component_factory_.reset(new ProfileSyncComponentsFactoryImpl(
skym 2016/01/28 20:20:55 Wow this constructor is big.
pavely 2016/01/28 22:30:53 Acknowledged.
207 this, chrome::GetChannel(), chrome::GetVersionString(), 206 this, chrome::GetChannel(), chrome::GetVersionString(),
208 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, 207 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET,
209 *base::CommandLine::ForCurrentProcess(), 208 *base::CommandLine::ForCurrentProcess(),
210 prefs::kSavingBrowserHistoryDisabled, sync_service_url, 209 prefs::kSavingBrowserHistoryDisabled, sync_service_url,
211 content::BrowserThread::GetMessageLoopProxyForThread( 210 content::BrowserThread::GetMessageLoopProxyForThread(
212 content::BrowserThread::UI), 211 content::BrowserThread::UI),
213 content::BrowserThread::GetMessageLoopProxyForThread( 212 content::BrowserThread::GetMessageLoopProxyForThread(
214 content::BrowserThread::DB), 213 content::BrowserThread::DB),
215 token_service, url_request_context_getter, web_data_service_, 214 token_service, url_request_context_getter, web_data_service_,
216 password_store_)); 215 password_store_));
217 } 216 }
218 } 217 }
219 218
220 sync_driver::SyncService* ChromeSyncClient::GetSyncService() { 219 sync_driver::SyncService* ChromeSyncClient::GetSyncService() {
221 DCHECK_CURRENTLY_ON(BrowserThread::UI); 220 DCHECK_CURRENTLY_ON(BrowserThread::UI);
222 return ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); 221 return ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_);
223 } 222 }
224 223
225 PrefService* ChromeSyncClient::GetPrefService() { 224 PrefService* ChromeSyncClient::GetPrefService() {
226 DCHECK_CURRENTLY_ON(BrowserThread::UI); 225 DCHECK_CURRENTLY_ON(BrowserThread::UI);
227 return profile_->GetPrefs(); 226 return profile_->GetPrefs();
228 } 227 }
229 228
230 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() { 229 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() {
231 DCHECK_CURRENTLY_ON(BrowserThread::UI); 230 DCHECK_CURRENTLY_ON(BrowserThread::UI);
232 return BookmarkModelFactory::GetForProfile(profile_); 231 return BookmarkModelFactory::GetForProfile(profile_);
233 } 232 }
234 233
235 favicon::FaviconService* ChromeSyncClient::GetFaviconService() { 234 favicon::FaviconService* ChromeSyncClient::GetFaviconService() {
skym 2016/01/28 20:20:55 Why doesn't this just delegate to the sync_session
pavely 2016/01/28 22:30:53 To be honest don't know.
236 DCHECK_CURRENTLY_ON(BrowserThread::UI); 235 DCHECK_CURRENTLY_ON(BrowserThread::UI);
237 return FaviconServiceFactory::GetForProfile( 236 return FaviconServiceFactory::GetForProfile(
238 profile_, ServiceAccessType::EXPLICIT_ACCESS); 237 profile_, ServiceAccessType::IMPLICIT_ACCESS);
239 } 238 }
240 239
241 history::HistoryService* ChromeSyncClient::GetHistoryService() { 240 history::HistoryService* ChromeSyncClient::GetHistoryService() {
skym 2016/01/28 20:20:55 Same delegate question.
242 DCHECK_CURRENTLY_ON(BrowserThread::UI); 241 DCHECK_CURRENTLY_ON(BrowserThread::UI);
243 return HistoryServiceFactory::GetForProfile( 242 return HistoryServiceFactory::GetForProfile(
244 profile_, ServiceAccessType::EXPLICIT_ACCESS); 243 profile_, ServiceAccessType::EXPLICIT_ACCESS);
skym 2016/01/28 20:20:55 and here
pavely 2016/01/28 22:30:53 Done.
245 } 244 }
246 245
247 autofill::PersonalDataManager* ChromeSyncClient::GetPersonalDataManager() { 246 autofill::PersonalDataManager* ChromeSyncClient::GetPersonalDataManager() {
248 DCHECK_CURRENTLY_ON(BrowserThread::UI); 247 DCHECK_CURRENTLY_ON(BrowserThread::UI);
249 return autofill::PersonalDataManagerFactory::GetForProfile(profile_); 248 return autofill::PersonalDataManagerFactory::GetForProfile(profile_);
250 } 249 }
251 250
252 sync_driver::ClearBrowsingDataCallback 251 sync_driver::ClearBrowsingDataCallback
253 ChromeSyncClient::GetClearBrowsingDataCallback() { 252 ChromeSyncClient::GetClearBrowsingDataCallback() {
254 return base::Bind(&ChromeSyncClient::ClearBrowsingData, 253 return base::Bind(&ChromeSyncClient::ClearBrowsingData,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return ThemeServiceFactory::GetForProfile(profile_)-> 350 return ThemeServiceFactory::GetForProfile(profile_)->
352 GetThemeSyncableService()->AsWeakPtr(); 351 GetThemeSyncableService()->AsWeakPtr();
353 #endif 352 #endif
354 case syncer::HISTORY_DELETE_DIRECTIVES: { 353 case syncer::HISTORY_DELETE_DIRECTIVES: {
355 history::HistoryService* history = GetHistoryService(); 354 history::HistoryService* history = GetHistoryService();
356 return history ? history->AsWeakPtr() 355 return history ? history->AsWeakPtr()
357 : base::WeakPtr<history::HistoryService>(); 356 : base::WeakPtr<history::HistoryService>();
358 } 357 }
359 case syncer::TYPED_URLS: { 358 case syncer::TYPED_URLS: {
360 history::HistoryService* history = HistoryServiceFactory::GetForProfile( 359 history::HistoryService* history = HistoryServiceFactory::GetForProfile(
361 profile_, ServiceAccessType::EXPLICIT_ACCESS); 360 profile_, ServiceAccessType::EXPLICIT_ACCESS);
skym 2016/01/28 20:20:55 and here. Also why is this repeating logic instead
pavely 2016/01/28 22:30:53 HistoryServiceFactory::GetForProfile works slightl
skym 2016/01/28 22:41:13 Makes sense. Were you going to change this to be I
362 if (!history) 361 if (!history)
363 return base::WeakPtr<history::TypedUrlSyncableService>(); 362 return base::WeakPtr<history::TypedUrlSyncableService>();
364 return history->GetTypedUrlSyncableService()->AsWeakPtr(); 363 return history->GetTypedUrlSyncableService()->AsWeakPtr();
365 } 364 }
366 #if defined(ENABLE_SPELLCHECK) 365 #if defined(ENABLE_SPELLCHECK)
367 case syncer::DICTIONARY: 366 case syncer::DICTIONARY:
368 return SpellcheckServiceFactory::GetForContext(profile_)-> 367 return SpellcheckServiceFactory::GetForContext(profile_)->
369 GetCustomDictionary()->AsWeakPtr(); 368 GetCustomDictionary()->AsWeakPtr();
370 #endif 369 #endif
371 case syncer::FAVICON_IMAGES: 370 case syncer::FAVICON_IMAGES:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 469 }
471 470
472 void ChromeSyncClient::ClearBrowsingData(base::Time start, base::Time end) { 471 void ChromeSyncClient::ClearBrowsingData(base::Time start, base::Time end) {
473 BrowsingDataRemover* remover = 472 BrowsingDataRemover* remover =
474 BrowsingDataRemoverFactory::GetForBrowserContext(profile_); 473 BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
475 remover->Remove(BrowsingDataRemover::TimeRange(start, end), 474 remover->Remove(BrowsingDataRemover::TimeRange(start, end),
476 BrowsingDataRemover::REMOVE_ALL, BrowsingDataHelper::ALL); 475 BrowsingDataRemover::REMOVE_ALL, BrowsingDataHelper::ALL);
477 476
478 scoped_refptr<password_manager::PasswordStore> password = 477 scoped_refptr<password_manager::PasswordStore> password =
479 PasswordStoreFactory::GetForProfile(profile_, 478 PasswordStoreFactory::GetForProfile(profile_,
480 ServiceAccessType::EXPLICIT_ACCESS); 479 ServiceAccessType::EXPLICIT_ACCESS);
skym 2016/01/28 20:20:55 and here. Also why isn't this using cached passwor
pavely 2016/01/28 22:30:53 Here I thought that ClearBrowsingData must be call
481 password->RemoveLoginsSyncedBetween(start, end); 480 password->RemoveLoginsSyncedBetween(start, end);
482 } 481 }
483 482
484 void ChromeSyncClient::SetBrowsingDataRemoverObserverForTesting( 483 void ChromeSyncClient::SetBrowsingDataRemoverObserverForTesting(
485 BrowsingDataRemover::Observer* observer) { 484 BrowsingDataRemover::Observer* observer) {
486 BrowsingDataRemover* remover = 485 BrowsingDataRemover* remover =
487 BrowsingDataRemoverFactory::GetForBrowserContext(profile_); 486 BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
488 if (browsing_data_remover_observer_) 487 if (browsing_data_remover_observer_)
489 remover->RemoveObserver(browsing_data_remover_observer_); 488 remover->RemoveObserver(browsing_data_remover_observer_);
490 489
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 sync_service->RegisterDataTypeController( 615 sync_service->RegisterDataTypeController(
617 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS, 616 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS,
618 error_callback, this, profile_)); 617 error_callback, this, profile_));
619 sync_service->RegisterDataTypeController( 618 sync_service->RegisterDataTypeController(
620 new SupervisedUserSyncDataTypeController( 619 new SupervisedUserSyncDataTypeController(
621 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); 620 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_));
622 #endif 621 #endif
623 } 622 }
624 623
625 } // namespace browser_sync 624 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698