OLD | NEW |
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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class | 122 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class |
123 // due to possible multiple inheritance issues, wherein ChromeSyncClient might | 123 // due to possible multiple inheritance issues, wherein ChromeSyncClient might |
124 // inherit from other interfaces with same methods. | 124 // inherit from other interfaces with same methods. |
125 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { | 125 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { |
126 public: | 126 public: |
127 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { | 127 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { |
128 window_delegates_getter_.reset( | 128 window_delegates_getter_.reset( |
129 #if BUILDFLAG(ANDROID_JAVA_UI) | 129 #if BUILDFLAG(ANDROID_JAVA_UI) |
130 // Android doesn't have multi-profile support, so no need to pass the | 130 // Android doesn't have multi-profile support, so no need to pass the |
131 // profile in. | 131 // profile in. |
132 new browser_sync::SyncedWindowDelegatesGetterAndroid()); | 132 new SyncedWindowDelegatesGetterAndroid()); |
133 #else | 133 #else |
134 new browser_sync::BrowserSyncedWindowDelegatesGetter(profile)); | 134 new browser_sync::BrowserSyncedWindowDelegatesGetter(profile)); |
135 #endif | 135 #endif |
136 } | 136 } |
137 ~SyncSessionsClientImpl() override {} | 137 ~SyncSessionsClientImpl() override {} |
138 | 138 |
139 // SyncSessionsClient implementation. | 139 // SyncSessionsClient implementation. |
140 bookmarks::BookmarkModel* GetBookmarkModel() override { | 140 bookmarks::BookmarkModel* GetBookmarkModel() override { |
141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
142 return BookmarkModelFactory::GetForBrowserContext(profile_); | 142 return BookmarkModelFactory::GetForBrowserContext(profile_); |
(...skipping 11 matching lines...) Expand all Loading... |
154 bool ShouldSyncURL(const GURL& url) const override { | 154 bool ShouldSyncURL(const GURL& url) const override { |
155 if (url == GURL(chrome::kChromeUIHistoryURL)) { | 155 if (url == GURL(chrome::kChromeUIHistoryURL)) { |
156 // The history page is treated specially as we want it to trigger syncable | 156 // The history page is treated specially as we want it to trigger syncable |
157 // events for UI purposes. | 157 // events for UI purposes. |
158 return true; | 158 return true; |
159 } | 159 } |
160 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) && | 160 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) && |
161 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile(); | 161 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile(); |
162 } | 162 } |
163 | 163 |
164 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() override { | 164 sync_sessions::SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() |
| 165 override { |
165 return window_delegates_getter_.get(); | 166 return window_delegates_getter_.get(); |
166 } | 167 } |
167 | 168 |
168 std::unique_ptr<browser_sync::LocalSessionEventRouter> | 169 std::unique_ptr<sync_sessions::LocalSessionEventRouter> |
169 GetLocalSessionEventRouter() override { | 170 GetLocalSessionEventRouter() override { |
170 syncer::SyncableService::StartSyncFlare flare( | 171 syncer::SyncableService::StartSyncFlare flare( |
171 sync_start_util::GetFlareForSyncableService(profile_->GetPath())); | 172 sync_start_util::GetFlareForSyncableService(profile_->GetPath())); |
172 return base::MakeUnique<NotificationServiceSessionsRouter>(profile_, this, | 173 return base::MakeUnique<sync_sessions::NotificationServiceSessionsRouter>( |
173 flare); | 174 profile_, this, flare); |
174 } | 175 } |
175 | 176 |
176 private: | 177 private: |
177 Profile* profile_; | 178 Profile* profile_; |
178 std::unique_ptr<SyncedWindowDelegatesGetter> window_delegates_getter_; | 179 std::unique_ptr<sync_sessions::SyncedWindowDelegatesGetter> |
| 180 window_delegates_getter_; |
179 | 181 |
180 DISALLOW_COPY_AND_ASSIGN(SyncSessionsClientImpl); | 182 DISALLOW_COPY_AND_ASSIGN(SyncSessionsClientImpl); |
181 }; | 183 }; |
182 | 184 |
183 ChromeSyncClient::ChromeSyncClient(Profile* profile) | 185 ChromeSyncClient::ChromeSyncClient(Profile* profile) |
184 : profile_(profile), | 186 : profile_(profile), |
185 sync_sessions_client_(new SyncSessionsClientImpl(profile)), | 187 sync_sessions_client_(new SyncSessionsClientImpl(profile)), |
186 weak_ptr_factory_(this) {} | 188 weak_ptr_factory_(this) {} |
187 | 189 |
188 ChromeSyncClient::~ChromeSyncClient() { | 190 ChromeSyncClient::~ChromeSyncClient() { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 return base::WeakPtr<history::TypedUrlSyncableService>(); | 365 return base::WeakPtr<history::TypedUrlSyncableService>(); |
364 return history->GetTypedUrlSyncableService()->AsWeakPtr(); | 366 return history->GetTypedUrlSyncableService()->AsWeakPtr(); |
365 } | 367 } |
366 #if defined(ENABLE_SPELLCHECK) | 368 #if defined(ENABLE_SPELLCHECK) |
367 case syncer::DICTIONARY: | 369 case syncer::DICTIONARY: |
368 return SpellcheckServiceFactory::GetForContext(profile_)-> | 370 return SpellcheckServiceFactory::GetForContext(profile_)-> |
369 GetCustomDictionary()->AsWeakPtr(); | 371 GetCustomDictionary()->AsWeakPtr(); |
370 #endif | 372 #endif |
371 case syncer::FAVICON_IMAGES: | 373 case syncer::FAVICON_IMAGES: |
372 case syncer::FAVICON_TRACKING: { | 374 case syncer::FAVICON_TRACKING: { |
373 browser_sync::FaviconCache* favicons = | 375 sync_sessions::FaviconCache* favicons = |
374 ProfileSyncServiceFactory::GetForProfile(profile_)-> | 376 ProfileSyncServiceFactory::GetForProfile(profile_)->GetFaviconCache(); |
375 GetFaviconCache(); | |
376 return favicons ? favicons->AsWeakPtr() | 377 return favicons ? favicons->AsWeakPtr() |
377 : base::WeakPtr<syncer::SyncableService>(); | 378 : base::WeakPtr<syncer::SyncableService>(); |
378 } | 379 } |
379 #if defined(ENABLE_SUPERVISED_USERS) | 380 #if defined(ENABLE_SUPERVISED_USERS) |
380 case syncer::SUPERVISED_USER_SETTINGS: | 381 case syncer::SUPERVISED_USER_SETTINGS: |
381 return SupervisedUserSettingsServiceFactory::GetForProfile(profile_)-> | 382 return SupervisedUserSettingsServiceFactory::GetForProfile(profile_)-> |
382 AsWeakPtr(); | 383 AsWeakPtr(); |
383 #if !defined(OS_ANDROID) | 384 #if !defined(OS_ANDROID) |
384 case syncer::SUPERVISED_USERS: | 385 case syncer::SUPERVISED_USERS: |
385 return SupervisedUserSyncServiceFactory::GetForProfile(profile_)-> | 386 return SupervisedUserSyncServiceFactory::GetForProfile(profile_)-> |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 sync_service->RegisterDataTypeController( | 628 sync_service->RegisterDataTypeController( |
628 base::MakeUnique<SupervisedUserSyncDataTypeController>( | 629 base::MakeUnique<SupervisedUserSyncDataTypeController>( |
629 syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_)); | 630 syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_)); |
630 sync_service->RegisterDataTypeController( | 631 sync_service->RegisterDataTypeController( |
631 base::MakeUnique<SupervisedUserSyncDataTypeController>( | 632 base::MakeUnique<SupervisedUserSyncDataTypeController>( |
632 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); | 633 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); |
633 #endif | 634 #endif |
634 } | 635 } |
635 | 636 |
636 } // namespace browser_sync | 637 } // namespace browser_sync |
OLD | NEW |