[email protected] | ebbbb9f | 2011-03-09 13:16:14 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 8 | |
| 9 | #include <string> |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 10 | |
| 11 | #include "base/basictypes.h" |
[email protected] | 61b694a | 2010-06-10 10:40:46 | [diff] [blame] | 12 | #include "base/gtest_prod_util.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 13 | #include "base/memory/scoped_ptr.h" |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 14 | #include "base/observer_list.h" |
[email protected] | 06614687 | 2010-08-05 00:55:08 | [diff] [blame] | 15 | #include "base/string16.h" |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 16 | #include "base/task.h" |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 17 | #include "base/time.h" |
[email protected] | 990de36 | 2010-10-13 17:55:50 | [diff] [blame] | 18 | #include "base/timer.h" |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 19 | #include "base/tracked.h" |
[email protected] | 37858e5 | 2010-08-26 00:22:02 | [diff] [blame] | 20 | #include "chrome/browser/prefs/pref_member.h" |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 21 | #include "chrome/browser/sync/engine/model_safe_worker.h" |
[email protected] | 72a31b4 | 2010-02-17 22:26:33 | [diff] [blame] | 22 | #include "chrome/browser/sync/glue/data_type_controller.h" |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 23 | #include "chrome/browser/sync/glue/sync_backend_host.h" |
[email protected] | f92351d | 2011-02-01 07:42:12 | [diff] [blame] | 24 | #include "chrome/browser/sync/js_event_handler_list.h" |
[email protected] | d3b98c8 | 2010-07-14 07:45:59 | [diff] [blame] | 25 | #include "chrome/browser/sync/profile_sync_service_observer.h" |
[email protected] | d80033e | 2009-10-16 10:32:04 | [diff] [blame] | 26 | #include "chrome/browser/sync/sync_setup_wizard.h" |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 27 | #include "chrome/browser/sync/syncable/autofill_migration.h" |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 28 | #include "chrome/browser/sync/syncable/model_type.h" |
[email protected] | eafb218 | 2010-03-03 00:46:31 | [diff] [blame] | 29 | #include "chrome/browser/sync/unrecoverable_error_handler.h" |
[email protected] | 99074c5 | 2010-08-19 18:44:19 | [diff] [blame] | 30 | #include "chrome/common/net/gaia/google_service_auth_error.h" |
[email protected] | ebbbb9f | 2011-03-09 13:16:14 | [diff] [blame] | 31 | #include "content/common/notification_observer.h" |
| 32 | #include "content/common/notification_registrar.h" |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 33 | #include "content/common/notification_type.h" |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 34 | #include "googleurl/src/gurl.h" |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 35 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 36 | |
[email protected] | c4c672a | 2010-03-23 21:47:04 | [diff] [blame] | 37 | class NotificationDetails; |
| 38 | class NotificationSource; |
[email protected] | 942690b13 | 2010-05-11 06:42:14 | [diff] [blame] | 39 | class Profile; |
| 40 | class ProfileSyncFactory; |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 41 | class SigninManager; |
[email protected] | c4c672a | 2010-03-23 21:47:04 | [diff] [blame] | 42 | |
[email protected] | f92351d | 2011-02-01 07:42:12 | [diff] [blame] | 43 | namespace browser_sync { |
[email protected] | dc55625 | 2011-04-20 01:59:35 | [diff] [blame] | 44 | class BackendMigrator; |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 45 | class ChangeProcessor; |
| 46 | class DataTypeManager; |
[email protected] | f92351d | 2011-02-01 07:42:12 | [diff] [blame] | 47 | class JsFrontend; |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 48 | class SessionModelAssociator; |
| 49 | namespace sessions { struct SyncSessionSnapshot; } |
| 50 | } |
| 51 | |
| 52 | namespace sync_api { |
| 53 | class BaseTransaction; |
| 54 | struct SyncCredentials; |
| 55 | struct UserShare; |
| 56 | } |
[email protected] | f92351d | 2011-02-01 07:42:12 | [diff] [blame] | 57 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 58 | // ProfileSyncService is the layer between browser subsystems like bookmarks, |
[email protected] | a1c2aef6 | 2010-04-02 02:58:05 | [diff] [blame] | 59 | // and the sync backend. Each subsystem is logically thought of as being |
| 60 | // a sync datatype. |
| 61 | // |
| 62 | // Individual datatypes can, at any point, be in a variety of stages of being |
| 63 | // "enabled". Here are some specific terms for concepts used in this class: |
| 64 | // |
| 65 | // 'Registered' (feature suppression for a datatype) |
| 66 | // |
| 67 | // When a datatype is registered, the user has the option of syncing it. |
| 68 | // The sync opt-in UI will show only registered types; a checkbox should |
| 69 | // never be shown for an unregistered type, and nor should it ever be |
| 70 | // synced. |
| 71 | // |
| 72 | // A datatype is considered registered once RegisterDataTypeController |
| 73 | // has been called with that datatype's DataTypeController. |
| 74 | // |
| 75 | // 'Preferred' (user preferences and opt-out for a datatype) |
| 76 | // |
| 77 | // This means the user's opt-in or opt-out preference on a per-datatype |
| 78 | // basis. The sync service will try to make active exactly these types. |
| 79 | // If a user has opted out of syncing a particular datatype, it will |
| 80 | // be registered, but not preferred. |
| 81 | // |
| 82 | // This state is controlled by the ConfigurePreferredDataTypes and |
| 83 | // GetPreferredDataTypes. They are stored in the preferences system, |
| 84 | // and persist; though if a datatype is not registered, it cannot |
| 85 | // be a preferred datatype. |
| 86 | // |
| 87 | // 'Active' (run-time initialization of sync system for a datatype) |
| 88 | // |
| 89 | // An active datatype is a preferred datatype that is actively being |
| 90 | // synchronized: the syncer has been instructed to querying the server |
| 91 | // for this datatype, first-time merges have finished, and there is an |
| 92 | // actively installed ChangeProcessor that listens for changes to this |
| 93 | // datatype, propagating such changes into and out of the sync backend |
| 94 | // as necessary. |
| 95 | // |
| 96 | // When a datatype is in the process of becoming active, it may be |
| 97 | // in some intermediate state. Those finer-grained intermediate states |
| 98 | // are differentiated by the DataTypeController state. |
| 99 | // |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 100 | class ProfileSyncService : public browser_sync::SyncFrontend, |
[email protected] | c4c672a | 2010-03-23 21:47:04 | [diff] [blame] | 101 | public browser_sync::UnrecoverableErrorHandler, |
| 102 | public NotificationObserver { |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 103 | public: |
| 104 | typedef ProfileSyncServiceObserver Observer; |
| 105 | typedef browser_sync::SyncBackendHost::Status Status; |
| 106 | |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 107 | enum SyncEventCodes { |
| 108 | MIN_SYNC_EVENT_CODE = 0, |
| 109 | |
| 110 | // Events starting the sync service. |
| 111 | START_FROM_NTP = 1, // Sync was started from the ad in NTP |
| 112 | START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. |
| 113 | START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. |
[email protected] | b220d13f | 2009-10-09 04:12:46 | [diff] [blame] | 114 | START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. |
[email protected] | 29d7025 | 2011-04-28 02:16:58 | [diff] [blame] | 115 | START_FROM_PROFILE_MENU = 5, // Sync was started from multiprofile menu. |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 116 | |
[email protected] | a7ab833 | 2010-03-31 20:49:04 | [diff] [blame] | 117 | // Events regarding cancellation of the signon process of sync. |
[email protected] | 8ac2dc11 | 2009-10-01 23:19:13 | [diff] [blame] | 118 | CANCEL_FROM_SIGNON_WITHOUT_AUTH = 10, // Cancelled before submitting |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 119 | // username and password. |
| 120 | CANCEL_DURING_SIGNON = 11, // Cancelled after auth. |
[email protected] | c976938f | 2010-10-12 04:55:44 | [diff] [blame] | 121 | CANCEL_DURING_CONFIGURE = 12, // Cancelled before choosing data |
[email protected] | 8c94d63 | 2010-06-25 22:38:00 | [diff] [blame] | 122 | // types and clicking OK. |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 123 | // Events resulting in the stoppage of sync service. |
| 124 | STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. |
| 125 | |
| 126 | // Miscellaneous events caused by sync service. |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 127 | |
| 128 | MAX_SYNC_EVENT_CODE |
| 129 | }; |
| 130 | |
[email protected] | 689a7a7 | 2010-09-29 19:56:41 | [diff] [blame] | 131 | // Keep track of where we are when clearing server data. |
| 132 | enum ClearServerDataState { |
| 133 | CLEAR_NOT_STARTED = 1, |
| 134 | CLEAR_CLEARING = 2, |
| 135 | CLEAR_FAILED = 3, |
| 136 | CLEAR_SUCCEEDED = 4, |
| 137 | }; |
| 138 | |
[email protected] | f66bcdf | 2010-05-17 20:31:14 | [diff] [blame] | 139 | // Default sync server URL. |
| 140 | static const char* kSyncServerUrl; |
| 141 | // Sync server URL for dev channel users |
| 142 | static const char* kDevServerUrl; |
| 143 | |
[email protected] | e3e43d9 | 2010-02-26 22:02:38 | [diff] [blame] | 144 | ProfileSyncService(ProfileSyncFactory* factory_, |
| 145 | Profile* profile, |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 146 | const std::string& cros_user); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 147 | virtual ~ProfileSyncService(); |
| 148 | |
| 149 | // Initializes the object. This should be called every time an object of this |
| 150 | // class is constructed. |
| 151 | void Initialize(); |
| 152 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 153 | void RegisterAuthNotifications(); |
| 154 | |
| 155 | // Return whether all sync tokens are loaded and |
| 156 | // available for the backend to start up. |
| 157 | bool AreCredentialsAvailable(); |
| 158 | |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 159 | // Registers a data type controller with the sync service. This |
| 160 | // makes the data type controller available for use, it does not |
| 161 | // enable or activate the synchronization of the data type (see |
| 162 | // ActivateDataType). Takes ownership of the pointer. |
| 163 | void RegisterDataTypeController( |
| 164 | browser_sync::DataTypeController* data_type_controller); |
| 165 | |
[email protected] | 5edb922 | 2010-08-18 00:23:29 | [diff] [blame] | 166 | // Returns the session model associator associated with this type, but only if |
| 167 | // the associator is running. If it is doing anything else, it will return |
| 168 | // null. |
| 169 | browser_sync::SessionModelAssociator* GetSessionModelAssociator(); |
| 170 | |
[email protected] | 689a7a7 | 2010-09-29 19:56:41 | [diff] [blame] | 171 | // Maintain state of where we are in a server clear operation. |
| 172 | void ResetClearServerDataState(); |
| 173 | ClearServerDataState GetClearServerDataState(); |
| 174 | |
[email protected] | a7ab833 | 2010-03-31 20:49:04 | [diff] [blame] | 175 | // Fills state_map with a map of current data types that are possible to |
| 176 | // sync, as well as their states. |
| 177 | void GetDataTypeControllerStates( |
| 178 | browser_sync::DataTypeController::StateMap* state_map) const; |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 179 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 180 | // Disables sync for user. Use ShowLoginDialog to enable. |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 181 | virtual void DisableForUser(); |
| 182 | |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 183 | // Clears all Chromesync data from the server. |
| 184 | void ClearServerData(); |
| 185 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 186 | // Whether sync is enabled by user or not. |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 187 | virtual bool HasSyncSetupCompleted() const; |
[email protected] | 2efebbbf | 2010-10-25 10:31:21 | [diff] [blame] | 188 | virtual void SetSyncSetupCompleted(); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 189 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 190 | // SyncFrontend implementation. |
| 191 | virtual void OnBackendInitialized(); |
| 192 | virtual void OnSyncCycleCompleted(); |
| 193 | virtual void OnAuthError(); |
[email protected] | 7f8abea | 2010-07-14 01:31:36 | [diff] [blame] | 194 | virtual void OnStopSyncingPermanently(); |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 195 | virtual void OnClearServerDataFailed(); |
[email protected] | 990de36 | 2010-10-13 17:55:50 | [diff] [blame] | 196 | virtual void OnClearServerDataTimeout(); |
[email protected] | 1ce52aa | 2010-09-08 19:07:36 | [diff] [blame] | 197 | virtual void OnClearServerDataSucceeded(); |
[email protected] | 43c48fb9 | 2011-05-02 19:47:43 | [diff] [blame^] | 198 | virtual void OnPassphraseRequired(sync_api::PassphraseRequiredReason reason); |
[email protected] | 1a78769 | 2011-01-19 22:19:46 | [diff] [blame] | 199 | virtual void OnPassphraseAccepted(); |
[email protected] | 3fa964af | 2011-02-24 18:54:39 | [diff] [blame] | 200 | virtual void OnEncryptionComplete( |
| 201 | const syncable::ModelTypeSet& encrypted_types); |
[email protected] | dc55625 | 2011-04-20 01:59:35 | [diff] [blame] | 202 | virtual void OnMigrationNeededForTypes( |
| 203 | const syncable::ModelTypeSet& types); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 204 | |
| 205 | // Called when a user enters credentials through UI. |
| 206 | virtual void OnUserSubmittedAuth(const std::string& username, |
[email protected] | 1fc9b3f | 2009-11-12 21:22:09 | [diff] [blame] | 207 | const std::string& password, |
[email protected] | 96209ccd | 2010-10-11 21:57:27 | [diff] [blame] | 208 | const std::string& captcha, |
| 209 | const std::string& access_code); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 210 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 211 | // Update the last auth error and notify observers of error state. |
| 212 | void UpdateAuthErrorState(const GoogleServiceAuthError& error); |
| 213 | |
[email protected] | af90949 | 2010-06-10 18:45:38 | [diff] [blame] | 214 | // Called when a user chooses which data types to sync as part of the sync |
| 215 | // setup wizard. |sync_everything| represents whether they chose the |
[email protected] | 8c94d63 | 2010-06-25 22:38:00 | [diff] [blame] | 216 | // "keep everything synced" option; if true, |chosen_types| will be ignored |
| 217 | // and all data types will be synced. |sync_everything| means "sync all |
| 218 | // current and future data types." |
[email protected] | af90949 | 2010-06-10 18:45:38 | [diff] [blame] | 219 | virtual void OnUserChoseDatatypes(bool sync_everything, |
[email protected] | 8c94d63 | 2010-06-25 22:38:00 | [diff] [blame] | 220 | const syncable::ModelTypeSet& chosen_types); |
[email protected] | af90949 | 2010-06-10 18:45:38 | [diff] [blame] | 221 | |
[email protected] | a7ab833 | 2010-03-31 20:49:04 | [diff] [blame] | 222 | // Called when a user cancels any setup dialog (login, etc). |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 223 | virtual void OnUserCancelledDialog(); |
| 224 | |
| 225 | // Get various information for displaying in the user interface. |
| 226 | browser_sync::SyncBackendHost::StatusSummary QuerySyncStatusSummary(); |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 227 | virtual browser_sync::SyncBackendHost::Status QueryDetailedSyncStatus(); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 228 | |
[email protected] | 712257e | 2009-11-11 22:57:46 | [diff] [blame] | 229 | const GoogleServiceAuthError& GetAuthError() const { |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 230 | return last_auth_error_; |
| 231 | } |
| 232 | |
| 233 | // Displays a dialog for the user to enter GAIA credentials and attempt |
| 234 | // re-authentication, and returns true if it actually opened the dialog. |
| 235 | // Returns false if a dialog is already showing, an auth attempt is in |
| 236 | // progress, the sync system is already authenticated, or some error |
| 237 | // occurred preventing the action. We make it the duty of ProfileSyncService |
| 238 | // to open the dialog to easily ensure only one is ever showing. |
[email protected] | d688559 | 2010-10-11 19:38:24 | [diff] [blame] | 239 | virtual bool SetupInProgress() const; |
[email protected] | 44b78f90a | 2009-10-15 17:32:20 | [diff] [blame] | 240 | bool WizardIsVisible() const { |
| 241 | return wizard_.IsVisible(); |
| 242 | } |
[email protected] | d688559 | 2010-10-11 19:38:24 | [diff] [blame] | 243 | virtual void ShowLoginDialog(gfx::NativeWindow parent_window); |
[email protected] | a159596 | 2011-04-22 21:56:24 | [diff] [blame] | 244 | SyncSetupWizard& get_wizard() { return wizard_; } |
[email protected] | 1c73847 | 2011-01-19 21:48:01 | [diff] [blame] | 245 | |
| 246 | // This method handles clicks on "sync error" UI, showing the appropriate |
| 247 | // dialog for the error condition (relogin / enter passphrase). |
| 248 | virtual void ShowErrorUI(gfx::NativeWindow parent_window); |
| 249 | |
[email protected] | 5d0e7c2 | 2011-04-19 23:09:07 | [diff] [blame] | 250 | // Shows the configure screen of the Sync setup wizard. If |sync_everything| |
| 251 | // is true, shows the corresponding page in the customize screen; otherwise, |
| 252 | // displays the page that gives the user the ability to select which data |
| 253 | // types to sync. |
| 254 | void ShowConfigure(gfx::NativeWindow parent_window, bool sync_everything); |
| 255 | |
[email protected] | 22d3eff | 2011-01-08 01:45:18 | [diff] [blame] | 256 | void PromptForExistingPassphrase(gfx::NativeWindow parent_window); |
[email protected] | f0718a39 | 2011-01-21 23:52:56 | [diff] [blame] | 257 | void SigninForPassphraseMigration(gfx::NativeWindow parent_window); |
[email protected] | 8c94d63 | 2010-06-25 22:38:00 | [diff] [blame] | 258 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 259 | // Pretty-printed strings for a given StatusSummary. |
[email protected] | 06614687 | 2010-08-05 00:55:08 | [diff] [blame] | 260 | static std::string BuildSyncStatusSummaryText( |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 261 | const browser_sync::SyncBackendHost::StatusSummary& summary); |
| 262 | |
| 263 | // Returns true if the SyncBackendHost has told us it's ready to accept |
| 264 | // changes. |
[email protected] | cd2ec4b | 2011-01-06 00:09:36 | [diff] [blame] | 265 | // [REMARK] - it is safe to call this function only from the ui thread. |
| 266 | // because the variable is not thread safe and should only be accessed from |
| 267 | // single thread. If we want multiple threads to access this(and there is |
| 268 | // currently no need to do so) we need to protect this with a lock. |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 269 | // TODO(timsteele): What happens if the bookmark model is loaded, a change |
| 270 | // takes place, and the backend isn't initialized yet? |
| 271 | bool sync_initialized() const { return backend_initialized_; } |
[email protected] | ddb1e5a | 2010-12-13 20:10:45 | [diff] [blame] | 272 | virtual bool unrecoverable_error_detected() const; |
[email protected] | f6ec8b2 | 2010-06-08 23:40:06 | [diff] [blame] | 273 | const std::string& unrecoverable_error_message() { |
| 274 | return unrecoverable_error_message_; |
| 275 | } |
| 276 | tracked_objects::Location unrecoverable_error_location() { |
| 277 | return unrecoverable_error_location_.get() ? |
| 278 | *unrecoverable_error_location_.get() : tracked_objects::Location(); |
| 279 | } |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 280 | |
| 281 | bool UIShouldDepictAuthInProgress() const { |
| 282 | return is_auth_in_progress_; |
| 283 | } |
| 284 | |
[email protected] | 43c48fb9 | 2011-05-02 19:47:43 | [diff] [blame^] | 285 | // Returns true if OnPassphraseRequired has been called for any reason. |
| 286 | bool ObservedPassphraseRequired() const { |
| 287 | return passphrase_required_reason_ != |
| 288 | sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
[email protected] | 66d8100 | 2010-10-18 16:52:09 | [diff] [blame] | 289 | } |
| 290 | |
[email protected] | 43c48fb9 | 2011-05-02 19:47:43 | [diff] [blame^] | 291 | sync_api::PassphraseRequiredReason passphrase_required_reason() const { |
| 292 | return passphrase_required_reason_; |
[email protected] | fc52c42 | 2010-11-19 18:59:23 | [diff] [blame] | 293 | } |
| 294 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 295 | // Returns a user-friendly string form of last synced time (in minutes). |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 296 | virtual string16 GetLastSyncedTimeString() const; |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 297 | |
| 298 | // Returns the authenticated username of the sync user, or empty if none |
| 299 | // exists. It will only exist if the authentication service provider (e.g |
| 300 | // GAIA) has confirmed the username is authentic. |
| 301 | virtual string16 GetAuthenticatedUsername() const; |
| 302 | |
| 303 | const std::string& last_attempted_user_email() const { |
| 304 | return last_attempted_user_email_; |
| 305 | } |
| 306 | |
| 307 | // The profile we are syncing for. |
[email protected] | c976938f | 2010-10-12 04:55:44 | [diff] [blame] | 308 | Profile* profile() const { return profile_; } |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 309 | |
| 310 | // Adds/removes an observer. ProfileSyncService does not take ownership of |
| 311 | // the observer. |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 312 | virtual void AddObserver(Observer* observer); |
| 313 | virtual void RemoveObserver(Observer* observer); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 314 | |
[email protected] | d1db1c33 | 2010-10-13 19:57:00 | [diff] [blame] | 315 | // Returns true if |observer| has already been added as an observer. |
| 316 | bool HasObserver(Observer* observer) const; |
| 317 | |
[email protected] | f92351d | 2011-02-01 07:42:12 | [diff] [blame] | 318 | // Returns a pointer to the service's JsFrontend (which is owned by |
| 319 | // the service). Never returns NULL. Overrideable for testing |
| 320 | // purposes. |
| 321 | virtual browser_sync::JsFrontend* GetJsFrontend(); |
| 322 | |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 323 | // Record stats on various events. |
| 324 | static void SyncEvent(SyncEventCodes code); |
| 325 | |
[email protected] | eec3bcfa | 2009-11-12 17:23:43 | [diff] [blame] | 326 | // Returns whether sync is enabled. Sync can be enabled/disabled both |
| 327 | // at compile time (e.g., on a per-OS basis) or at run time (e.g., |
| 328 | // command-line switches). |
| 329 | static bool IsSyncEnabled(); |
| 330 | |
[email protected] | d1db1c33 | 2010-10-13 19:57:00 | [diff] [blame] | 331 | // Returns whether sync is managed, i.e. controlled by configuration |
[email protected] | d3b98c8 | 2010-07-14 07:45:59 | [diff] [blame] | 332 | // management. If so, the user is not allowed to configure sync. |
| 333 | bool IsManaged(); |
| 334 | |
[email protected] | db1df0f | 2009-08-18 22:36:05 | [diff] [blame] | 335 | // UnrecoverableErrorHandler implementation. |
[email protected] | f6ec8b2 | 2010-06-08 23:40:06 | [diff] [blame] | 336 | virtual void OnUnrecoverableError( |
| 337 | const tracked_objects::Location& from_here, |
| 338 | const std::string& message); |
[email protected] | db1df0f | 2009-08-18 22:36:05 | [diff] [blame] | 339 | |
[email protected] | 42091493 | 2011-01-24 23:32:41 | [diff] [blame] | 340 | // The functions below (until ActivateDataType()) should only be |
| 341 | // called if sync_initialized() is true. |
| 342 | |
| 343 | // TODO(akalin): This is called mostly by ModelAssociators and |
| 344 | // tests. Figure out how to pass the handle to the ModelAssociators |
| 345 | // directly, figure out how to expose this to tests, and remove this |
| 346 | // function. |
| 347 | sync_api::UserShare* GetUserShare() const; |
| 348 | |
| 349 | // TODO(akalin): These two functions are used only by |
| 350 | // ProfileSyncServiceHarness. Figure out a different way to expose |
| 351 | // this info to that class, and remove these functions. |
| 352 | |
[email protected] | dc55625 | 2011-04-20 01:59:35 | [diff] [blame] | 353 | virtual const browser_sync::sessions::SyncSessionSnapshot* |
[email protected] | 42091493 | 2011-01-24 23:32:41 | [diff] [blame] | 354 | GetLastSessionSnapshot() const; |
| 355 | |
| 356 | // Returns whether or not the underlying sync engine has made any |
| 357 | // local changes to items that have not yet been synced with the |
| 358 | // server. |
| 359 | bool HasUnsyncedItems() const; |
| 360 | |
[email protected] | 51c84ee | 2011-04-26 22:07:59 | [diff] [blame] | 361 | // Returns whether or not the sync service is reconfiguring due |
| 362 | // to server-initiated resynchronization. |
| 363 | bool HasPendingBackendMigration() const; |
| 364 | |
[email protected] | 42091493 | 2011-01-24 23:32:41 | [diff] [blame] | 365 | // Get the current routing information for all enabled model types. |
| 366 | // If a model type is not enabled (that is, if the syncer should not |
| 367 | // be trying to sync it), it is not in this map. |
| 368 | // |
| 369 | // TODO(akalin): This function is used by |
| 370 | // sync_ui_util::ConstructAboutInformation() and by some test |
| 371 | // classes. Figure out a different way to expose this info and |
| 372 | // remove this function. |
| 373 | void GetModelSafeRoutingInfo(browser_sync::ModelSafeRoutingInfo* out); |
| 374 | |
| 375 | // TODO(akalin): Remove these four functions once we're done with |
| 376 | // autofill migration. |
| 377 | |
| 378 | syncable::AutofillMigrationState |
| 379 | GetAutofillMigrationState(); |
| 380 | |
| 381 | void SetAutofillMigrationState( |
| 382 | syncable::AutofillMigrationState state); |
| 383 | |
| 384 | syncable::AutofillMigrationDebugInfo |
| 385 | GetAutofillMigrationDebugInfo(); |
| 386 | |
| 387 | void SetAutofillMigrationDebugInfo( |
| 388 | syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| 389 | const syncable::AutofillMigrationDebugInfo& info); |
[email protected] | db1df0f | 2009-08-18 22:36:05 | [diff] [blame] | 390 | |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 391 | virtual void ActivateDataType( |
| 392 | browser_sync::DataTypeController* data_type_controller, |
| 393 | browser_sync::ChangeProcessor* change_processor); |
| 394 | virtual void DeactivateDataType( |
| 395 | browser_sync::DataTypeController* data_type_controller, |
| 396 | browser_sync::ChangeProcessor* change_processor); |
| 397 | |
[email protected] | c4c672a | 2010-03-23 21:47:04 | [diff] [blame] | 398 | // NotificationObserver implementation. |
| 399 | virtual void Observe(NotificationType type, |
| 400 | const NotificationSource& source, |
| 401 | const NotificationDetails& details); |
| 402 | |
[email protected] | a1c2aef6 | 2010-04-02 02:58:05 | [diff] [blame] | 403 | // Changes which data types we're going to be syncing to |preferred_types|. |
| 404 | // If it is running, the DataTypeManager will be instructed to reconfigure |
| 405 | // the sync backend so that exactly these datatypes are actively synced. See |
| 406 | // class comment for more on what it means for a datatype to be Preferred. |
| 407 | virtual void ChangePreferredDataTypes( |
| 408 | const syncable::ModelTypeSet& preferred_types); |
| 409 | |
| 410 | // Get the set of currently enabled data types (as chosen or configured by |
| 411 | // the user). See class comment for more on what it means for a datatype |
| 412 | // to be Preferred. |
| 413 | virtual void GetPreferredDataTypes( |
| 414 | syncable::ModelTypeSet* preferred_types) const; |
| 415 | |
| 416 | // Gets the set of all data types that could be allowed (the set that |
| 417 | // should be advertised to the user). These will typically only change |
| 418 | // via a command-line option. See class comment for more on what it means |
| 419 | // for a datatype to be Registered. |
| 420 | virtual void GetRegisteredDataTypes( |
| 421 | syncable::ModelTypeSet* registered_types) const; |
[email protected] | a7ab833 | 2010-03-31 20:49:04 | [diff] [blame] | 422 | |
[email protected] | ff0aa75 | 2010-06-10 22:40:52 | [diff] [blame] | 423 | // Checks whether the Cryptographer is ready to encrypt and decrypt updates |
[email protected] | 47f6a36 | 2011-03-29 19:57:11 | [diff] [blame] | 424 | // for sensitive data types. Caller must be holding a |
| 425 | // syncapi::BaseTransaction to ensure thread safety. |
| 426 | virtual bool IsCryptographerReady( |
| 427 | const sync_api::BaseTransaction* trans) const; |
[email protected] | ff0aa75 | 2010-06-10 22:40:52 | [diff] [blame] | 428 | |
[email protected] | c976938f | 2010-10-12 04:55:44 | [diff] [blame] | 429 | // Returns true if a secondary passphrase is being used. |
| 430 | virtual bool IsUsingSecondaryPassphrase() const; |
| 431 | |
[email protected] | ee1adf4b | 2010-10-11 03:48:48 | [diff] [blame] | 432 | // Sets the Cryptographer's passphrase, or caches it until that is possible. |
| 433 | // This will check asynchronously whether the passphrase is valid and notify |
[email protected] | dc39dd1b | 2010-10-07 18:08:11 | [diff] [blame] | 434 | // ProfileSyncServiceObservers via the NotificationService when the outcome |
| 435 | // is known. |
[email protected] | 954b108 | 2010-11-10 20:22:50 | [diff] [blame] | 436 | // |is_explicit| is true if the call is in response to the user explicitly |
| 437 | // setting a passphrase as opposed to implicitly (from the users' perspective) |
| 438 | // using their Google Account password. An implicit SetPassphrase will *not* |
| 439 | // *not* override an explicit passphrase set previously. |
[email protected] | 2e610e9 | 2011-01-13 23:39:45 | [diff] [blame] | 440 | // |is_creation| is true if the call is in response to the user setting |
| 441 | // up a new passphrase, and false if it's being set in response to a prompt |
| 442 | // for an existing passphrase. |
| 443 | virtual void SetPassphrase(const std::string& passphrase, |
| 444 | bool is_explicit, |
| 445 | bool is_creation); |
[email protected] | bb899b3f | 2010-06-23 21:35:32 | [diff] [blame] | 446 | |
[email protected] | 3fa964af | 2011-02-24 18:54:39 | [diff] [blame] | 447 | // Changes the set of datatypes that require encryption. This affects all |
| 448 | // machines synced to this account and all data belonging to the specified |
| 449 | // types. |
| 450 | // Note that this is an asynchronous operation (the encryption of data is |
| 451 | // performed on SyncBackendHost's core thread) and may not have an immediate |
| 452 | // effect. |
| 453 | virtual void EncryptDataTypes( |
| 454 | const syncable::ModelTypeSet& encrypted_types); |
| 455 | |
| 456 | // Get the currently encrypted data types. |
| 457 | virtual void GetEncryptedDataTypes( |
| 458 | syncable::ModelTypeSet* encrypted_types) const; |
| 459 | |
[email protected] | 5edb922 | 2010-08-18 00:23:29 | [diff] [blame] | 460 | // Returns whether processing changes is allowed. Check this before doing |
| 461 | // any model-modifying operations. |
| 462 | bool ShouldPushChanges(); |
| 463 | |
[email protected] | 9a127f2 | 2010-09-17 21:05:16 | [diff] [blame] | 464 | const GURL& sync_service_url() const { return sync_service_url_; } |
[email protected] | bb868b4 | 2010-11-18 22:33:00 | [diff] [blame] | 465 | SigninManager* signin() { return signin_.get(); } |
| 466 | const std::string& cros_user() const { return cros_user_; } |
[email protected] | 9a127f2 | 2010-09-17 21:05:16 | [diff] [blame] | 467 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 468 | protected: |
[email protected] | 42091493 | 2011-01-24 23:32:41 | [diff] [blame] | 469 | // Used by test classes that derive from ProfileSyncService. |
| 470 | virtual browser_sync::SyncBackendHost* GetBackendForTest(); |
| 471 | |
[email protected] | 7cef1c44 | 2010-07-07 17:05:22 | [diff] [blame] | 472 | // Helper to install and configure a data type manager. |
| 473 | void ConfigureDataTypeManager(); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 474 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 475 | // Starts up the backend sync components. |
| 476 | void StartUp(); |
| 477 | // Shuts down the backend sync components. |
| 478 | // |sync_disabled| indicates if syncing is being disabled or not. |
| 479 | void Shutdown(bool sync_disabled); |
| 480 | |
[email protected] | 48352c1 | 2009-08-15 01:19:11 | [diff] [blame] | 481 | // Methods to register and remove preferences. |
| 482 | void RegisterPreferences(); |
| 483 | void ClearPreferences(); |
| 484 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 485 | // Return SyncCredentials from the TokenService. |
| 486 | sync_api::SyncCredentials GetCredentials(); |
| 487 | |
[email protected] | 18af9a2 | 2010-08-11 00:47:19 | [diff] [blame] | 488 | // Test need to override this to create backends that allow setting up |
| 489 | // initial conditions, such as populating sync nodes. |
[email protected] | 42091493 | 2011-01-24 23:32:41 | [diff] [blame] | 490 | // |
| 491 | // TODO(akalin): Figure out a better way to do this. Ideally, we'd |
| 492 | // construct the backend outside this class and pass it in to the |
| 493 | // contructor or Initialize(). |
[email protected] | 18af9a2 | 2010-08-11 00:47:19 | [diff] [blame] | 494 | virtual void CreateBackend(); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 495 | |
[email protected] | 7cef1c44 | 2010-07-07 17:05:22 | [diff] [blame] | 496 | const browser_sync::DataTypeController::TypeMap& data_type_controllers() { |
| 497 | return data_type_controllers_; |
| 498 | } |
| 499 | |
[email protected] | 4b2866b | 2011-01-26 18:58:44 | [diff] [blame] | 500 | // Helper method for managing encryption UI. |
| 501 | bool IsEncryptedDatatypeEnabled() const; |
| 502 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 503 | // The wizard will try to read the auth state out of the profile sync |
| 504 | // service using this member. Captcha and error state are reflected. |
[email protected] | 712257e | 2009-11-11 22:57:46 | [diff] [blame] | 505 | GoogleServiceAuthError last_auth_error_; |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 506 | |
[email protected] | 7cef1c44 | 2010-07-07 17:05:22 | [diff] [blame] | 507 | // Our asynchronous backend to communicate with sync components living on |
| 508 | // other threads. |
| 509 | scoped_ptr<browser_sync::SyncBackendHost> backend_; |
| 510 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 511 | // Cache of the last name the client attempted to authenticate. |
| 512 | std::string last_attempted_user_email_; |
| 513 | |
[email protected] | fc52c42 | 2010-11-19 18:59:23 | [diff] [blame] | 514 | // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it |
[email protected] | 43c48fb9 | 2011-05-02 19:47:43 | [diff] [blame^] | 515 | // was required for encryption, decryption with a cached passphrase, or |
| 516 | // because a new passphrase is required? |
| 517 | sync_api::PassphraseRequiredReason passphrase_required_reason_; |
[email protected] | fc52c42 | 2010-11-19 18:59:23 | [diff] [blame] | 518 | |
[email protected] | f0718a39 | 2011-01-21 23:52:56 | [diff] [blame] | 519 | // Is the user in a passphrase migration? |
| 520 | bool passphrase_migration_in_progress_; |
| 521 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 522 | private: |
[email protected] | 4f5732a4 | 2010-09-21 22:39:09 | [diff] [blame] | 523 | friend class ProfileSyncServicePasswordTest; |
[email protected] | 42091493 | 2011-01-24 23:32:41 | [diff] [blame] | 524 | friend class TestProfileSyncService; |
[email protected] | 61b694a | 2010-06-10 10:40:46 | [diff] [blame] | 525 | FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 526 | |
[email protected] | 18af9a2 | 2010-08-11 00:47:19 | [diff] [blame] | 527 | // If |delete_sync_data_folder| is true, then this method will delete all |
| 528 | // previous "Sync Data" folders. (useful if the folder is partial/corrupt). |
| 529 | void InitializeBackend(bool delete_sync_data_folder); |
| 530 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 531 | // Initializes the various settings from the command line. |
| 532 | void InitSettings(); |
| 533 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 534 | // Sets the last synced time to the current time. |
| 535 | void UpdateLastSyncedTime(); |
| 536 | |
[email protected] | 1a78769 | 2011-01-19 22:19:46 | [diff] [blame] | 537 | void NotifyObservers(); |
| 538 | |
[email protected] | 57ecc4b | 2010-08-11 03:02:51 | [diff] [blame] | 539 | static const char* GetPrefNameForDataType(syncable::ModelType data_type); |
[email protected] | a1c2aef6 | 2010-04-02 02:58:05 | [diff] [blame] | 540 | |
[email protected] | cb4c06e | 2009-08-22 00:24:39 | [diff] [blame] | 541 | // Time at which we begin an attempt a GAIA authorization. |
| 542 | base::TimeTicks auth_start_time_; |
| 543 | |
| 544 | // Time at which error UI is presented for the new tab page. |
[email protected] | 1f97a11 | 2009-08-11 02:17:06 | [diff] [blame] | 545 | base::TimeTicks auth_error_time_; |
| 546 | |
[email protected] | e3e43d9 | 2010-02-26 22:02:38 | [diff] [blame] | 547 | // Factory used to create various dependent objects. |
| 548 | ProfileSyncFactory* factory_; |
| 549 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 550 | // The profile whose data we are synchronizing. |
| 551 | Profile* profile_; |
| 552 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 553 | // Email for the ChromiumOS user, if we're running under ChromiumOS. |
| 554 | std::string cros_user_; |
[email protected] | 72a31b4 | 2010-02-17 22:26:33 | [diff] [blame] | 555 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 556 | // TODO(ncarter): Put this in a profile, once there is UI for it. |
| 557 | // This specifies where to find the sync server. |
| 558 | GURL sync_service_url_; |
| 559 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 560 | // The last time we detected a successful transition from SYNCING state. |
| 561 | // Our backend notifies us whenever we should take a new snapshot. |
| 562 | base::Time last_synced_time_; |
| 563 | |
[email protected] | 4aea04a | 2010-02-10 20:13:43 | [diff] [blame] | 564 | // List of available data type controllers. |
[email protected] | 72a31b4 | 2010-02-17 22:26:33 | [diff] [blame] | 565 | browser_sync::DataTypeController::TypeMap data_type_controllers_; |
[email protected] | db1df0f | 2009-08-18 22:36:05 | [diff] [blame] | 566 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 567 | // Whether the SyncBackendHost has been initialized. |
| 568 | bool backend_initialized_; |
| 569 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 570 | // Various pieces of UI query this value to determine if they should show |
| 571 | // an "Authenticating.." type of message. We are the only central place |
| 572 | // all auth attempts funnel through, so it makes sense to provide this. |
| 573 | // As its name suggests, this should NOT be used for anything other than UI. |
| 574 | bool is_auth_in_progress_; |
| 575 | |
[email protected] | 44b78f90a | 2009-10-15 17:32:20 | [diff] [blame] | 576 | SyncSetupWizard wizard_; |
| 577 | |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 578 | // Encapsulates user signin with TokenService. |
[email protected] | bb868b4 | 2010-11-18 22:33:00 | [diff] [blame] | 579 | scoped_ptr<SigninManager> signin_; |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 580 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 581 | // True if an unrecoverable error (e.g. violation of an assumed invariant) |
| 582 | // occurred during syncer operation. This value should be checked before |
| 583 | // doing any work that might corrupt things further. |
| 584 | bool unrecoverable_error_detected_; |
| 585 | |
[email protected] | f6ec8b2 | 2010-06-08 23:40:06 | [diff] [blame] | 586 | // A message sent when an unrecoverable error occurred. |
| 587 | std::string unrecoverable_error_message_; |
| 588 | scoped_ptr<tracked_objects::Location> unrecoverable_error_location_; |
| 589 | |
[email protected] | e3e43d9 | 2010-02-26 22:02:38 | [diff] [blame] | 590 | // Manages the start and stop of the various data types. |
| 591 | scoped_ptr<browser_sync::DataTypeManager> data_type_manager_; |
| 592 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 593 | ObserverList<Observer> observers_; |
| 594 | |
[email protected] | f92351d | 2011-02-01 07:42:12 | [diff] [blame] | 595 | browser_sync::JsEventHandlerList js_event_handlers_; |
| 596 | |
[email protected] | c4c672a | 2010-03-23 21:47:04 | [diff] [blame] | 597 | NotificationRegistrar registrar_; |
| 598 | |
[email protected] | 2be7bf2 | 2010-04-23 21:02:37 | [diff] [blame] | 599 | ScopedRunnableMethodFactory<ProfileSyncService> |
[email protected] | 954b108 | 2010-11-10 20:22:50 | [diff] [blame] | 600 | scoped_runnable_method_factory_; |
[email protected] | 2be7bf2 | 2010-04-23 21:02:37 | [diff] [blame] | 601 | |
[email protected] | d3b98c8 | 2010-07-14 07:45:59 | [diff] [blame] | 602 | // The preference that controls whether sync is under control by configuration |
| 603 | // management. |
| 604 | BooleanPrefMember pref_sync_managed_; |
| 605 | |
[email protected] | a47eeb5 | 2010-07-15 17:54:25 | [diff] [blame] | 606 | // This allows us to gracefully handle an ABORTED return code from the |
| 607 | // DataTypeManager in the event that the server informed us to cease and |
| 608 | // desist syncing immediately. |
| 609 | bool expect_sync_configuration_aborted_; |
| 610 | |
[email protected] | 48a98b3 | 2010-09-17 20:26:59 | [diff] [blame] | 611 | // Sometimes we need to temporarily hold on to a passphrase because we don't |
| 612 | // yet have a backend to send it to. This happens during initialization as |
| 613 | // we don't StartUp until we have a valid token, which happens after valid |
| 614 | // credentials were provided. |
[email protected] | 954b108 | 2010-11-10 20:22:50 | [diff] [blame] | 615 | struct CachedPassphrase { |
| 616 | std::string value; |
| 617 | bool is_explicit; |
[email protected] | 2e610e9 | 2011-01-13 23:39:45 | [diff] [blame] | 618 | bool is_creation; |
| 619 | CachedPassphrase() : is_explicit(false), is_creation(false) {} |
[email protected] | 954b108 | 2010-11-10 20:22:50 | [diff] [blame] | 620 | }; |
| 621 | CachedPassphrase cached_passphrase_; |
| 622 | |
| 623 | // TODO(tim): Remove this once new 'explicit passphrase' code flushes through |
| 624 | // dev channel. See bug 62103. |
| 625 | // To "migrate" early adopters of password sync on dev channel to the new |
| 626 | // model that stores their secondary passphrase preference in the cloud, we |
| 627 | // need some extra state since this cloud pref will be empty for all of them |
| 628 | // regardless of how they set up sync, and we can't trust |
| 629 | // kSyncUsingSecondaryPassphrase due to bugs in that implementation. |
| 630 | bool tried_implicit_gaia_remove_when_bug_62103_fixed_; |
[email protected] | 48a98b3 | 2010-09-17 20:26:59 | [diff] [blame] | 631 | |
[email protected] | 689a7a7 | 2010-09-29 19:56:41 | [diff] [blame] | 632 | // Keep track of where we are in a server clear operation |
| 633 | ClearServerDataState clear_server_data_state_; |
| 634 | |
[email protected] | 990de36 | 2010-10-13 17:55:50 | [diff] [blame] | 635 | // Timeout for the clear data command. This timeout is a temporary hack |
[email protected] | 954b108 | 2010-11-10 20:22:50 | [diff] [blame] | 636 | // and is necessary because the nudge sync framework can drop nudges for |
[email protected] | 990de36 | 2010-10-13 17:55:50 | [diff] [blame] | 637 | // a wide variety of sync-related conditions (throttling, connections issues, |
| 638 | // syncer paused, etc.). It can only be removed correctly when the framework |
| 639 | // is reworked to allow one-shot commands like clearing server data. |
| 640 | base::OneShotTimer<ProfileSyncService> clear_server_data_timer_; |
| 641 | |
[email protected] | 3fa964af | 2011-02-24 18:54:39 | [diff] [blame] | 642 | // The set of encrypted types. This is updated whenever datatypes are |
| 643 | // encrypted through the OnEncryptionComplete callback of SyncFrontend. |
| 644 | syncable::ModelTypeSet encrypted_types_; |
| 645 | |
[email protected] | dc55625 | 2011-04-20 01:59:35 | [diff] [blame] | 646 | scoped_ptr<browser_sync::BackendMigrator> migrator_; |
| 647 | |
[email protected] | 132c8565 | 2009-08-05 01:18:27 | [diff] [blame] | 648 | DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 649 | }; |
| 650 | |
| 651 | #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |