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

Side by Side Diff: ios/chrome/browser/sync/ios_chrome_sync_client.mm

Issue 2723953002: [sync] skeleton implementation of TypedURLSyncBridge (Closed)
Patch Set: rebase and address missing parts for bug 558320 Created 3 years, 9 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 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 "ios/chrome/browser/sync/ios_chrome_sync_client.h" 5 #include "ios/chrome/browser/sync/ios_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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" 14 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h"
15 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h" 15 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h"
16 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" 16 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h"
17 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync able_service.h" 17 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync able_service.h"
18 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv ice.h" 18 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv ice.h"
19 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 19 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
20 #include "components/browser_sync/browser_sync_switches.h" 20 #include "components/browser_sync/browser_sync_switches.h"
21 #include "components/browser_sync/profile_sync_components_factory_impl.h" 21 #include "components/browser_sync/profile_sync_components_factory_impl.h"
22 #include "components/browser_sync/profile_sync_service.h" 22 #include "components/browser_sync/profile_sync_service.h"
23 #include "components/dom_distiller/core/dom_distiller_service.h" 23 #include "components/dom_distiller/core/dom_distiller_service.h"
24 #include "components/history/core/browser/history_model_worker.h" 24 #include "components/history/core/browser/history_model_worker.h"
25 #include "components/history/core/browser/history_service.h" 25 #include "components/history/core/browser/history_service.h"
26 #include "components/history/core/browser/typed_url_sync_bridge.h"
27 #include "components/history/core/browser/typed_url_syncable_service.h"
26 #include "components/invalidation/impl/profile_invalidation_provider.h" 28 #include "components/invalidation/impl/profile_invalidation_provider.h"
27 #include "components/keyed_service/core/service_access_type.h" 29 #include "components/keyed_service/core/service_access_type.h"
28 #include "components/password_manager/core/browser/password_store.h" 30 #include "components/password_manager/core/browser/password_store.h"
29 #include "components/password_manager/sync/browser/password_model_worker.h" 31 #include "components/password_manager/sync/browser/password_model_worker.h"
30 #include "components/reading_list/core/reading_list_switches.h" 32 #include "components/reading_list/core/reading_list_switches.h"
31 #include "components/reading_list/ios/reading_list_model.h" 33 #include "components/reading_list/ios/reading_list_model.h"
32 #include "components/search_engines/search_engine_data_type_controller.h" 34 #include "components/search_engines/search_engine_data_type_controller.h"
33 #include "components/signin/core/browser/profile_oauth2_token_service.h" 35 #include "components/signin/core/browser/profile_oauth2_token_service.h"
34 #include "components/sync/base/report_unrecoverable_error.h" 36 #include "components/sync/base/report_unrecoverable_error.h"
35 #include "components/sync/driver/sync_api_component_factory.h" 37 #include "components/sync/driver/sync_api_component_factory.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 // SyncSessionsClient implementation. 89 // SyncSessionsClient implementation.
88 bookmarks::BookmarkModel* GetBookmarkModel() override { 90 bookmarks::BookmarkModel* GetBookmarkModel() override {
89 DCHECK_CURRENTLY_ON(web::WebThread::UI); 91 DCHECK_CURRENTLY_ON(web::WebThread::UI);
90 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); 92 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_);
91 } 93 }
92 94
93 favicon::FaviconService* GetFaviconService() override { 95 favicon::FaviconService* GetFaviconService() override {
94 DCHECK_CURRENTLY_ON(web::WebThread::UI); 96 DCHECK_CURRENTLY_ON(web::WebThread::UI);
95 return ios::FaviconServiceFactory::GetForBrowserState( 97 return ios::FaviconServiceFactory::GetForBrowserState(
96 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); 98 browser_state_, ServiceAccessType::IMPLICIT_ACCESS);
97 } 99 }
98 100
99 history::HistoryService* GetHistoryService() override { 101 history::HistoryService* GetHistoryService() override {
100 DCHECK_CURRENTLY_ON(web::WebThread::UI); 102 DCHECK_CURRENTLY_ON(web::WebThread::UI);
101 return ios::HistoryServiceFactory::GetForBrowserState( 103 return ios::HistoryServiceFactory::GetForBrowserState(
102 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); 104 browser_state_, ServiceAccessType::EXPLICIT_ACCESS);
103 } 105 }
104 106
105 bool ShouldSyncURL(const GURL& url) const override { 107 bool ShouldSyncURL(const GURL& url) const override {
106 if (url == GURL(kChromeUIHistoryURL)) { 108 if (url == GURL(kChromeUIHistoryURL)) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::MakeUnique<SyncSessionsClientImpl>(browser_state)), 144 base::MakeUnique<SyncSessionsClientImpl>(browser_state)),
143 weak_ptr_factory_(this) {} 145 weak_ptr_factory_(this) {}
144 146
145 IOSChromeSyncClient::~IOSChromeSyncClient() {} 147 IOSChromeSyncClient::~IOSChromeSyncClient() {}
146 148
147 void IOSChromeSyncClient::Initialize() { 149 void IOSChromeSyncClient::Initialize() {
148 DCHECK_CURRENTLY_ON(web::WebThread::UI); 150 DCHECK_CURRENTLY_ON(web::WebThread::UI);
149 151
150 web_data_service_ = 152 web_data_service_ =
151 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( 153 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState(
152 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); 154 browser_state_, ServiceAccessType::IMPLICIT_ACCESS);
153 // TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here?
154 password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState( 155 password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState(
155 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); 156 browser_state_, ServiceAccessType::IMPLICIT_ACCESS);
156 157
157 // Component factory may already be set in tests. 158 // Component factory may already be set in tests.
158 if (!GetSyncApiComponentFactory()) { 159 if (!GetSyncApiComponentFactory()) {
159 const GURL sync_service_url = syncer::GetSyncServiceURL( 160 const GURL sync_service_url = syncer::GetSyncServiceURL(
160 *base::CommandLine::ForCurrentProcess(), ::GetChannel()); 161 *base::CommandLine::ForCurrentProcess(), ::GetChannel());
161 ProfileOAuth2TokenService* token_service = 162 ProfileOAuth2TokenService* token_service =
162 OAuth2TokenServiceFactory::GetForBrowserState(browser_state_); 163 OAuth2TokenServiceFactory::GetForBrowserState(browser_state_);
163 164
164 net::URLRequestContextGetter* url_request_context_getter = 165 net::URLRequestContextGetter* url_request_context_getter =
165 browser_state_->GetRequestContext(); 166 browser_state_->GetRequestContext();
(...skipping 25 matching lines...) Expand all
191 } 192 }
192 193
193 bookmarks::BookmarkModel* IOSChromeSyncClient::GetBookmarkModel() { 194 bookmarks::BookmarkModel* IOSChromeSyncClient::GetBookmarkModel() {
194 DCHECK_CURRENTLY_ON(web::WebThread::UI); 195 DCHECK_CURRENTLY_ON(web::WebThread::UI);
195 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); 196 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_);
196 } 197 }
197 198
198 favicon::FaviconService* IOSChromeSyncClient::GetFaviconService() { 199 favicon::FaviconService* IOSChromeSyncClient::GetFaviconService() {
199 DCHECK_CURRENTLY_ON(web::WebThread::UI); 200 DCHECK_CURRENTLY_ON(web::WebThread::UI);
200 return ios::FaviconServiceFactory::GetForBrowserState( 201 return ios::FaviconServiceFactory::GetForBrowserState(
201 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); 202 browser_state_, ServiceAccessType::IMPLICIT_ACCESS);
202 } 203 }
203 204
204 history::HistoryService* IOSChromeSyncClient::GetHistoryService() { 205 history::HistoryService* IOSChromeSyncClient::GetHistoryService() {
205 DCHECK_CURRENTLY_ON(web::WebThread::UI); 206 DCHECK_CURRENTLY_ON(web::WebThread::UI);
206 return ios::HistoryServiceFactory::GetForBrowserState( 207 return ios::HistoryServiceFactory::GetForBrowserState(
207 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); 208 browser_state_, ServiceAccessType::EXPLICIT_ACCESS);
208 } 209 }
209 210
210 bool IOSChromeSyncClient::HasPasswordStore() { 211 bool IOSChromeSyncClient::HasPasswordStore() {
211 DCHECK_CURRENTLY_ON(web::WebThread::UI); 212 DCHECK_CURRENTLY_ON(web::WebThread::UI);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 case syncer::READING_LIST: { 351 case syncer::READING_LIST: {
351 DCHECK(reading_list::switches::IsReadingListEnabled()); 352 DCHECK(reading_list::switches::IsReadingListEnabled());
352 ReadingListModel* reading_list_model = 353 ReadingListModel* reading_list_model =
353 ReadingListModelFactory::GetForBrowserState(browser_state_); 354 ReadingListModelFactory::GetForBrowserState(browser_state_);
354 return reading_list_model->GetModelTypeSyncBridge()->AsWeakPtr(); 355 return reading_list_model->GetModelTypeSyncBridge()->AsWeakPtr();
355 } 356 }
356 case syncer::AUTOFILL: 357 case syncer::AUTOFILL:
357 return autofill::AutocompleteSyncBridge::FromWebDataService( 358 return autofill::AutocompleteSyncBridge::FromWebDataService(
358 web_data_service_.get()) 359 web_data_service_.get())
359 ->AsWeakPtr(); 360 ->AsWeakPtr();
361 case syncer::TYPED_URLS: {
362 history::HistoryService* history =
363 ios::HistoryServiceFactory::GetForBrowserState(
364 browser_state_, ServiceAccessType::IMPLICIT_ACCESS);
365 return history ? history->GetTypedURLSyncBridge()->AsWeakPtr()
366 : base::WeakPtr<syncer::ModelTypeSyncBridge>();
367 }
360 default: 368 default:
361 NOTREACHED(); 369 NOTREACHED();
362 return base::WeakPtr<syncer::ModelTypeSyncBridge>(); 370 return base::WeakPtr<syncer::ModelTypeSyncBridge>();
363 } 371 }
364 } 372 }
365 373
366 scoped_refptr<syncer::ModelSafeWorker> 374 scoped_refptr<syncer::ModelSafeWorker>
367 IOSChromeSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) { 375 IOSChromeSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) {
368 DCHECK_CURRENTLY_ON(web::WebThread::UI); 376 DCHECK_CURRENTLY_ON(web::WebThread::UI);
369 switch (group) { 377 switch (group) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); 429 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
422 if (profile_sync_service != nullptr) { 430 if (profile_sync_service != nullptr) {
423 const syncer::DeviceInfoTracker* tracker = 431 const syncer::DeviceInfoTracker* tracker =
424 profile_sync_service->GetDeviceInfoTracker(); 432 profile_sync_service->GetDeviceInfoTracker();
425 if (tracker != nullptr) { 433 if (tracker != nullptr) {
426 trackers->push_back(tracker); 434 trackers->push_back(tracker);
427 } 435 }
428 } 436 }
429 } 437 }
430 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698