OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 8 #include <string> |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/google_service_auth_error.h" | 16 #include "chrome/browser/google_service_auth_error.h" |
| 17 #include "chrome/browser/pref_member.h" |
17 #include "chrome/browser/sync/glue/data_type_controller.h" | 18 #include "chrome/browser/sync/glue/data_type_controller.h" |
18 #include "chrome/browser/sync/glue/data_type_manager.h" | 19 #include "chrome/browser/sync/glue/data_type_manager.h" |
19 #include "chrome/browser/sync/glue/sync_backend_host.h" | 20 #include "chrome/browser/sync/glue/sync_backend_host.h" |
20 #include "chrome/browser/sync/notification_method.h" | 21 #include "chrome/browser/sync/notification_method.h" |
| 22 #include "chrome/browser/sync/profile_sync_service_observer.h" |
21 #include "chrome/browser/sync/sync_setup_wizard.h" | 23 #include "chrome/browser/sync/sync_setup_wizard.h" |
22 #include "chrome/browser/sync/syncable/model_type.h" | 24 #include "chrome/browser/sync/syncable/model_type.h" |
23 #include "chrome/browser/sync/unrecoverable_error_handler.h" | 25 #include "chrome/browser/sync/unrecoverable_error_handler.h" |
24 #include "chrome/common/notification_observer.h" | 26 #include "chrome/common/notification_observer.h" |
25 #include "chrome/common/notification_registrar.h" | 27 #include "chrome/common/notification_registrar.h" |
26 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
27 | 29 |
28 class NotificationDetails; | 30 class NotificationDetails; |
29 class NotificationSource; | 31 class NotificationSource; |
30 class NotificationType; | 32 class NotificationType; |
31 class Profile; | 33 class Profile; |
32 class ProfileSyncFactory; | 34 class ProfileSyncFactory; |
33 | 35 |
34 // Various UI components such as the New Tab page can be driven by observing | |
35 // the ProfileSyncService through this interface. | |
36 class ProfileSyncServiceObserver { | |
37 public: | |
38 // When one of the following events occurs, OnStateChanged() is called. | |
39 // Observers should query the service to determine what happened. | |
40 // - We initialized successfully. | |
41 // - There was an authentication error and the user needs to reauthenticate. | |
42 // - The sync servers are unavailable at this time. | |
43 // - Credentials are now in flight for authentication. | |
44 virtual void OnStateChanged() = 0; | |
45 protected: | |
46 virtual ~ProfileSyncServiceObserver() { } | |
47 }; | |
48 | |
49 // ProfileSyncService is the layer between browser subsystems like bookmarks, | 36 // ProfileSyncService is the layer between browser subsystems like bookmarks, |
50 // and the sync backend. Each subsystem is logically thought of as being | 37 // and the sync backend. Each subsystem is logically thought of as being |
51 // a sync datatype. | 38 // a sync datatype. |
52 // | 39 // |
53 // Individual datatypes can, at any point, be in a variety of stages of being | 40 // Individual datatypes can, at any point, be in a variety of stages of being |
54 // "enabled". Here are some specific terms for concepts used in this class: | 41 // "enabled". Here are some specific terms for concepts used in this class: |
55 // | 42 // |
56 // 'Registered' (feature suppression for a datatype) | 43 // 'Registered' (feature suppression for a datatype) |
57 // | 44 // |
58 // When a datatype is registered, the user has the option of syncing it. | 45 // When a datatype is registered, the user has the option of syncing it. |
(...skipping 191 matching lines...) Loading... |
250 virtual void RemoveObserver(Observer* observer); | 237 virtual void RemoveObserver(Observer* observer); |
251 | 238 |
252 // Record stats on various events. | 239 // Record stats on various events. |
253 static void SyncEvent(SyncEventCodes code); | 240 static void SyncEvent(SyncEventCodes code); |
254 | 241 |
255 // Returns whether sync is enabled. Sync can be enabled/disabled both | 242 // Returns whether sync is enabled. Sync can be enabled/disabled both |
256 // at compile time (e.g., on a per-OS basis) or at run time (e.g., | 243 // at compile time (e.g., on a per-OS basis) or at run time (e.g., |
257 // command-line switches). | 244 // command-line switches). |
258 static bool IsSyncEnabled(); | 245 static bool IsSyncEnabled(); |
259 | 246 |
| 247 // Retuns whether sync is managed, i.e. controlled by configuration |
| 248 // management. If so, the user is not allowed to configure sync. |
| 249 bool IsManaged(); |
| 250 |
260 // UnrecoverableErrorHandler implementation. | 251 // UnrecoverableErrorHandler implementation. |
261 virtual void OnUnrecoverableError( | 252 virtual void OnUnrecoverableError( |
262 const tracked_objects::Location& from_here, | 253 const tracked_objects::Location& from_here, |
263 const std::string& message); | 254 const std::string& message); |
264 | 255 |
265 browser_sync::SyncBackendHost* backend() { return backend_.get(); } | 256 browser_sync::SyncBackendHost* backend() { return backend_.get(); } |
266 | 257 |
267 virtual void ActivateDataType( | 258 virtual void ActivateDataType( |
268 browser_sync::DataTypeController* data_type_controller, | 259 browser_sync::DataTypeController* data_type_controller, |
269 browser_sync::ChangeProcessor* change_processor); | 260 browser_sync::ChangeProcessor* change_processor); |
(...skipping 168 matching lines...) Loading... |
438 // Manages the start and stop of the various data types. | 429 // Manages the start and stop of the various data types. |
439 scoped_ptr<browser_sync::DataTypeManager> data_type_manager_; | 430 scoped_ptr<browser_sync::DataTypeManager> data_type_manager_; |
440 | 431 |
441 ObserverList<Observer> observers_; | 432 ObserverList<Observer> observers_; |
442 | 433 |
443 NotificationRegistrar registrar_; | 434 NotificationRegistrar registrar_; |
444 | 435 |
445 ScopedRunnableMethodFactory<ProfileSyncService> | 436 ScopedRunnableMethodFactory<ProfileSyncService> |
446 scoped_runnable_method_factory_; | 437 scoped_runnable_method_factory_; |
447 | 438 |
| 439 // The preference that controls whether sync is under control by configuration |
| 440 // management. |
| 441 BooleanPrefMember pref_sync_managed_; |
| 442 |
448 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 443 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
449 }; | 444 }; |
450 | 445 |
451 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 446 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |