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