Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifdef CHROME_PERSONALIZATION | 5 #ifdef CHROME_PERSONALIZATION |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 7 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 8 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 8 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // - Credentials are now in flight for authentication. | 56 // - Credentials are now in flight for authentication. |
| 57 virtual void OnStateChanged() = 0; | 57 virtual void OnStateChanged() = 0; |
| 58 protected: | 58 protected: |
| 59 virtual ~ProfileSyncServiceObserver() { } | 59 virtual ~ProfileSyncServiceObserver() { } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // ProfileSyncService is the layer between browser subsystems like bookmarks, | 62 // ProfileSyncService is the layer between browser subsystems like bookmarks, |
| 63 // and the sync backend. | 63 // and the sync backend. |
| 64 class ProfileSyncService : public NotificationObserver, | 64 class ProfileSyncService : public NotificationObserver, |
| 65 public browser_sync::SyncFrontend, | 65 public browser_sync::SyncFrontend, |
| 66 public browser_sync::UnrecoverableErrorHandler { | 66 public browser_sync::UnrecoverableErrorHandler, |
| 67 public SyncSetupWizard::WizardParentDelegate { | |
| 67 public: | 68 public: |
| 68 typedef ProfileSyncServiceObserver Observer; | 69 typedef ProfileSyncServiceObserver Observer; |
| 69 typedef browser_sync::SyncBackendHost::Status Status; | 70 typedef browser_sync::SyncBackendHost::Status Status; |
| 70 | 71 |
| 71 enum SyncEventCodes { | 72 enum SyncEventCodes { |
| 72 MIN_SYNC_EVENT_CODE = 0, | 73 MIN_SYNC_EVENT_CODE = 0, |
| 73 | 74 |
| 74 // Events starting the sync service. | 75 // Events starting the sync service. |
| 75 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 76 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 76 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 77 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 explicit ProfileSyncService(Profile* profile); | 96 explicit ProfileSyncService(Profile* profile); |
| 96 virtual ~ProfileSyncService(); | 97 virtual ~ProfileSyncService(); |
| 97 | 98 |
| 98 // Initializes the object. This should be called every time an object of this | 99 // Initializes the object. This should be called every time an object of this |
| 99 // class is constructed. | 100 // class is constructed. |
| 100 void Initialize(); | 101 void Initialize(); |
| 101 | 102 |
| 102 // Enables/disables sync for user. | 103 // Enables/disables sync for user. |
| 103 virtual void EnableForUser(); | 104 virtual void EnableForUser(gfx::NativeWindow parent_window); |
|
tim (not reviewing)
2009/10/29 21:58:44
can we call it setup_dialog_parent_window, and add
| |
| 104 virtual void DisableForUser(); | 105 virtual void DisableForUser(); |
| 105 | 106 |
| 106 // Whether sync is enabled by user or not. | 107 // Whether sync is enabled by user or not. |
| 107 bool HasSyncSetupCompleted() const; | 108 bool HasSyncSetupCompleted() const; |
| 108 void SetSyncSetupCompleted(); | 109 void SetSyncSetupCompleted(); |
| 109 | 110 |
| 110 // NotificationObserver implementation. | 111 // NotificationObserver implementation. |
| 111 virtual void Observe(NotificationType type, | 112 virtual void Observe(NotificationType type, |
| 112 const NotificationSource& source, | 113 const NotificationSource& source, |
| 113 const NotificationDetails& details); | 114 const NotificationDetails& details); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 140 // Returns false if a dialog is already showing, an auth attempt is in | 141 // Returns false if a dialog is already showing, an auth attempt is in |
| 141 // progress, the sync system is already authenticated, or some error | 142 // progress, the sync system is already authenticated, or some error |
| 142 // occurred preventing the action. We make it the duty of ProfileSyncService | 143 // occurred preventing the action. We make it the duty of ProfileSyncService |
| 143 // to open the dialog to easily ensure only one is ever showing. | 144 // to open the dialog to easily ensure only one is ever showing. |
| 144 bool SetupInProgress() const { | 145 bool SetupInProgress() const { |
| 145 return !HasSyncSetupCompleted() && WizardIsVisible(); | 146 return !HasSyncSetupCompleted() && WizardIsVisible(); |
| 146 } | 147 } |
| 147 bool WizardIsVisible() const { | 148 bool WizardIsVisible() const { |
| 148 return wizard_.IsVisible(); | 149 return wizard_.IsVisible(); |
| 149 } | 150 } |
| 150 void ShowLoginDialog(); | 151 gfx::NativeWindow GetWizardParent() const { |
|
tim (not reviewing)
2009/10/29 21:58:44
please add virtual
| |
| 152 return wizard_parent_window_; | |
| 153 } | |
| 154 void ShowLoginDialog(gfx::NativeWindow parent_window); | |
|
tim (not reviewing)
2009/10/29 21:58:44
the name of the variable is fine here, but please
| |
| 151 | 155 |
| 152 // Pretty-printed strings for a given StatusSummary. | 156 // Pretty-printed strings for a given StatusSummary. |
| 153 static std::wstring BuildSyncStatusSummaryText( | 157 static std::wstring BuildSyncStatusSummaryText( |
| 154 const browser_sync::SyncBackendHost::StatusSummary& summary); | 158 const browser_sync::SyncBackendHost::StatusSummary& summary); |
| 155 | 159 |
| 156 // Returns true if the SyncBackendHost has told us it's ready to accept | 160 // Returns true if the SyncBackendHost has told us it's ready to accept |
| 157 // changes. | 161 // changes. |
| 158 // TODO(timsteele): What happens if the bookmark model is loaded, a change | 162 // TODO(timsteele): What happens if the bookmark model is loaded, a change |
| 159 // takes place, and the backend isn't initialized yet? | 163 // takes place, and the backend isn't initialized yet? |
| 160 bool sync_initialized() const { return backend_initialized_; } | 164 bool sync_initialized() const { return backend_initialized_; } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 // one, it is actually an error and this bool isn't needed. | 298 // one, it is actually an error and this bool isn't needed. |
| 295 bool expecting_first_run_auth_needed_event_; | 299 bool expecting_first_run_auth_needed_event_; |
| 296 | 300 |
| 297 // Various pieces of UI query this value to determine if they should show | 301 // Various pieces of UI query this value to determine if they should show |
| 298 // an "Authenticating.." type of message. We are the only central place | 302 // an "Authenticating.." type of message. We are the only central place |
| 299 // all auth attempts funnel through, so it makes sense to provide this. | 303 // all auth attempts funnel through, so it makes sense to provide this. |
| 300 // As its name suggests, this should NOT be used for anything other than UI. | 304 // As its name suggests, this should NOT be used for anything other than UI. |
| 301 bool is_auth_in_progress_; | 305 bool is_auth_in_progress_; |
| 302 | 306 |
| 303 SyncSetupWizard wizard_; | 307 SyncSetupWizard wizard_; |
| 308 gfx::NativeWindow wizard_parent_window_; | |
| 304 | 309 |
| 305 // True if an unrecoverable error (e.g. violation of an assumed invariant) | 310 // True if an unrecoverable error (e.g. violation of an assumed invariant) |
| 306 // occurred during syncer operation. This value should be checked before | 311 // occurred during syncer operation. This value should be checked before |
| 307 // doing any work that might corrupt things further. | 312 // doing any work that might corrupt things further. |
| 308 bool unrecoverable_error_detected_; | 313 bool unrecoverable_error_detected_; |
| 309 | 314 |
| 310 ObserverList<Observer> observers_; | 315 ObserverList<Observer> observers_; |
| 311 | 316 |
| 312 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 317 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 313 }; | 318 }; |
| 314 | 319 |
| 315 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 320 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 316 | 321 |
| 317 #endif // CHROME_PERSONALIZATION | 322 #endif // CHROME_PERSONALIZATION |
| OLD | NEW |