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

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: Revert to explicit access for HistoryService to fix integration tests. 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);
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.
(...skipping 28 matching lines...) Expand all
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(
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
(...skipping 22 matching lines...) Expand all
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() {
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() {
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);
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);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 case syncer::THEMES: 349 case syncer::THEMES:
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: {
359 // We request history service with explicit access here because this
360 // codepath is executed on backend thread while HistoryServiceFactory
361 // checks preference value in implicit mode and PrefService expectes calls
362 // only from UI thread.
360 history::HistoryService* history = HistoryServiceFactory::GetForProfile( 363 history::HistoryService* history = HistoryServiceFactory::GetForProfile(
361 profile_, ServiceAccessType::EXPLICIT_ACCESS); 364 profile_, ServiceAccessType::EXPLICIT_ACCESS);
362 if (!history) 365 if (!history)
363 return base::WeakPtr<history::TypedUrlSyncableService>(); 366 return base::WeakPtr<history::TypedUrlSyncableService>();
364 return history->GetTypedUrlSyncableService()->AsWeakPtr(); 367 return history->GetTypedUrlSyncableService()->AsWeakPtr();
365 } 368 }
366 #if defined(ENABLE_SPELLCHECK) 369 #if defined(ENABLE_SPELLCHECK)
367 case syncer::DICTIONARY: 370 case syncer::DICTIONARY:
368 return SpellcheckServiceFactory::GetForContext(profile_)-> 371 return SpellcheckServiceFactory::GetForContext(profile_)->
369 GetCustomDictionary()->AsWeakPtr(); 372 GetCustomDictionary()->AsWeakPtr();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 ChromeSyncClient::GetSyncApiComponentFactory() { 471 ChromeSyncClient::GetSyncApiComponentFactory() {
469 return component_factory_.get(); 472 return component_factory_.get();
470 } 473 }
471 474
472 void ChromeSyncClient::ClearBrowsingData(base::Time start, base::Time end) { 475 void ChromeSyncClient::ClearBrowsingData(base::Time start, base::Time end) {
473 BrowsingDataRemover* remover = 476 BrowsingDataRemover* remover =
474 BrowsingDataRemoverFactory::GetForBrowserContext(profile_); 477 BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
475 remover->Remove(BrowsingDataRemover::TimeRange(start, end), 478 remover->Remove(BrowsingDataRemover::TimeRange(start, end),
476 BrowsingDataRemover::REMOVE_ALL, BrowsingDataHelper::ALL); 479 BrowsingDataRemover::REMOVE_ALL, BrowsingDataHelper::ALL);
477 480
478 scoped_refptr<password_manager::PasswordStore> password = 481 password_store_->RemoveLoginsSyncedBetween(start, end);
479 PasswordStoreFactory::GetForProfile(profile_,
480 ServiceAccessType::EXPLICIT_ACCESS);
481 password->RemoveLoginsSyncedBetween(start, end);
482 } 482 }
483 483
484 void ChromeSyncClient::SetBrowsingDataRemoverObserverForTesting( 484 void ChromeSyncClient::SetBrowsingDataRemoverObserverForTesting(
485 BrowsingDataRemover::Observer* observer) { 485 BrowsingDataRemover::Observer* observer) {
486 BrowsingDataRemover* remover = 486 BrowsingDataRemover* remover =
487 BrowsingDataRemoverFactory::GetForBrowserContext(profile_); 487 BrowsingDataRemoverFactory::GetForBrowserContext(profile_);
488 if (browsing_data_remover_observer_) 488 if (browsing_data_remover_observer_)
489 remover->RemoveObserver(browsing_data_remover_observer_); 489 remover->RemoveObserver(browsing_data_remover_observer_);
490 490
491 if (observer) 491 if (observer)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 sync_service->RegisterDataTypeController( 616 sync_service->RegisterDataTypeController(
617 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS, 617 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS,
618 error_callback, this, profile_)); 618 error_callback, this, profile_));
619 sync_service->RegisterDataTypeController( 619 sync_service->RegisterDataTypeController(
620 new SupervisedUserSyncDataTypeController( 620 new SupervisedUserSyncDataTypeController(
621 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); 621 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_));
622 #endif 622 #endif
623 } 623 }
624 624
625 } // namespace browser_sync 625 } // 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