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

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

Issue 1408643002: [Sync] Componentize synced_tab_delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN, self review Created 5 years, 2 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 "chrome/browser/sync/chrome_sync_client.h" 5 #include "chrome/browser/sync/chrome_sync_client.h"
6 6
7 #include "chrome/browser/autofill/personal_data_manager_factory.h" 7 #include "chrome/browser/autofill/personal_data_manager_factory.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
10 #include "chrome/browser/favicon/favicon_service_factory.h" 10 #include "chrome/browser/favicon/favicon_service_factory.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/password_manager/password_store_factory.h" 12 #include "chrome/browser/password_manager/password_store_factory.h"
13 #include "chrome/browser/prefs/pref_service_syncable_util.h" 13 #include "chrome/browser/prefs/pref_service_syncable_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
16 #include "chrome/browser/sync/profile_sync_service.h" 16 #include "chrome/browser/sync/profile_sync_service.h"
17 #include "chrome/browser/sync/profile_sync_service_factory.h" 17 #include "chrome/browser/sync/profile_sync_service_factory.h"
18 #include "chrome/browser/themes/theme_service.h" 18 #include "chrome/browser/themes/theme_service.h"
19 #include "chrome/browser/themes/theme_service_factory.h" 19 #include "chrome/browser/themes/theme_service_factory.h"
20 #include "chrome/browser/themes/theme_syncable_service.h" 20 #include "chrome/browser/themes/theme_syncable_service.h"
21 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 21 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
22 #include "chrome/browser/web_data_service_factory.h" 22 #include "chrome/browser/web_data_service_factory.h"
23 #include "chrome/common/url_constants.h"
23 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h" 24 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h"
24 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" 25 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h"
25 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync able_service.h" 26 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync able_service.h"
26 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv ice.h" 27 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv ice.h"
27 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 28 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
28 #include "components/dom_distiller/core/dom_distiller_service.h" 29 #include "components/dom_distiller/core/dom_distiller_service.h"
29 #include "components/history/core/browser/history_service.h" 30 #include "components/history/core/browser/history_service.h"
30 #include "components/password_manager/core/browser/password_store.h" 31 #include "components/password_manager/core/browser/password_store.h"
31 #include "components/sync_driver/sync_api_component_factory.h" 32 #include "components/sync_driver/sync_api_component_factory.h"
32 #include "components/syncable_prefs/pref_service_syncable.h" 33 #include "components/syncable_prefs/pref_service_syncable.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
35 #include "content/public/common/url_constants.h"
34 36
35 #if defined(ENABLE_APP_LIST) 37 #if defined(ENABLE_APP_LIST)
36 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 38 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
37 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 39 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
38 #include "ui/app_list/app_list_switches.h" 40 #include "ui/app_list/app_list_switches.h"
39 #endif 41 #endif
40 42
41 #if defined(ENABLE_EXTENSIONS) 43 #if defined(ENABLE_EXTENSIONS)
42 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 44 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
43 #include "chrome/browser/extensions/extension_sync_service.h" 45 #include "chrome/browser/extensions/extension_sync_service.h"
(...skipping 19 matching lines...) Expand all
63 #include "chrome/browser/spellchecker/spellcheck_service.h" 65 #include "chrome/browser/spellchecker/spellcheck_service.h"
64 #endif 66 #endif
65 67
66 #if defined(OS_CHROMEOS) 68 #if defined(OS_CHROMEOS)
67 #include "components/wifi_sync/wifi_credential_syncable_service.h" 69 #include "components/wifi_sync/wifi_credential_syncable_service.h"
68 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" 70 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h"
69 #endif 71 #endif
70 72
71 namespace browser_sync { 73 namespace browser_sync {
72 74
75 // Chrome implementation of SyncSesssionsClient. Needs to be in a separate class
maxbogue 2015/10/17 21:53:58 s/sss/ss/
Nicolas Zea 2015/10/20 23:14:41 Done.
76 // due to possible multiple inheritance issues, wherein ChromeSyncClient might
77 // inherit from other interfaces with same methods.
78 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient {
79 public:
80 SyncSessionsClientImpl() {}
81 ~SyncSessionsClientImpl() override {}
82
83 // SyncSesssionsClient implementation.
maxbogue 2015/10/17 21:53:58 s/sss/ss/
Nicolas Zea 2015/10/20 23:14:41 Done.
84 bool ShouldSyncURL(const GURL& url) const override {
85 if (url == GURL(chrome::kChromeUIHistoryURL)) {
86 // The history page is treated specially as we want it to trigger syncable
87 // events for UI purposes.
88 return true;
89 }
90 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) &&
91 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile();
92 }
93 };
94
73 ChromeSyncClient::ChromeSyncClient( 95 ChromeSyncClient::ChromeSyncClient(
74 Profile* profile, 96 Profile* profile,
75 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory) 97 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory)
76 : profile_(profile), component_factory_(component_factory.Pass()) {} 98 : profile_(profile),
99 component_factory_(component_factory.Pass()),
100 sync_sessions_client_(new SyncSessionsClientImpl()) {}
77 ChromeSyncClient::~ChromeSyncClient() { 101 ChromeSyncClient::~ChromeSyncClient() {
78 } 102 }
79 103
80 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { 104 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) {
81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
82 sync_service_ = sync_service; 106 sync_service_ = sync_service;
83 web_data_service_ = GetWebDataService(); 107 web_data_service_ = GetWebDataService();
84 password_store_ = GetPasswordStore(); 108 password_store_ = GetPasswordStore();
85 component_factory_->RegisterDataTypes(this); 109 component_factory_->RegisterDataTypes(this);
86 } 110 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ChromeSyncClient::GetWebDataService() { 154 ChromeSyncClient::GetWebDataService() {
131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 155 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
132 return WebDataServiceFactory::GetAutofillWebDataForProfile( 156 return WebDataServiceFactory::GetAutofillWebDataForProfile(
133 profile_, ServiceAccessType::EXPLICIT_ACCESS); 157 profile_, ServiceAccessType::EXPLICIT_ACCESS);
134 } 158 }
135 159
136 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() { 160 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() {
137 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_); 161 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_);
138 } 162 }
139 163
164 sync_sessions::SyncSessionsClient* ChromeSyncClient::GetSyncSessionsClient() {
165 return sync_sessions_client_.get();
166 }
167
140 base::WeakPtr<syncer::SyncableService> 168 base::WeakPtr<syncer::SyncableService>
141 ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { 169 ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
142 if (!profile_) { // For tests. 170 if (!profile_) { // For tests.
143 return base::WeakPtr<syncer::SyncableService>(); 171 return base::WeakPtr<syncer::SyncableService>();
144 } 172 }
145 switch (type) { 173 switch (type) {
146 case syncer::DEVICE_INFO: 174 case syncer::DEVICE_INFO:
147 return ProfileSyncServiceFactory::GetForProfile(profile_) 175 return ProfileSyncServiceFactory::GetForProfile(profile_)
148 ->GetDeviceInfoSyncableService() 176 ->GetDeviceInfoSyncableService()
149 ->AsWeakPtr(); 177 ->AsWeakPtr();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return base::WeakPtr<syncer::SyncableService>(); 289 return base::WeakPtr<syncer::SyncableService>();
262 } 290 }
263 } 291 }
264 292
265 sync_driver::SyncApiComponentFactory* 293 sync_driver::SyncApiComponentFactory*
266 ChromeSyncClient::GetSyncApiComponentFactory() { 294 ChromeSyncClient::GetSyncApiComponentFactory() {
267 return component_factory_.get(); 295 return component_factory_.get();
268 } 296 }
269 297
270 } // namespace browser_sync 298 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698