OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
7 | 7 |
| 8 #include <set> |
8 #include <string> | 9 #include <string> |
9 #include <utility> | 10 #include <utility> |
10 #include <vector> | |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
(...skipping 29 matching lines...) Expand all Loading... |
50 #include "sync/internal_api/public/util/experiments.h" | 50 #include "sync/internal_api/public/util/experiments.h" |
51 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 51 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
52 #include "sync/js/sync_js_controller.h" | 52 #include "sync/js/sync_js_controller.h" |
53 #include "url/gurl.h" | 53 #include "url/gurl.h" |
54 | 54 |
55 class Profile; | 55 class Profile; |
56 class ProfileOAuth2TokenService; | 56 class ProfileOAuth2TokenService; |
57 class ProfileSyncComponentsFactory; | 57 class ProfileSyncComponentsFactory; |
58 class SupervisedUserSigninManagerWrapper; | 58 class SupervisedUserSigninManagerWrapper; |
59 class SyncErrorController; | 59 class SyncErrorController; |
| 60 class SyncTypePreferenceProvider; |
60 | 61 |
61 namespace base { | 62 namespace base { |
62 class CommandLine; | 63 class CommandLine; |
63 }; | 64 }; |
64 | 65 |
65 namespace browser_sync { | 66 namespace browser_sync { |
66 class BackendMigrator; | 67 class BackendMigrator; |
67 class DeviceInfo; | 68 class DeviceInfo; |
68 class FaviconCache; | 69 class FaviconCache; |
69 class JsController; | 70 class JsController; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 ProfileSyncServiceBase::Observer* observer) const OVERRIDE; | 295 ProfileSyncServiceBase::Observer* observer) const OVERRIDE; |
295 | 296 |
296 | 297 |
297 void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); | 298 void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); |
298 void RemoveProtocolEventObserver( | 299 void RemoveProtocolEventObserver( |
299 browser_sync::ProtocolEventObserver* observer); | 300 browser_sync::ProtocolEventObserver* observer); |
300 | 301 |
301 void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); | 302 void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); |
302 void RemoveTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); | 303 void RemoveTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); |
303 | 304 |
| 305 // Add a sync type preference provider. Each provider may only be added once. |
| 306 void AddPreferenceProvider(SyncTypePreferenceProvider* provider); |
| 307 // Remove a sync type preference provider. May only be called for providers |
| 308 // that have been added. Providers must not remove themselves while being |
| 309 // called back. |
| 310 void RemovePreferenceProvider(SyncTypePreferenceProvider* provider); |
| 311 // Check whether a given sync type preference provider has been added. |
| 312 bool HasPreferenceProvider(SyncTypePreferenceProvider* provider) const; |
| 313 |
304 // Asynchronously fetches base::Value representations of all sync nodes and | 314 // Asynchronously fetches base::Value representations of all sync nodes and |
305 // returns them to the specified callback on this thread. | 315 // returns them to the specified callback on this thread. |
306 // | 316 // |
307 // These requests can live a long time and return when you least expect it. | 317 // These requests can live a long time and return when you least expect it. |
308 // For safety, the callback should be bound to some sort of WeakPtr<> or | 318 // For safety, the callback should be bound to some sort of WeakPtr<> or |
309 // scoped_refptr<>. | 319 // scoped_refptr<>. |
310 void GetAllNodes( | 320 void GetAllNodes( |
311 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); | 321 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); |
312 | 322 |
313 void RegisterAuthNotifications(); | 323 void RegisterAuthNotifications(); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 void RegisterNewDataType(syncer::ModelType data_type); | 923 void RegisterNewDataType(syncer::ModelType data_type); |
914 | 924 |
915 // Reconfigures the data type manager with the latest enabled types. | 925 // Reconfigures the data type manager with the latest enabled types. |
916 // Note: Does not initialize the backend if it is not already initialized. | 926 // Note: Does not initialize the backend if it is not already initialized. |
917 // This function needs to be called only after sync has been initialized | 927 // This function needs to be called only after sync has been initialized |
918 // (i.e.,only for reconfigurations). The reason we don't initialize the | 928 // (i.e.,only for reconfigurations). The reason we don't initialize the |
919 // backend is because if we had encountered an unrecoverable error we don't | 929 // backend is because if we had encountered an unrecoverable error we don't |
920 // want to startup once more. | 930 // want to startup once more. |
921 virtual void ReconfigureDatatypeManager(); | 931 virtual void ReconfigureDatatypeManager(); |
922 | 932 |
| 933 // Collects preferred sync data types from |preference_providers_|. |
| 934 syncer::ModelTypeSet GetDataTypesFromPreferenceProviders(); |
| 935 |
923 // Called when the user changes the sync configuration, to update the UMA | 936 // Called when the user changes the sync configuration, to update the UMA |
924 // stats. | 937 // stats. |
925 void UpdateSelectedTypesHistogram( | 938 void UpdateSelectedTypesHistogram( |
926 bool sync_everything, | 939 bool sync_everything, |
927 const syncer::ModelTypeSet chosen_types) const; | 940 const syncer::ModelTypeSet chosen_types) const; |
928 | 941 |
929 #if defined(OS_CHROMEOS) | 942 #if defined(OS_CHROMEOS) |
930 // Refresh spare sync bootstrap token for re-enabling the sync service. | 943 // Refresh spare sync bootstrap token for re-enabling the sync service. |
931 // Called on successful sign-in notifications. | 944 // Called on successful sign-in notifications. |
932 void RefreshSpareBootstrapToken(const std::string& passphrase); | 945 void RefreshSpareBootstrapToken(const std::string& passphrase); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 // Manages the start and stop of the directory data types. | 1030 // Manages the start and stop of the directory data types. |
1018 scoped_ptr<sync_driver::DataTypeManager> directory_data_type_manager_; | 1031 scoped_ptr<sync_driver::DataTypeManager> directory_data_type_manager_; |
1019 | 1032 |
1020 // Manager for the non-blocking data types. | 1033 // Manager for the non-blocking data types. |
1021 sync_driver::NonBlockingDataTypeManager non_blocking_data_type_manager_; | 1034 sync_driver::NonBlockingDataTypeManager non_blocking_data_type_manager_; |
1022 | 1035 |
1023 ObserverList<ProfileSyncServiceBase::Observer> observers_; | 1036 ObserverList<ProfileSyncServiceBase::Observer> observers_; |
1024 ObserverList<browser_sync::ProtocolEventObserver> protocol_event_observers_; | 1037 ObserverList<browser_sync::ProtocolEventObserver> protocol_event_observers_; |
1025 ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; | 1038 ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; |
1026 | 1039 |
| 1040 std::set<SyncTypePreferenceProvider*> preference_providers_; |
| 1041 |
1027 syncer::SyncJsController sync_js_controller_; | 1042 syncer::SyncJsController sync_js_controller_; |
1028 | 1043 |
1029 // This allows us to gracefully handle an ABORTED return code from the | 1044 // This allows us to gracefully handle an ABORTED return code from the |
1030 // DataTypeManager in the event that the server informed us to cease and | 1045 // DataTypeManager in the event that the server informed us to cease and |
1031 // desist syncing immediately. | 1046 // desist syncing immediately. |
1032 bool expect_sync_configuration_aborted_; | 1047 bool expect_sync_configuration_aborted_; |
1033 | 1048 |
1034 // Sometimes we need to temporarily hold on to a passphrase because we don't | 1049 // Sometimes we need to temporarily hold on to a passphrase because we don't |
1035 // yet have a backend to send it to. This happens during initialization as | 1050 // yet have a backend to send it to. This happens during initialization as |
1036 // we don't StartUp until we have a valid token, which happens after valid | 1051 // we don't StartUp until we have a valid token, which happens after valid |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 scoped_ptr<base::Time> last_backup_time_; | 1152 scoped_ptr<base::Time> last_backup_time_; |
1138 | 1153 |
1139 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1154 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
1140 }; | 1155 }; |
1141 | 1156 |
1142 bool ShouldShowActionOnUI( | 1157 bool ShouldShowActionOnUI( |
1143 const syncer::SyncProtocolError& error); | 1158 const syncer::SyncProtocolError& error); |
1144 | 1159 |
1145 | 1160 |
1146 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1161 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |