15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 86e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include <set> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <utility> 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/gtest_prod_util.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/location.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 17a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/memory/scoped_vector.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/observer_list.h" 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 21eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h" 22eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/timer/timer.h" 2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "chrome/browser/browsing_data/browsing_data_remover.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/sync/backend_unrecoverable_error_handler.h" 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/sync/backup_rollback_controller.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/sync/glue/sync_backend_host.h" 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/sync/profile_sync_service_base.h" 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/sync/profile_sync_service_observer.h" 29effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/browser/sync/protocol_event_observer.h" 300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "chrome/browser/sync/sessions/sessions_sync_manager.h" 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/sync/startup_controller.h" 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/core/keyed_service.h" 33effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "components/signin/core/browser/signin_manager_base.h" 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/sync_driver/data_type_controller.h" 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/sync_driver/data_type_encryption_handler.h" 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/sync_driver/data_type_manager.h" 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/sync_driver/data_type_manager_observer.h" 381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/sync_driver/data_type_status_table.h" 391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/sync_driver/device_info_sync_service.h" 401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/sync_driver/local_device_info_provider.h" 415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "components/sync_driver/non_blocking_data_type_manager.h" 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/sync_driver/sync_frontend.h" 4323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "components/sync_driver/sync_prefs.h" 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "google_apis/gaia/google_service_auth_error.h" 45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "google_apis/gaia/oauth2_token_service.h" 467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "net/base/backoff_entry.h" 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/internal_api/public/base/model_type.h" 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/internal_api/public/engine/model_safe_worker.h" 495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "sync/internal_api/public/shutdown_reason.h" 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/internal_api/public/sync_manager_factory.h" 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/internal_api/public/util/experiments.h" 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/internal_api/public/util/unrecoverable_error_handler.h" 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/js/sync_js_controller.h" 54eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h" 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile; 57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class ProfileOAuth2TokenService; 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ProfileSyncComponentsFactory; 59116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass SupervisedUserSigninManagerWrapper; 60effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass SyncErrorController; 616e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class SyncTypePreferenceProvider; 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 63f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)namespace base { 64f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)class CommandLine; 65f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)}; 66f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace browser_sync { 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BackendMigrator; 69f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class FaviconCache; 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class JsController; 71f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class OpenTabsUIDelegate; 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)namespace sessions { 7468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)class SyncSessionSnapshot; 7568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)} // namespace sessions 7668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)} // namespace browser_sync 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 785f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace sync_driver { 795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class ChangeProcessor; 805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class DataTypeManager; 811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass DeviceInfoSyncService; 821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass LocalDeviceInfoProvider; 835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)} // namespace sync_driver 845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace syncer { 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BaseTransaction; 87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class NetworkResources; 88010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)struct CommitCounters; 89010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)struct StatusCounters; 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct SyncCredentials; 91010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)struct UpdateCounters; 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct UserShare; 9368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)} // namespace syncer 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace sync_pb { 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class EncryptedData; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace sync_pb 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ProfileSyncService is the layer between browser subsystems like bookmarks, 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and the sync backend. Each subsystem is logically thought of as being 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a sync datatype. 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Individual datatypes can, at any point, be in a variety of stages of being 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// "enabled". Here are some specific terms for concepts used in this class: 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 'Registered' (feature suppression for a datatype) 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When a datatype is registered, the user has the option of syncing it. 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The sync opt-in UI will show only registered types; a checkbox should 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// never be shown for an unregistered type, and nor should it ever be 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// synced. 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A datatype is considered registered once RegisterDataTypeController 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// has been called with that datatype's DataTypeController. 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 'Preferred' (user preferences and opt-out for a datatype) 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This means the user's opt-in or opt-out preference on a per-datatype 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// basis. The sync service will try to make active exactly these types. 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If a user has opted out of syncing a particular datatype, it will 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// be registered, but not preferred. 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This state is controlled by the ConfigurePreferredDataTypes and 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// GetPreferredDataTypes. They are stored in the preferences system, 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and persist; though if a datatype is not registered, it cannot 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// be a preferred datatype. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 'Active' (run-time initialization of sync system for a datatype) 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// An active datatype is a preferred datatype that is actively being 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// synchronized: the syncer has been instructed to querying the server 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// for this datatype, first-time merges have finished, and there is an 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// actively installed ChangeProcessor that listens for changes to this 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// datatype, propagating such changes into and out of the sync backend 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// as necessary. 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When a datatype is in the process of becoming active, it may be 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// in some intermediate state. Those finer-grained intermediate states 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// are differentiated by the DataTypeController state. 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sync Configuration: 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sync configuration is accomplished via the following APIs: 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * OnUserChoseDatatypes(): Set the data types the user wants to sync. 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * SetDecryptionPassphrase(): Attempt to decrypt the user's encrypted data 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// using the passed passphrase. 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * SetEncryptionPassphrase(): Re-encrypt the user's data using the passed 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// passphrase. 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Additionally, the current sync configuration can be fetched by calling 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * GetRegisteredDataTypes() 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * GetPreferredDataTypes() 153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// * GetActiveDataTypes() 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * IsUsingSecondaryPassphrase() 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * EncryptEverythingEnabled() 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * IsPassphraseRequired()/IsPassphraseRequiredForDecryption() 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The "sync everything" state cannot be read from ProfileSyncService, but 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is instead pulled from SyncPrefs.HasKeepEverythingSynced(). 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Initial sync setup: 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// For privacy reasons, it is usually desirable to avoid syncing any data 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// types until the user has finished setting up sync. There are two APIs 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// that control the initial sync download: 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * SetSyncSetupCompleted() 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * SetSetupInProgress() 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SetSyncSetupCompleted() should be called once the user has finished setting 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// up sync at least once on their account. SetSetupInProgress(true) should be 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// called while the user is actively configuring their account, and then 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SetSetupInProgress(false) should be called when configuration is complete. 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// been called, then the sync engine knows not to download any user data. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When initial sync is complete, the UI code should call 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// tell the sync engine that setup is completed and it can begin downloading 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// data from the sync server. 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 182a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class ProfileSyncService : public ProfileSyncServiceBase, 1835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public sync_driver::SyncFrontend, 18423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) public sync_driver::SyncPrefObserver, 1855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public sync_driver::DataTypeManagerObserver, 186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public syncer::UnrecoverableErrorHandler, 187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public KeyedService, 1885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public sync_driver::DataTypeEncryptionHandler, 189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public OAuth2TokenService::Consumer, 190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public OAuth2TokenService::Observer, 191effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch public SigninManagerBase::Observer { 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef browser_sync::SyncBackendHost::Status Status; 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 195f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Status of sync server connection, sync token and token request. 196f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) struct SyncTokenStatus { 197f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) SyncTokenStatus(); 198f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ~SyncTokenStatus(); 199f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 200f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Sync server connection status reported by sync backend. 201f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time connection_status_update_time; 202f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) syncer::ConnectionStatus connection_status; 203f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 204f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Times when OAuth2 access token is requested and received. 205f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time token_request_time; 206f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time token_receive_time; 207f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 208f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Error returned by OAuth2TokenService for token request and time when 209f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // next request is scheduled. 210f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) GoogleServiceAuthError last_get_token_error; 211f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time next_token_request_time; 212f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) }; 213f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum SyncEventCodes { 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MIN_SYNC_EVENT_CODE = 0, 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Events starting the sync service. 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) START_FROM_NTP = 1, // Sync was started from the ad in NTP 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) START_FROM_WRENCH = 2, // Sync was started from the Wrench menu. 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options. 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager. 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) START_FROM_PROFILE_MENU = 5, // Sync was started from multiprofile menu. 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) START_FROM_URL = 6, // Sync was started from a typed URL. 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Events regarding cancellation of the signon process of sync. 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CANCEL_FROM_SIGNON_WITHOUT_AUTH = 10, // Cancelled before submitting 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // username and password. 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CANCEL_DURING_SIGNON = 11, // Cancelled after auth. 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CANCEL_DURING_CONFIGURE = 12, // Cancelled before choosing data 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // types and clicking OK. 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Events resulting in the stoppage of sync service. 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. 23390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) STOP_FROM_ADVANCED_DIALOG = 21, // Sync was stopped via advanced settings. 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Miscellaneous events caused by sync service. 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MAX_SYNC_EVENT_CODE 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used to specify the kind of passphrase with which sync data is encrypted. 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum PassphraseType { 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IMPLICIT, // The user did not provide a custom passphrase for encryption. 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We implicitly use the GAIA password in such cases. 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPLICIT, // The user selected the "use custom passphrase" radio button 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // during sync setup and provided a passphrase. 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 248d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) enum SyncStatusSummary { 249d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) UNRECOVERABLE_ERROR, 250d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) NOT_ENABLED, 251d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) SETUP_INCOMPLETE, 252d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) DATATYPES_NOT_INITIALIZED, 253d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) INITIALIZED, 254cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) BACKUP_USER_DATA, 255cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) ROLLBACK_USER_DATA, 256d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) UNKNOWN_ERROR, 257d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) }; 258d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 259cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) enum BackendMode { 260cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) IDLE, // No backend. 261cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) SYNC, // Backend for syncing. 262cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) BACKUP, // Backend for backup. 263cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) ROLLBACK // Backend for rollback. 264cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) }; 265cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Default sync server URL. 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const char* kSyncServerUrl; 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sync server URL for dev channel users 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const char* kDevServerUrl; 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Takes ownership of |factory| and |signin_wrapper|. 272a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ProfileSyncService( 2735f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) scoped_ptr<ProfileSyncComponentsFactory> factory, 274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Profile* profile, 275116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, 276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ProfileOAuth2TokenService* oauth2_token_service, 277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) browser_sync::ProfileSyncServiceStartBehavior start_behavior); 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~ProfileSyncService(); 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initializes the object. This must be called at most once, and 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // immediately after an object of this class is constructed. 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Initialize(); 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetSyncSetupCompleted(); 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ProfileSyncServiceBase implementation. 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool HasSyncSetupCompleted() const OVERRIDE; 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool ShouldPushChanges() OVERRIDE; 289868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual syncer::ModelTypeSet GetActiveDataTypes() const OVERRIDE; 290ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void AddObserver(ProfileSyncServiceBase::Observer* observer) OVERRIDE; 291ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void RemoveObserver( 292ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ProfileSyncServiceBase::Observer* observer) OVERRIDE; 293ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual bool HasObserver( 294ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ProfileSyncServiceBase::Observer* observer) const OVERRIDE; 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 296effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 297effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); 298effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch void RemoveProtocolEventObserver( 299effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch browser_sync::ProtocolEventObserver* observer); 300effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 301010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); 302010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void RemoveTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); 303010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 3046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Add a sync type preference provider. Each provider may only be added once. 3056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void AddPreferenceProvider(SyncTypePreferenceProvider* provider); 3066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Remove a sync type preference provider. May only be called for providers 3076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // that have been added. Providers must not remove themselves while being 3086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // called back. 3096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void RemovePreferenceProvider(SyncTypePreferenceProvider* provider); 3106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Check whether a given sync type preference provider has been added. 3116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool HasPreferenceProvider(SyncTypePreferenceProvider* provider) const; 3126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 313c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Asynchronously fetches base::Value representations of all sync nodes and 314c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // returns them to the specified callback on this thread. 315c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // 316c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // These requests can live a long time and return when you least expect it. 317c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // For safety, the callback should be bound to some sort of WeakPtr<> or 318c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // scoped_refptr<>. 319c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void GetAllNodes( 320c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); 321c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RegisterAuthNotifications(); 323ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch void UnregisterAuthNotifications(); 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if sync is enabled/not suppressed and the user is logged in. 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (being logged in does not mean that tokens are available - tokens may 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be missing because they have not loaded yet, or because they were deleted 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // due to http://crbug.com/121755). 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Virtual to enable mocking in tests. 330a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // TODO(tim): Remove this? Nothing in ProfileSyncService uses it, and outside 331a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // callers use a seemingly arbitrary / redundant / bug prone combination of 332a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // this method, IsSyncAccessible, and others. 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsSyncEnabledAndLoggedIn(); 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Return whether OAuth2 refresh token is loaded and available for the backend 3367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // to start up. Virtual to enable mocking in tests. 3377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual bool IsOAuthRefreshTokenAvailable(); 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Registers a data type controller with the sync service. This 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // makes the data type controller available for use, it does not 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // enable or activate the synchronization of the data type (see 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ActivateDataType). Takes ownership of the pointer. 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RegisterDataTypeController( 3445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) sync_driver::DataTypeController* data_type_controller); 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 346c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Registers a type whose sync storage will not be managed by the 347c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // ProfileSyncService. It declares that this sync type may be activated at 348c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // some point in the future. This function call does not enable or activate 349c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // the syncing of this type 350c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void RegisterNonBlockingType(syncer::ModelType type); 351c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 3525c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // Called by a component that supports non-blocking sync when it is ready to 3535c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // initialize its connection to the sync backend. 3545c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // 3555c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // If policy allows for syncing this type (ie. it is "preferred"), then this 3565c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // should result in a message to enable syncing for this type when the sync 3575c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // backend is available. If the type is not to be synced, this should result 3585c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // in a message that allows the component to delete its local sync state. 3595c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu void InitializeNonBlockingType( 3605c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu syncer::ModelType type, 361116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const scoped_refptr<base::SequencedTaskRunner>& task_runner, 362116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const base::WeakPtr<syncer::ModelTypeSyncProxyImpl>& proxy); 3635c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 364f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Return the active OpenTabsUIDelegate. If sessions is not enabled or not 365f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // currently syncing, returns NULL. 366f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual browser_sync::OpenTabsUIDelegate* GetOpenTabsUIDelegate(); 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3685f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Returns the SyncedWindowDelegatesGetter from the embedded sessions manager. 3695f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) virtual browser_sync::SyncedWindowDelegatesGetter* 3705f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) GetSyncedWindowDelegatesGetter() const; 3715f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 372f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Returns the SyncableService for syncer::SESSIONS. 373f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual syncer::SyncableService* GetSessionsSyncableService(); 374f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 3751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Returns the SyncableService for syncer::DEVICE_INFO. 3761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual syncer::SyncableService* GetDeviceInfoSyncableService(); 377c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 3781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Returns DeviceInfo provider for the local device. 3791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual sync_driver::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider(); 380424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 3811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Returns synced devices tracker. If DEVICE_INFO model type isn't yet 3821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // enabled or syncing, returns NULL. 3831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual sync_driver::DeviceInfoTracker* GetDeviceInfoTracker() const; 384424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills state_map with a map of current data types that are possible to 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sync, as well as their states. 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GetDataTypeControllerStates( 3885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) sync_driver::DataTypeController::StateMap* state_map) const; 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Disables sync for user. Use ShowLoginDialog to enable. 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DisableForUser(); 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Disables sync for the user and prevents it from starting on next restart. 3945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void StopSyncingPermanently(); 3955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // SyncFrontend implementation. 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnBackendInitialized( 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::WeakHandle<syncer::JsBackend>& js_backend, 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) debug_info_listener, 4015f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const std::string& cache_guid, 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool success) OVERRIDE; 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnSyncCycleCompleted() OVERRIDE; 404effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual void OnProtocolEvent(const syncer::ProtocolEvent& event) OVERRIDE; 405010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) virtual void OnDirectoryTypeCommitCounterUpdated( 406010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) syncer::ModelType type, 407010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) const syncer::CommitCounters& counters) OVERRIDE; 408010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) virtual void OnDirectoryTypeUpdateCounterUpdated( 409010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) syncer::ModelType type, 410010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) const syncer::UpdateCounters& counters) OVERRIDE; 411010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) virtual void OnDirectoryTypeStatusCounterUpdated( 412010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) syncer::ModelType type, 413010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) const syncer::StatusCounters& counters) OVERRIDE; 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnSyncConfigureRetry() OVERRIDE; 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnConnectionStatusChange( 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ConnectionStatus status) OVERRIDE; 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnPassphraseRequired( 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::PassphraseRequiredReason reason, 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const sync_pb::EncryptedData& pending_keys) OVERRIDE; 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnPassphraseAccepted() OVERRIDE; 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnEncryptedTypesChanged( 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ModelTypeSet encrypted_types, 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool encrypt_everything) OVERRIDE; 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnEncryptionComplete() OVERRIDE; 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnMigrationNeededForTypes( 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ModelTypeSet types) OVERRIDE; 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnExperimentsChanged( 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::Experiments& experiments) OVERRIDE; 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnActionableError( 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::SyncProtocolError& error) OVERRIDE; 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // DataTypeManagerObserver implementation. 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnConfigureDone( 4345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const sync_driver::DataTypeManager::ConfigureResult& result) OVERRIDE; 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnConfigureRetry() OVERRIDE; 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnConfigureStart() OVERRIDE; 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 438868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // DataTypeEncryptionHandler implementation. 439868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual bool IsPassphraseRequired() const OVERRIDE; 440868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual syncer::ModelTypeSet GetEncryptedDataTypes() const OVERRIDE; 441868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 442effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // SigninManagerBase::Observer implementation. 4431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void GoogleSigninSucceeded(const std::string& account_id, 4441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const std::string& username, 445effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch const std::string& password) OVERRIDE; 4461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void GoogleSignedOut(const std::string& account_id, 4471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const std::string& username) OVERRIDE; 448effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when a user chooses which data types to sync as part of the sync 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // setup wizard. |sync_everything| represents whether they chose the 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // "keep everything synced" option; if true, |chosen_types| will be ignored 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and all data types will be synced. |sync_everything| means "sync all 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // current and future data types." 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnUserChoseDatatypes(bool sync_everything, 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ModelTypeSet chosen_types); 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 457d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Get the sync status code. 458d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) SyncStatusSummary QuerySyncStatusSummary(); 459d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 460d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Get a description of the sync status for displaying in the user interface. 461d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) std::string QuerySyncStatusSummaryString(); 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initializes a struct of status indicators with data from the backend. 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns false if the backend was not available for querying; in that case 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the struct will be filled with default data. 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool QueryDetailedSyncStatus( 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_sync::SyncBackendHost::Status* result); 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const GoogleServiceAuthError& GetAuthError() const; 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if initial sync setup is in progress (does not return true 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if the user is customizing sync after already completing setup once). 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ProfileSyncService uses this to determine if it's OK to start syncing, or 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if the user is still setting up the initial sync configuration. 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool FirstSetupInProgress() const; 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by the UI to notify the ProfileSyncService that UI is visible so it 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // will not start syncing. This tells sync whether it's safe to start 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // downloading data types yet (we don't start syncing until after sync setup 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is complete). The UI calls this as soon as any part of the signin wizard is 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // displayed (even just the login UI). 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If |setup_in_progress| is false, this also kicks the sync engine to ensure 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that data download starts. 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetSetupInProgress(bool setup_in_progress); 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the SyncBackendHost has told us it's ready to accept 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // changes. 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // [REMARK] - it is safe to call this function only from the ui thread. 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // because the variable is not thread safe and should only be accessed from 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // single thread. If we want multiple threads to access this(and there is 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // currently no need to do so) we need to protect this with a lock. 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(timsteele): What happens if the bookmark model is loaded, a change 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // takes place, and the backend isn't initialized yet? 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool sync_initialized() const; 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool HasUnrecoverableError() const; 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& unrecoverable_error_message() { 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return unrecoverable_error_message_; 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) tracked_objects::Location unrecoverable_error_location() { 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return unrecoverable_error_location_; 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if OnPassphraseRequired has been called for decryption and 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // we have an encrypted data type enabled. 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsPassphraseRequiredForDecryption() const; 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::PassphraseRequiredReason passphrase_required_reason() const { 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return passphrase_required_reason_; 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns a user-friendly string form of last synced time (in minutes). 513a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual base::string16 GetLastSyncedTimeString() const; 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns a human readable string describing backend initialization state. 5162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) std::string GetBackendInitializationStateString() const; 5172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns true if startup is suppressed (i.e. user has stopped syncing via 5192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the google dashboard). 5202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool IsStartSuppressed() const; 5212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ProfileSyncComponentsFactory* factory() { return factory_.get(); } 5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The profile we are syncing for. 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile() const { return profile_; } 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns a weak pointer to the service's JsController. 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overrideable for testing purposes. 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual base::WeakPtr<syncer::JsController> GetJsController(); 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Record stats on various events. 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void SyncEvent(SyncEventCodes code); 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether sync is enabled. Sync can be enabled/disabled both 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // at compile time (e.g., on a per-OS basis) or at run time (e.g., 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // command-line switches). 5372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Profile::IsSyncAccessible() is probably a better signal than this function. 5382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // This function can be called from any thread, and the implementation doesn't 5392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // assume it's running on the UI thread. 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool IsSyncEnabled(); 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether sync is managed, i.e. controlled by configuration 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // management. If so, the user is not allowed to configure sync. 5442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool IsManaged() const; 5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // syncer::UnrecoverableErrorHandler implementation. 5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnUnrecoverableError( 5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const tracked_objects::Location& from_here, 5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& message) OVERRIDE; 5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // Called to re-enable a type disabled by DisableDatatype(..). Note, this does 5526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // not change the preferred state of a datatype, and is not persisted across 5536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // restarts. 5546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) void ReenableDatatype(syncer::ModelType type); 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The functions below (until ActivateDataType()) should only be 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // called if sync_initialized() is true. 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(akalin): This is called mostly by ModelAssociators and 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tests. Figure out how to pass the handle to the ModelAssociators 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // directly, figure out how to expose this to tests, and remove this 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // function. 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual syncer::UserShare* GetUserShare() const; 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(akalin): These two functions are used only by 5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ProfileSyncServiceHarness. Figure out a different way to expose 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // this info to that class, and remove these functions. 5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual syncer::sessions::SyncSessionSnapshot 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetLastSessionSnapshot() const; 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether or not the underlying sync engine has made any 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // local changes to items that have not yet been synced with the 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // server. 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HasUnsyncedItems() const; 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used by ProfileSyncServiceHarness. May return NULL. 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_sync::BackendMigrator* GetBackendMigratorForTest(); 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 580f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Used by tests to inspect interaction with OAuth2TokenService. 581f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool IsRetryingAccessTokenFetchForTest() const; 582f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 583f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Used by tests to inspect the OAuth2 access tokens used by PSS. 584f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) std::string GetAccessTokenForTest() const; 585f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(sync): This is only used in tests. Can we remove it? 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns a ListValue indicating the status of all registered types. 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The format is: 5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // [ {"name": <name>, "value": <value>, "status": <status> }, ... ] 5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // where <name> is a type's name, <value> is a string providing details for 5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the type's status, and <status> is one of "error", "warning" or "ok" 59546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // depending on the type's current status. 5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 59746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // This function is used by about_sync_util.cc to help populate the about:sync 5982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // page. It returns a ListValue rather than a DictionaryValue in part to make 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it easier to iterate over its elements when constructing that page. 6005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Value* GetTypeStatusMap() const; 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden by tests. 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(zea): Remove these and have the dtc's call directly into the SBH. 6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DeactivateDataType(syncer::ModelType type); 6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // SyncPrefObserver implementation. 6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnSyncManagedPrefChange(bool is_sync_managed) OVERRIDE; 6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Changes which data types we're going to be syncing to |preferred_types|. 6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If it is running, the DataTypeManager will be instructed to reconfigure 6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the sync backend so that exactly these datatypes are actively synced. See 6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // class comment for more on what it means for a datatype to be Preferred. 6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ChangePreferredDataTypes( 6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ModelTypeSet preferred_types); 6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 616868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Returns the set of types which are preferred for enabling. This is a 6175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // superset of the active types (see GetActiveDataTypes()). 618868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual syncer::ModelTypeSet GetPreferredDataTypes() const; 619868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 620c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Returns the set of directory types which are preferred for enabling. 621c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual syncer::ModelTypeSet GetPreferredDirectoryDataTypes() const; 622c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 623c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Returns the set of off-thread types which are preferred for enabling. 624c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual syncer::ModelTypeSet GetPreferredNonBlockingDataTypes() const; 625c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 6261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Returns the set of types which are enforced programmatically and can not 6271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // be disabled by the user. 6281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual syncer::ModelTypeSet GetForcedDataTypes() const; 6291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the set of all data types that could be allowed (the set that 6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // should be advertised to the user). These will typically only change 6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // via a command-line option. See class comment for more on what it means 6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for a datatype to be Registered. 6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; 6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 636c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Gets the set of directory types which could be allowed. 637c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual syncer::ModelTypeSet GetRegisteredDirectoryDataTypes() const; 638c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 639c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Gets the set of off-thread types which could be allowed. 640c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual syncer::ModelTypeSet GetRegisteredNonBlockingDataTypes() const; 641c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks whether the Cryptographer is ready to encrypt and decrypt updates 6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for sensitive data types. Caller must be holding a 6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // syncapi::BaseTransaction to ensure thread safety. 6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsCryptographerReady( 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::BaseTransaction* trans) const; 6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if a secondary (explicit) passphrase is being used. It is not 6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // legal to call this method before the backend is initialized. 6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsUsingSecondaryPassphrase() const; 6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the actual passphrase type being used for encryption. 6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual syncer::PassphraseType GetPassphraseType() const; 6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the time the current explicit passphrase (if any), was set. 6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If no secondary passphrase is in use, or no time is available, returns an 6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // unset base::Time. 6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual base::Time GetExplicitPassphraseTime() const; 6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note about setting passphrases: There are different scenarios under which 6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // we might want to apply a passphrase. It could be for first-time encryption, 6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // re-encryption, or for decryption by clients that sign in at a later time. 6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // In addition, encryption can either be done using a custom passphrase, or by 6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // reusing the GAIA password. Depending on what is happening in the system, 6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // callers should determine which of the two methods below must be used. 6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Asynchronously sets the passphrase to |passphrase| for encryption. |type| 6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // specifies whether the passphrase is a custom passphrase or the GAIA 6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // password being reused as a passphrase. 6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(atwilson): Change this so external callers can only set an EXPLICIT 6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // passphrase with this API. 6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetEncryptionPassphrase(const std::string& passphrase, 6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PassphraseType type); 6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Asynchronously decrypts pending keys using |passphrase|. Returns false 6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // immediately if the passphrase could not be used to decrypt a locally cached 6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // copy of encrypted keys; returns true otherwise. 6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool SetDecryptionPassphrase(const std::string& passphrase) 6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WARN_UNUSED_RESULT; 6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 681ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch // Returns true if encrypting all the sync data is allowed. If this method 682ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch // returns false, EnableEncryptEverything() should not be called. 683ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch virtual bool EncryptEverythingAllowed() const; 684ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch 685ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch // Sets whether encrypting all the sync data is allowed or not. 686ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch virtual void SetEncryptEverythingAllowed(bool allowed); 687ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch 6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() 6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // after calling this to force the encryption to occur. 6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void EnableEncryptEverything(); 6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if we are currently set to encrypt all the sync data. Note: 6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // this is based on the cryptographer's settings, so if the user has recently 6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // requested encryption to be turned on, this may not be true yet. For that, 6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // encryption_pending() must be checked. 6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool EncryptEverythingEnabled() const; 6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the syncer is waiting for new datatypes to be encrypted. 6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool encryption_pending() const; 7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& sync_service_url() const { return sync_service_url_; } 7025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SigninManagerBase* signin() const; 703a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 704a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Used by tests. 705a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool auto_start_enabled() const; 706a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool setup_in_progress() const; 7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stops the sync backend and sets the flag for suppressing sync startup. 7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StopAndSuppress(); 7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Resets the flag for suppressing sync startup and starts the sync backend. 71290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual void UnsuppressAndStart(); 7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Marks all currently registered types as "acknowledged" so we won't prompt 7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the user about them any more. 7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void AcknowledgeSyncedTypes(); 7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 718effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch SyncErrorController* sync_error_controller() { 719effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch return sync_error_controller_.get(); 720effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch } 7215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(sync): This is only used in tests. Can we remove it? 7231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const sync_driver::DataTypeStatusTable& data_type_status_table() const; 7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) sync_driver::DataTypeManager::ConfigureStatus configure_status() { 7265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return configure_status_; 7275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If true, the ProfileSyncService has detected that a new GAIA signin has 7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // succeeded, and is waiting for initialization to complete. This is used by 7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the UI to differentiate between a new auth error (encountered as part of 7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the initialization process) and a pre-existing auth error that just hasn't 7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // been cleared yet. Virtual for testing purposes. 7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool waiting_for_auth() const; 7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The set of currently enabled sync experiments. 7372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const syncer::Experiments& current_experiments() const; 7382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 739ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // OAuth2TokenService::Consumer implementation. 7407d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual void OnGetTokenSuccess( 7417d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const OAuth2TokenService::Request* request, 7427d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const std::string& access_token, 7437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const base::Time& expiration_time) OVERRIDE; 7447d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual void OnGetTokenFailure( 7457d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const OAuth2TokenService::Request* request, 7467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const GoogleServiceAuthError& error) OVERRIDE; 7477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 748ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // OAuth2TokenService::Observer implementation. 749ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 7503551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 751ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void OnRefreshTokensLoaded() OVERRIDE; 752ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 753a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // KeyedService implementation. This must be called exactly 7545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // once (before this object is destroyed). 7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Shutdown() OVERRIDE; 7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 757c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Called when a datatype (SyncableService) has a need for sync to start 758c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // ASAP, presumably because a local change event has occurred but we're 759c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // still in deferred start mode, meaning the SyncableService hasn't been 760c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // told to MergeDataAndStartSyncing yet. 761c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void OnDataTypeRequestsSyncStartup(syncer::ModelType type); 762c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 763f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Return sync token status. 764f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) SyncTokenStatus GetSyncTokenStatus() const; 765f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 766f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) browser_sync::FaviconCache* GetFaviconCache(); 767f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 768a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Overrides the NetworkResources used for Sync connections. 769a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // This function takes ownership of |network_resources|. 770a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void OverrideNetworkResourcesForTest( 771a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) scoped_ptr<syncer::NetworkResources> network_resources); 7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool IsDataTypeControllerRunning(syncer::ModelType type) const; 7745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 775cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) BackendMode backend_mode() const { 776cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return backend_mode_; 777cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 778cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 77903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // Helpers for testing rollback. 78003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void SetBrowsingDataRemoverObserverForTesting( 78103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) BrowsingDataRemover::Observer* observer); 78203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void SetClearingBrowseringDataForTesting(base::Callback< 78303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void(BrowsingDataRemover::Observer*, Profile*, base::Time, base::Time)> 78403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) c); 78546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 786f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Return the base URL of the Sync Server. 787f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) static GURL GetSyncServiceURL(const base::CommandLine& command_line); 788f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 789116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch base::Time GetDeviceBackupTimeForTesting() const; 790116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 791a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) protected: 792c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Helper to configure the priority data types. 793c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void ConfigurePriorityDataTypes(); 794c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper to install and configure a data type manager. 7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ConfigureDataTypeManager(); 7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Shuts down the backend sync components. 7995f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // |reason| dictates if syncing is being disabled or not, and whether 800a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // to claim ownership of sync thread from backend. 8015f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) void ShutdownImpl(syncer::ShutdownReason reason); 8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 803f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Return SyncCredentials from the OAuth2TokenService. 8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::SyncCredentials GetCredentials(); 8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 806a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); 807a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 8085f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const sync_driver::DataTypeController::TypeMap& 8095c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu directory_data_type_controllers() { 8105c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return directory_data_type_controllers_; 8115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper method for managing encryption UI. 8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsEncryptedDatatypeEnabled() const; 8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper for OnUnrecoverableError. 8175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, 8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and in SyncBackendHost::Shutdown. 8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnUnrecoverableErrorImpl( 8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const tracked_objects::Location& from_here, 8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& message, 8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool delete_sync_database); 8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual bool NeedBackup() const; 8256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is a cache of the last authentication response we received from the 8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sync server. The UI queries this to display appropriate messaging to the 8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // user. 8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GoogleServiceAuthError last_auth_error_; 8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Our asynchronous backend to communicate with sync components living on 8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // other threads. 8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<browser_sync::SyncBackendHost> backend_; 8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it 8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // was required for encryption, decryption with a cached passphrase, or 8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // because a new passphrase is required? 8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::PassphraseRequiredReason passphrase_required_reason_; 8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum UnrecoverableErrorReason { 8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_UNSET, 8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_SYNCER, 8445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_BACKEND_INIT_FAILURE, 8455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_CONFIGURATION_RETRY, 8465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_CONFIGURATION_FAILURE, 8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_ACTIONABLE_ERROR, 8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ERROR_REASON_LIMIT 8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 850f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 851f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) enum AuthErrorMetric { 852f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) AUTH_ERROR_ENCOUNTERED, 853f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) AUTH_ERROR_FIXED, 854f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) AUTH_ERROR_LIMIT 855f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) }; 856f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class ProfileSyncServicePasswordTest; 8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class SyncTest; 8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class TestProfileSyncService; 8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); 8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Update the last auth error and notify observers of error state. 8634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void UpdateAuthErrorState(const GoogleServiceAuthError& error); 8644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 8655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Detects and attempts to recover from a previous improper datatype 8665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // configuration where Keep Everything Synced and the preferred types were 8675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not correctly set. 8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void TrySyncDatatypePrefRecovery(); 8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Puts the backend's sync scheduler into NORMAL mode. 8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when configuration is complete. 8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StartSyncingWithServer(); 8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when we've determined that we don't need a passphrase (either 8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // because OnPassphraseAccepted() was called, or because we've gotten a 8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnPassphraseRequired() but no data types are enabled). 8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ResolvePassphraseRequired(); 8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // During initial signin, ProfileSyncService caches the user's signin 8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // passphrase so it can be used to encrypt/decrypt data after sync starts up. 8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This routine is invoked once the backend has started up to use the 8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // cached passphrase and clear it out when it is done. 8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ConsumeCachedPassphraseIfPossible(); 8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8857d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // RequestAccessToken initiates RPC to request downscoped access token from 886f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // refresh token. This happens when a new OAuth2 login token is loaded and 8877d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // when sync server returns AUTH_ERROR which indicates it is time to refresh 8887d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // token. 8897d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual void RequestAccessToken(); 8907d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 891cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Return true if backend should start from a fresh sync DB. 892cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool ShouldDeleteSyncFolder(); 893cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If |delete_sync_data_folder| is true, then this method will delete all 8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // previous "Sync Data" folders. (useful if the folder is partial/corrupt). 8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InitializeBackend(bool delete_sync_data_folder); 8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initializes the various settings from the command line. 8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void InitSettings(); 9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the last synced time to the current time. 9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateLastSyncedTime(); 9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyObservers(); 905eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void NotifySyncCycleCompleted(); 9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ClearStaleErrors(); 9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ClearUnrecoverableError(); 9105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 911cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Starts up the backend sync components. |mode| specifies the kind of 912cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // backend to start, one of SYNC, BACKUP or ROLLBACK. 913f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) virtual void StartUpSlowBackendComponents(BackendMode mode); 9142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // About-flags experiment names for datatypes that aren't enabled by default 9165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // yet. 9175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static std::string GetExperimentNameForDataType( 9185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ModelType data_type); 9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Create and register a new datatype controller. 9215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RegisterNewDataType(syncer::ModelType data_type); 9225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Reconfigures the data type manager with the latest enabled types. 9245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note: Does not initialize the backend if it is not already initialized. 9255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This function needs to be called only after sync has been initialized 9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (i.e.,only for reconfigurations). The reason we don't initialize the 9275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // backend is because if we had encountered an unrecoverable error we don't 9285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // want to startup once more. 9295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReconfigureDatatypeManager(); 9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Collects preferred sync data types from |preference_providers_|. 9326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) syncer::ModelTypeSet GetDataTypesFromPreferenceProviders() const; 9336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 9345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when the user changes the sync configuration, to update the UMA 9355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // stats. 9365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void UpdateSelectedTypesHistogram( 9375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool sync_everything, 9385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::ModelTypeSet chosen_types) const; 9395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_CHROMEOS) 9415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Refresh spare sync bootstrap token for re-enabling the sync service. 9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called on successful sign-in notifications. 9435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RefreshSpareBootstrapToken(const std::string& passphrase); 9445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 9455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Internal unrecoverable error handler. Used to track error reason via 9475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sync.UnrecoverableErrors histogram. 9485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, 9495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& message, 9505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool delete_sync_database, 9515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) UnrecoverableErrorReason reason); 9525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 953cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Returns the type of manager to use according to |backend_mode_|. 954cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) syncer::SyncManagerFactory::MANAGER_TYPE GetManagerType() const; 955cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 956cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Update UMA for syncing backend. 957cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void UpdateBackendInitUMA(bool success); 958cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 959cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Various setup following backend initialization, mostly for syncing backend. 960cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void PostBackendInitialization(); 961cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 962cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // True if a syncing backend exists. 963cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool HasSyncingBackend() const; 964cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 96546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // Update first sync time stored in preferences 96646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) void UpdateFirstSyncTimePref(); 96746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 96846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // Clear browsing data since first sync during rollback. 96946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) void ClearBrowsingDataSinceFirstSync(); 97046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 971116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Post background task to check sync backup DB state if needed. 972116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void CheckSyncBackupIfNeeded(); 973116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 974116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Callback to receive backup DB check result. 975116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void CheckSyncBackupCallback(base::Time backup_time); 976116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 9776e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Callback function to call |startup_controller_|.TryStart() after 9786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // backup/rollback finishes; 9796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void TryStartSyncAfterBackup(); 9806e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 9816e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Clean up prefs and backup DB when rollback is not needed. 9826e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void CleanUpBackup(); 9836e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 98490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Factory used to create various dependent objects. 9855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<ProfileSyncComponentsFactory> factory_; 9865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The profile whose data we are synchronizing. 9885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profile* profile_; 9895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The class that handles getting, setting, and persisting sync 9915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // preferences. 99223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) sync_driver::SyncPrefs sync_prefs_; 9935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(ncarter): Put this in a profile, once there is UI for it. 9955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This specifies where to find the sync server. 996f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) const GURL sync_service_url_; 9975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The time that OnConfigureStart is called. This member is zero if 9995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnConfigureStart has not yet been called, and is reset to zero once 10005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnConfigureDone is called. 10015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Time sync_configure_start_time_; 10025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates if this is the first time sync is being configured. This value 10045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). 10055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_first_time_sync_configure_; 10065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10075c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // List of available data type controllers for directory types. 10085f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) sync_driver::DataTypeController::TypeMap directory_data_type_controllers_; 1009c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 10105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the SyncBackendHost has been initialized. 10115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool backend_initialized_; 10125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1013868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents 1014868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // ProfileSyncService from starting backend till browser restarted or user 1015868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // signed out. 1016868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool sync_disabled_by_admin_; 1017868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 10185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set to true if a signin has completed but we're still waiting for the 10195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // backend to refresh its credentials. 10205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_auth_in_progress_; 10215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Encapsulates user signin - used to set/get the user's authenticated 10235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // email address. 1024116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const scoped_ptr<SupervisedUserSigninManagerWrapper> signin_; 10255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Information describing an unrecoverable error. 10275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) UnrecoverableErrorReason unrecoverable_error_reason_; 10285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string unrecoverable_error_message_; 10295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) tracked_objects::Location unrecoverable_error_location_; 10305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // Manages the start and stop of the directory data types. 10325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) scoped_ptr<sync_driver::DataTypeManager> directory_data_type_manager_; 10335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 10345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // Manager for the non-blocking data types. 10355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) sync_driver::NonBlockingDataTypeManager non_blocking_data_type_manager_; 10365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1037ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch ObserverList<ProfileSyncServiceBase::Observer> observers_; 1038effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ObserverList<browser_sync::ProtocolEventObserver> protocol_event_observers_; 1039010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; 10405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) std::set<SyncTypePreferenceProvider*> preference_providers_; 10426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 10435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::SyncJsController sync_js_controller_; 10445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This allows us to gracefully handle an ABORTED return code from the 10465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // DataTypeManager in the event that the server informed us to cease and 10475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // desist syncing immediately. 10485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool expect_sync_configuration_aborted_; 10495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sometimes we need to temporarily hold on to a passphrase because we don't 10515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // yet have a backend to send it to. This happens during initialization as 10525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // we don't StartUp until we have a valid token, which happens after valid 10535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // credentials were provided. 10545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string cached_passphrase_; 10555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The current set of encrypted types. Always a superset of 10575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // syncer::Cryptographer::SensitiveTypes(). 10585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::ModelTypeSet encrypted_types_; 10595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1060ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch // Whether encrypting everything is allowed. 1061ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch bool encrypt_everything_allowed_; 1062ab8f6f0bd665d3c1ff476eb06c58c42630e462d4Ben Murdoch 10635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether we want to encrypt everything. 10645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool encrypt_everything_; 10655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether we're waiting for an attempt to encryption all sync data to 10675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // complete. We track this at this layer in order to allow the user to cancel 10685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if they e.g. don't remember their explicit passphrase. 10695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool encryption_pending_; 10705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<browser_sync::BackendMigrator> migrator_; 10725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the last |SyncProtocolError| we received from the server that had 10745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // an action set on it. 10755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::SyncProtocolError last_actionable_error_; 10765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1077effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Exposes sync errors to the UI. 1078effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch scoped_ptr<SyncErrorController> sync_error_controller_; 10795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1080868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Tracks the set of failed data types (those that encounter an error 1081868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // or must delay loading for some reason). 10821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci sync_driver::DataTypeStatusTable data_type_status_table_; 10835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) sync_driver::DataTypeManager::ConfigureStatus configure_status_; 10855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The set of currently enabled sync experiments. 10872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) syncer::Experiments current_experiments_; 10885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sync's internal debug info listener. Used to record datatype configuration 10905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and association information. 10915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; 10925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1093a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // A thread where all the sync operations happen. 1094a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // OWNERSHIP Notes: 1095a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // * Created when backend starts for the first time. 1096a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // * If sync is disabled, PSS claims ownership from backend. 1097a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) // * If sync is reenabled, PSS passes ownership to new backend. 1098a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) scoped_ptr<base::Thread> sync_thread_; 1099a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 110068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // ProfileSyncService uses this service to get access tokens. 1101f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) ProfileOAuth2TokenService* const oauth2_token_service_; 110268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 11037d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // ProfileSyncService needs to remember access token in order to invalidate it 11047d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // with OAuth2TokenService. 11057d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) std::string access_token_; 11067d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 11077d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // ProfileSyncService needs to hold reference to access_token_request_ for 11087d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // the duration of request in order to receive callbacks. 11097d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) scoped_ptr<OAuth2TokenService::Request> access_token_request_; 11107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 11117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // If RequestAccessToken fails with transient error then retry requesting 11127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // access token with exponential backoff. 11137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) base::OneShotTimer<ProfileSyncService> request_access_token_retry_timer_; 11147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) net::BackoffEntry request_access_token_backoff_; 11157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 11164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) base::WeakPtrFactory<ProfileSyncService> weak_factory_; 11174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // We don't use |weak_factory_| for the StartupController because the weak 1119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // ptrs should be bound to the lifetime of ProfileSyncService and not to the 1120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // [Initialize -> sync disabled/shutdown] lifetime. We don't pass 1121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // StartupController an Unretained reference to future-proof against 1122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the controller impl changing to post tasks. Therefore, we have a separate 1123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // factory. 1124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; 1125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1126f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // States related to sync token and connection. 1127f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time connection_status_update_time_; 1128f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) syncer::ConnectionStatus connection_status_; 1129f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time token_request_time_; 1130f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time token_receive_time_; 1131f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) GoogleServiceAuthError last_get_token_error_; 1132f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Time next_token_request_time_; 1133f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 11341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_ptr<sync_driver::LocalDeviceInfoProvider> local_device_; 11355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1136f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Locally owned SyncableService implementations. 11371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_ptr<browser_sync::SessionsSyncManager> sessions_sync_manager_; 11381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_ptr<sync_driver::DeviceInfoSyncService> device_info_sync_service_; 1139f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1140a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) scoped_ptr<syncer::NetworkResources> network_resources_; 1141a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) browser_sync::StartupController startup_controller_; 1143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1144cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) browser_sync::BackupRollbackController backup_rollback_controller_; 1145cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 1146cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Mode of current backend. 1147cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) BackendMode backend_mode_; 1148cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 11496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Whether backup is needed before sync starts. 11506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool need_backup_; 11516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 11526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Whether backup is finished. 11536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool backup_finished_; 11546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 11556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) base::Time backup_start_time_; 1156cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 115703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) base::Callback< 115803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void(BrowsingDataRemover::Observer*, Profile*, base::Time, base::Time)> 115903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) clear_browsing_data_; 116046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 1161116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Last time when pre-sync data was saved. NULL pointer means backup data 1162116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // state is unknown. If time value is null, backup data doesn't exist. 1163116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<base::Time> last_backup_time_; 1164116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 116503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) BrowsingDataRemover::Observer* browsing_data_remover_observer_; 116603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 11675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); 11685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 11695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 11705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ShouldShowActionOnUI( 11715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const syncer::SyncProtocolError& error); 11725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 11735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 11745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ 1175