| 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 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Events starting the sync service. | 101 // Events starting the sync service. |
| 102 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 102 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 103 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. | 103 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| 104 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. | 104 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
| 105 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. | 105 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. |
| 106 | 106 |
| 107 // Events regarding cancellation of the signon process of sync. | 107 // Events regarding cancellation of the signon process of sync. |
| 108 CANCEL_FROM_SIGNON_WITHOUT_AUTH = 10, // Cancelled before submitting | 108 CANCEL_FROM_SIGNON_WITHOUT_AUTH = 10, // Cancelled before submitting |
| 109 // username and password. | 109 // username and password. |
| 110 CANCEL_DURING_SIGNON = 11, // Cancelled after auth. | 110 CANCEL_DURING_SIGNON = 11, // Cancelled after auth. |
| 111 CANCEL_FROM_CHOOSE_DATA_TYPES = 12, // Cancelled before choosing data | 111 |
| 112 // types and clicking OK. | |
| 113 // Events resulting in the stoppage of sync service. | 112 // Events resulting in the stoppage of sync service. |
| 114 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. | 113 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. |
| 115 | 114 |
| 116 // Miscellaneous events caused by sync service. | 115 // Miscellaneous events caused by sync service. |
| 117 | 116 |
| 118 MAX_SYNC_EVENT_CODE | 117 MAX_SYNC_EVENT_CODE |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 // Default sync server URL. | 120 // Default sync server URL. |
| 122 static const char* kSyncServerUrl; | 121 static const char* kSyncServerUrl; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 virtual void OnSyncCycleCompleted(); | 156 virtual void OnSyncCycleCompleted(); |
| 158 virtual void OnAuthError(); | 157 virtual void OnAuthError(); |
| 159 | 158 |
| 160 // Called when a user enters credentials through UI. | 159 // Called when a user enters credentials through UI. |
| 161 virtual void OnUserSubmittedAuth(const std::string& username, | 160 virtual void OnUserSubmittedAuth(const std::string& username, |
| 162 const std::string& password, | 161 const std::string& password, |
| 163 const std::string& captcha); | 162 const std::string& captcha); |
| 164 | 163 |
| 165 // Called when a user chooses which data types to sync as part of the sync | 164 // Called when a user chooses which data types to sync as part of the sync |
| 166 // setup wizard. |sync_everything| represents whether they chose the | 165 // setup wizard. |sync_everything| represents whether they chose the |
| 167 // "keep everything synced" option; if true, |chosen_types| will be ignored | 166 // "keep everything synced" option; if true, data_types will be ignored and |
| 168 // and all data types will be synced. |sync_everything| means "sync all | 167 // all data types will be synced. |sync_everything| means "sync all current |
| 169 // current and future data types." | 168 // and future data types." |
| 170 virtual void OnUserChoseDatatypes(bool sync_everything, | 169 virtual void OnUserChoseDatatypes(bool sync_everything, |
| 171 const syncable::ModelTypeSet& chosen_types); | 170 const syncable::ModelTypeSet& data_types); |
| 172 | 171 |
| 173 // Called when a user cancels any setup dialog (login, etc). | 172 // Called when a user cancels any setup dialog (login, etc). |
| 174 virtual void OnUserCancelledDialog(); | 173 virtual void OnUserCancelledDialog(); |
| 175 | 174 |
| 176 // Get various information for displaying in the user interface. | 175 // Get various information for displaying in the user interface. |
| 177 browser_sync::SyncBackendHost::StatusSummary QuerySyncStatusSummary(); | 176 browser_sync::SyncBackendHost::StatusSummary QuerySyncStatusSummary(); |
| 178 browser_sync::SyncBackendHost::Status QueryDetailedSyncStatus(); | 177 browser_sync::SyncBackendHost::Status QueryDetailedSyncStatus(); |
| 179 | 178 |
| 180 const GoogleServiceAuthError& GetAuthError() const { | 179 const GoogleServiceAuthError& GetAuthError() const { |
| 181 return last_auth_error_; | 180 return last_auth_error_; |
| 182 } | 181 } |
| 183 | 182 |
| 184 // Displays a dialog for the user to enter GAIA credentials and attempt | 183 // Displays a dialog for the user to enter GAIA credentials and attempt |
| 185 // re-authentication, and returns true if it actually opened the dialog. | 184 // re-authentication, and returns true if it actually opened the dialog. |
| 186 // Returns false if a dialog is already showing, an auth attempt is in | 185 // Returns false if a dialog is already showing, an auth attempt is in |
| 187 // progress, the sync system is already authenticated, or some error | 186 // progress, the sync system is already authenticated, or some error |
| 188 // occurred preventing the action. We make it the duty of ProfileSyncService | 187 // occurred preventing the action. We make it the duty of ProfileSyncService |
| 189 // to open the dialog to easily ensure only one is ever showing. | 188 // to open the dialog to easily ensure only one is ever showing. |
| 190 bool SetupInProgress() const { | 189 bool SetupInProgress() const { |
| 191 return !HasSyncSetupCompleted() && | 190 return !HasSyncSetupCompleted() && |
| 192 (WizardIsVisible() || bootstrap_sync_authentication_); | 191 (WizardIsVisible() || bootstrap_sync_authentication_); |
| 193 } | 192 } |
| 194 bool WizardIsVisible() const { | 193 bool WizardIsVisible() const { |
| 195 return wizard_.IsVisible(); | 194 return wizard_.IsVisible(); |
| 196 } | 195 } |
| 197 void ShowLoginDialog(); | 196 void ShowLoginDialog(); |
| 198 | 197 |
| 199 void ShowChooseDataTypes(); | |
| 200 | |
| 201 // Pretty-printed strings for a given StatusSummary. | 198 // Pretty-printed strings for a given StatusSummary. |
| 202 static std::wstring BuildSyncStatusSummaryText( | 199 static std::wstring BuildSyncStatusSummaryText( |
| 203 const browser_sync::SyncBackendHost::StatusSummary& summary); | 200 const browser_sync::SyncBackendHost::StatusSummary& summary); |
| 204 | 201 |
| 205 // Returns true if the SyncBackendHost has told us it's ready to accept | 202 // Returns true if the SyncBackendHost has told us it's ready to accept |
| 206 // changes. | 203 // changes. |
| 207 // TODO(timsteele): What happens if the bookmark model is loaded, a change | 204 // TODO(timsteele): What happens if the bookmark model is loaded, a change |
| 208 // takes place, and the backend isn't initialized yet? | 205 // takes place, and the backend isn't initialized yet? |
| 209 bool sync_initialized() const { return backend_initialized_; } | 206 bool sync_initialized() const { return backend_initialized_; } |
| 210 bool unrecoverable_error_detected() const { | 207 bool unrecoverable_error_detected() const { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 438 |
| 442 NotificationRegistrar registrar_; | 439 NotificationRegistrar registrar_; |
| 443 | 440 |
| 444 ScopedRunnableMethodFactory<ProfileSyncService> | 441 ScopedRunnableMethodFactory<ProfileSyncService> |
| 445 scoped_runnable_method_factory_; | 442 scoped_runnable_method_factory_; |
| 446 | 443 |
| 447 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 444 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 448 }; | 445 }; |
| 449 | 446 |
| 450 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 447 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |