blob: 1e9dc4d58a7badd33dcf7e6e766127400815aa5a [file] [log] [blame]
[email protected]66761b952010-06-25 21:30:381// Copyright (c) 2010 The Chromium Authors. All rights reserved.
[email protected]132c85652009-08-05 01:18:272// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]132c85652009-08-05 01:18:275#ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
6#define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]132c85652009-08-05 01:18:278
9#include <string>
[email protected]132c85652009-08-05 01:18:2710
11#include "base/basictypes.h"
[email protected]61b694a2010-06-10 10:40:4612#include "base/gtest_prod_util.h"
[email protected]132c85652009-08-05 01:18:2713#include "base/observer_list.h"
14#include "base/scoped_ptr.h"
[email protected]066146872010-08-05 00:55:0815#include "base/string16.h"
[email protected]4aea04a2010-02-10 20:13:4316#include "base/time.h"
[email protected]990de362010-10-13 17:55:5017#include "base/timer.h"
[email protected]37858e52010-08-26 00:22:0218#include "chrome/browser/prefs/pref_member.h"
[email protected]e8234d32010-09-09 20:36:3919#include "chrome/browser/sync/engine/syncapi.h"
[email protected]72a31b42010-02-17 22:26:3320#include "chrome/browser/sync/glue/data_type_controller.h"
[email protected]e3e43d92010-02-26 22:02:3821#include "chrome/browser/sync/glue/data_type_manager.h"
[email protected]5edb9222010-08-18 00:23:2922#include "chrome/browser/sync/glue/session_model_associator.h"
[email protected]132c85652009-08-05 01:18:2723#include "chrome/browser/sync/glue/sync_backend_host.h"
[email protected]d3b98c82010-07-14 07:45:5924#include "chrome/browser/sync/profile_sync_service_observer.h"
[email protected]e8234d32010-09-09 20:36:3925#include "chrome/browser/sync/signin_manager.h"
[email protected]d80033e2009-10-16 10:32:0426#include "chrome/browser/sync/sync_setup_wizard.h"
[email protected]4aea04a2010-02-10 20:13:4327#include "chrome/browser/sync/syncable/model_type.h"
[email protected]eafb2182010-03-03 00:46:3128#include "chrome/browser/sync/unrecoverable_error_handler.h"
[email protected]99074c52010-08-19 18:44:1929#include "chrome/common/net/gaia/google_service_auth_error.h"
[email protected]c4c672a2010-03-23 21:47:0430#include "chrome/common/notification_observer.h"
31#include "chrome/common/notification_registrar.h"
[email protected]132c85652009-08-05 01:18:2732#include "googleurl/src/gurl.h"
[email protected]33cd0042010-09-08 19:25:2833#include "jingle/notifier/base/notifier_options.h"
[email protected]132c85652009-08-05 01:18:2734
[email protected]c4c672a2010-03-23 21:47:0435class NotificationDetails;
36class NotificationSource;
37class NotificationType;
[email protected]942690b132010-05-11 06:42:1438class Profile;
39class ProfileSyncFactory;
[email protected]e8234d32010-09-09 20:36:3940class TokenMigrator;
[email protected]c4c672a2010-03-23 21:47:0441
[email protected]132c85652009-08-05 01:18:2742// ProfileSyncService is the layer between browser subsystems like bookmarks,
[email protected]a1c2aef62010-04-02 02:58:0543// and the sync backend. Each subsystem is logically thought of as being
44// a sync datatype.
45//
46// Individual datatypes can, at any point, be in a variety of stages of being
47// "enabled". Here are some specific terms for concepts used in this class:
48//
49// 'Registered' (feature suppression for a datatype)
50//
51// When a datatype is registered, the user has the option of syncing it.
52// The sync opt-in UI will show only registered types; a checkbox should
53// never be shown for an unregistered type, and nor should it ever be
54// synced.
55//
56// A datatype is considered registered once RegisterDataTypeController
57// has been called with that datatype's DataTypeController.
58//
59// 'Preferred' (user preferences and opt-out for a datatype)
60//
61// This means the user's opt-in or opt-out preference on a per-datatype
62// basis. The sync service will try to make active exactly these types.
63// If a user has opted out of syncing a particular datatype, it will
64// be registered, but not preferred.
65//
66// This state is controlled by the ConfigurePreferredDataTypes and
67// GetPreferredDataTypes. They are stored in the preferences system,
68// and persist; though if a datatype is not registered, it cannot
69// be a preferred datatype.
70//
71// 'Active' (run-time initialization of sync system for a datatype)
72//
73// An active datatype is a preferred datatype that is actively being
74// synchronized: the syncer has been instructed to querying the server
75// for this datatype, first-time merges have finished, and there is an
76// actively installed ChangeProcessor that listens for changes to this
77// datatype, propagating such changes into and out of the sync backend
78// as necessary.
79//
80// When a datatype is in the process of becoming active, it may be
81// in some intermediate state. Those finer-grained intermediate states
82// are differentiated by the DataTypeController state.
83//
[email protected]4aea04a2010-02-10 20:13:4384class ProfileSyncService : public browser_sync::SyncFrontend,
[email protected]c4c672a2010-03-23 21:47:0485 public browser_sync::UnrecoverableErrorHandler,
86 public NotificationObserver {
[email protected]132c85652009-08-05 01:18:2787 public:
88 typedef ProfileSyncServiceObserver Observer;
89 typedef browser_sync::SyncBackendHost::Status Status;
90
[email protected]1f97a112009-08-11 02:17:0691 enum SyncEventCodes {
92 MIN_SYNC_EVENT_CODE = 0,
93
94 // Events starting the sync service.
95 START_FROM_NTP = 1, // Sync was started from the ad in NTP
96 START_FROM_WRENCH = 2, // Sync was started from the Wrench menu.
97 START_FROM_OPTIONS = 3, // Sync was started from Wrench->Options.
[email protected]b220d13f2009-10-09 04:12:4698 START_FROM_BOOKMARK_MANAGER = 4, // Sync was started from Bookmark manager.
[email protected]1f97a112009-08-11 02:17:0699
[email protected]a7ab8332010-03-31 20:49:04100 // Events regarding cancellation of the signon process of sync.
[email protected]8ac2dc112009-10-01 23:19:13101 CANCEL_FROM_SIGNON_WITHOUT_AUTH = 10, // Cancelled before submitting
[email protected]1f97a112009-08-11 02:17:06102 // username and password.
103 CANCEL_DURING_SIGNON = 11, // Cancelled after auth.
[email protected]c976938f2010-10-12 04:55:44104 CANCEL_DURING_CONFIGURE = 12, // Cancelled before choosing data
[email protected]8c94d632010-06-25 22:38:00105 // types and clicking OK.
[email protected]1f97a112009-08-11 02:17:06106 // Events resulting in the stoppage of sync service.
107 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options.
108
109 // Miscellaneous events caused by sync service.
[email protected]1f97a112009-08-11 02:17:06110
111 MAX_SYNC_EVENT_CODE
112 };
113
[email protected]689a7a72010-09-29 19:56:41114 // Keep track of where we are when clearing server data.
115 enum ClearServerDataState {
116 CLEAR_NOT_STARTED = 1,
117 CLEAR_CLEARING = 2,
118 CLEAR_FAILED = 3,
119 CLEAR_SUCCEEDED = 4,
120 };
121
[email protected]f66bcdf2010-05-17 20:31:14122 // Default sync server URL.
123 static const char* kSyncServerUrl;
124 // Sync server URL for dev channel users
125 static const char* kDevServerUrl;
126
[email protected]e3e43d92010-02-26 22:02:38127 ProfileSyncService(ProfileSyncFactory* factory_,
128 Profile* profile,
[email protected]e8234d32010-09-09 20:36:39129 const std::string& cros_user);
[email protected]132c85652009-08-05 01:18:27130 virtual ~ProfileSyncService();
131
132 // Initializes the object. This should be called every time an object of this
133 // class is constructed.
134 void Initialize();
135
[email protected]e8234d32010-09-09 20:36:39136 void RegisterAuthNotifications();
137
138 // Return whether all sync tokens are loaded and
139 // available for the backend to start up.
140 bool AreCredentialsAvailable();
141
142 // Loads credentials migrated from the old user settings db.
143 void LoadMigratedCredentials(const std::string& username,
144 const std::string& token);
145
[email protected]4aea04a2010-02-10 20:13:43146 // Registers a data type controller with the sync service. This
147 // makes the data type controller available for use, it does not
148 // enable or activate the synchronization of the data type (see
149 // ActivateDataType). Takes ownership of the pointer.
150 void RegisterDataTypeController(
151 browser_sync::DataTypeController* data_type_controller);
152
[email protected]5edb9222010-08-18 00:23:29153 // Returns the session model associator associated with this type, but only if
154 // the associator is running. If it is doing anything else, it will return
155 // null.
156 browser_sync::SessionModelAssociator* GetSessionModelAssociator();
157
[email protected]689a7a72010-09-29 19:56:41158 // Maintain state of where we are in a server clear operation.
159 void ResetClearServerDataState();
160 ClearServerDataState GetClearServerDataState();
161
[email protected]a7ab8332010-03-31 20:49:04162 // Fills state_map with a map of current data types that are possible to
163 // sync, as well as their states.
164 void GetDataTypeControllerStates(
165 browser_sync::DataTypeController::StateMap* state_map) const;
[email protected]4aea04a2010-02-10 20:13:43166
[email protected]e8234d32010-09-09 20:36:39167 // Disables sync for user. Use ShowLoginDialog to enable.
[email protected]132c85652009-08-05 01:18:27168 virtual void DisableForUser();
169
[email protected]1ce52aa2010-09-08 19:07:36170 // Clears all Chromesync data from the server.
171 void ClearServerData();
172
[email protected]132c85652009-08-05 01:18:27173 // Whether sync is enabled by user or not.
[email protected]4772b072010-03-30 17:45:46174 virtual bool HasSyncSetupCompleted() const;
[email protected]48352c12009-08-15 01:19:11175 void SetSyncSetupCompleted();
[email protected]132c85652009-08-05 01:18:27176
[email protected]132c85652009-08-05 01:18:27177 // SyncFrontend implementation.
178 virtual void OnBackendInitialized();
179 virtual void OnSyncCycleCompleted();
180 virtual void OnAuthError();
[email protected]7f8abea2010-07-14 01:31:36181 virtual void OnStopSyncingPermanently();
[email protected]1ce52aa2010-09-08 19:07:36182 virtual void OnClearServerDataFailed();
[email protected]990de362010-10-13 17:55:50183 virtual void OnClearServerDataTimeout();
[email protected]1ce52aa2010-09-08 19:07:36184 virtual void OnClearServerDataSucceeded();
[email protected]132c85652009-08-05 01:18:27185
186 // Called when a user enters credentials through UI.
187 virtual void OnUserSubmittedAuth(const std::string& username,
[email protected]1fc9b3f2009-11-12 21:22:09188 const std::string& password,
[email protected]96209ccd2010-10-11 21:57:27189 const std::string& captcha,
190 const std::string& access_code);
[email protected]132c85652009-08-05 01:18:27191
[email protected]e8234d32010-09-09 20:36:39192 // Update the last auth error and notify observers of error state.
193 void UpdateAuthErrorState(const GoogleServiceAuthError& error);
194
[email protected]af909492010-06-10 18:45:38195 // Called when a user chooses which data types to sync as part of the sync
196 // setup wizard. |sync_everything| represents whether they chose the
[email protected]8c94d632010-06-25 22:38:00197 // "keep everything synced" option; if true, |chosen_types| will be ignored
198 // and all data types will be synced. |sync_everything| means "sync all
199 // current and future data types."
[email protected]af909492010-06-10 18:45:38200 virtual void OnUserChoseDatatypes(bool sync_everything,
[email protected]8c94d632010-06-25 22:38:00201 const syncable::ModelTypeSet& chosen_types);
[email protected]af909492010-06-10 18:45:38202
[email protected]a7ab8332010-03-31 20:49:04203 // Called when a user cancels any setup dialog (login, etc).
[email protected]132c85652009-08-05 01:18:27204 virtual void OnUserCancelledDialog();
205
206 // Get various information for displaying in the user interface.
207 browser_sync::SyncBackendHost::StatusSummary QuerySyncStatusSummary();
208 browser_sync::SyncBackendHost::Status QueryDetailedSyncStatus();
209
[email protected]712257e2009-11-11 22:57:46210 const GoogleServiceAuthError& GetAuthError() const {
[email protected]132c85652009-08-05 01:18:27211 return last_auth_error_;
212 }
213
214 // Displays a dialog for the user to enter GAIA credentials and attempt
215 // re-authentication, and returns true if it actually opened the dialog.
216 // Returns false if a dialog is already showing, an auth attempt is in
217 // progress, the sync system is already authenticated, or some error
218 // occurred preventing the action. We make it the duty of ProfileSyncService
219 // to open the dialog to easily ensure only one is ever showing.
[email protected]d6885592010-10-11 19:38:24220 virtual bool SetupInProgress() const;
[email protected]44b78f90a2009-10-15 17:32:20221 bool WizardIsVisible() const {
222 return wizard_.IsVisible();
223 }
[email protected]d6885592010-10-11 19:38:24224 virtual void ShowLoginDialog(gfx::NativeWindow parent_window);
[email protected]fbfc2ec2010-07-16 17:00:42225 void ShowChooseDataTypes(gfx::NativeWindow parent_window);
[email protected]8c94d632010-06-25 22:38:00226
[email protected]132c85652009-08-05 01:18:27227 // Pretty-printed strings for a given StatusSummary.
[email protected]066146872010-08-05 00:55:08228 static std::string BuildSyncStatusSummaryText(
[email protected]132c85652009-08-05 01:18:27229 const browser_sync::SyncBackendHost::StatusSummary& summary);
230
231 // Returns true if the SyncBackendHost has told us it's ready to accept
232 // changes.
233 // TODO(timsteele): What happens if the bookmark model is loaded, a change
234 // takes place, and the backend isn't initialized yet?
235 bool sync_initialized() const { return backend_initialized_; }
[email protected]fb42c982009-09-16 22:33:33236 bool unrecoverable_error_detected() const {
237 return unrecoverable_error_detected_;
238 }
[email protected]f6ec8b22010-06-08 23:40:06239 const std::string& unrecoverable_error_message() {
240 return unrecoverable_error_message_;
241 }
242 tracked_objects::Location unrecoverable_error_location() {
243 return unrecoverable_error_location_.get() ?
244 *unrecoverable_error_location_.get() : tracked_objects::Location();
245 }
[email protected]132c85652009-08-05 01:18:27246
247 bool UIShouldDepictAuthInProgress() const {
248 return is_auth_in_progress_;
249 }
250
251 // A timestamp marking the last time the service observed a transition from
252 // the SYNCING state to the READY state. Note that this does not reflect the
253 // last time we polled the server to see if there were any changes; the
254 // timestamp is only snapped when syncing takes place and we download or
255 // upload some bookmark entity.
256 const base::Time& last_synced_time() const { return last_synced_time_; }
257
258 // Returns a user-friendly string form of last synced time (in minutes).
[email protected]066146872010-08-05 00:55:08259 string16 GetLastSyncedTimeString() const;
[email protected]132c85652009-08-05 01:18:27260
261 // Returns the authenticated username of the sync user, or empty if none
262 // exists. It will only exist if the authentication service provider (e.g
263 // GAIA) has confirmed the username is authentic.
264 virtual string16 GetAuthenticatedUsername() const;
265
266 const std::string& last_attempted_user_email() const {
267 return last_attempted_user_email_;
268 }
269
270 // The profile we are syncing for.
[email protected]c976938f2010-10-12 04:55:44271 Profile* profile() const { return profile_; }
[email protected]132c85652009-08-05 01:18:27272
273 // Adds/removes an observer. ProfileSyncService does not take ownership of
274 // the observer.
[email protected]4772b072010-03-30 17:45:46275 virtual void AddObserver(Observer* observer);
276 virtual void RemoveObserver(Observer* observer);
[email protected]132c85652009-08-05 01:18:27277
[email protected]1f97a112009-08-11 02:17:06278 // Record stats on various events.
279 static void SyncEvent(SyncEventCodes code);
280
[email protected]eec3bcfa2009-11-12 17:23:43281 // Returns whether sync is enabled. Sync can be enabled/disabled both
282 // at compile time (e.g., on a per-OS basis) or at run time (e.g.,
283 // command-line switches).
284 static bool IsSyncEnabled();
285
[email protected]d3b98c82010-07-14 07:45:59286 // Retuns whether sync is managed, i.e. controlled by configuration
287 // management. If so, the user is not allowed to configure sync.
288 bool IsManaged();
289
[email protected]db1df0f2009-08-18 22:36:05290 // UnrecoverableErrorHandler implementation.
[email protected]f6ec8b22010-06-08 23:40:06291 virtual void OnUnrecoverableError(
292 const tracked_objects::Location& from_here,
293 const std::string& message);
[email protected]db1df0f2009-08-18 22:36:05294
295 browser_sync::SyncBackendHost* backend() { return backend_.get(); }
296
[email protected]4aea04a2010-02-10 20:13:43297 virtual void ActivateDataType(
298 browser_sync::DataTypeController* data_type_controller,
299 browser_sync::ChangeProcessor* change_processor);
300 virtual void DeactivateDataType(
301 browser_sync::DataTypeController* data_type_controller,
302 browser_sync::ChangeProcessor* change_processor);
303
[email protected]c4c672a2010-03-23 21:47:04304 // NotificationObserver implementation.
305 virtual void Observe(NotificationType type,
306 const NotificationSource& source,
307 const NotificationDetails& details);
308
[email protected]a1c2aef62010-04-02 02:58:05309 // Changes which data types we're going to be syncing to |preferred_types|.
310 // If it is running, the DataTypeManager will be instructed to reconfigure
311 // the sync backend so that exactly these datatypes are actively synced. See
312 // class comment for more on what it means for a datatype to be Preferred.
313 virtual void ChangePreferredDataTypes(
314 const syncable::ModelTypeSet& preferred_types);
315
316 // Get the set of currently enabled data types (as chosen or configured by
317 // the user). See class comment for more on what it means for a datatype
318 // to be Preferred.
319 virtual void GetPreferredDataTypes(
320 syncable::ModelTypeSet* preferred_types) const;
321
322 // Gets the set of all data types that could be allowed (the set that
323 // should be advertised to the user). These will typically only change
324 // via a command-line option. See class comment for more on what it means
325 // for a datatype to be Registered.
326 virtual void GetRegisteredDataTypes(
327 syncable::ModelTypeSet* registered_types) const;
[email protected]a7ab8332010-03-31 20:49:04328
[email protected]ff0aa752010-06-10 22:40:52329 // Checks whether the Cryptographer is ready to encrypt and decrypt updates
330 // for sensitive data types.
331 virtual bool IsCryptographerReady() const;
332
[email protected]c976938f2010-10-12 04:55:44333 // Returns true if a secondary passphrase is being used.
334 virtual bool IsUsingSecondaryPassphrase() const;
335
336 // Sets the secondary passphrase.
337 virtual void SetSecondaryPassphrase(const std::string& passphrase);
338
[email protected]ee1adf4b2010-10-11 03:48:48339 // Sets the Cryptographer's passphrase, or caches it until that is possible.
340 // This will check asynchronously whether the passphrase is valid and notify
[email protected]dc39dd1b2010-10-07 18:08:11341 // ProfileSyncServiceObservers via the NotificationService when the outcome
342 // is known.
[email protected]bb899b3f2010-06-23 21:35:32343 virtual void SetPassphrase(const std::string& passphrase);
344
[email protected]5edb9222010-08-18 00:23:29345 // Returns whether processing changes is allowed. Check this before doing
346 // any model-modifying operations.
347 bool ShouldPushChanges();
348
[email protected]9a127f22010-09-17 21:05:16349 const GURL& sync_service_url() const { return sync_service_url_; }
350
[email protected]132c85652009-08-05 01:18:27351 protected:
[email protected]82d9d2952010-05-15 00:36:16352 // Used by ProfileSyncServiceMock only.
353 //
354 // TODO(akalin): Separate this class out into an abstract
355 // ProfileSyncService interface and a ProfileSyncServiceImpl class
356 // so we don't need this hack anymore.
357 ProfileSyncService();
358
[email protected]7cef1c442010-07-07 17:05:22359 // Helper to install and configure a data type manager.
360 void ConfigureDataTypeManager();
[email protected]132c85652009-08-05 01:18:27361
[email protected]132c85652009-08-05 01:18:27362 // Starts up the backend sync components.
363 void StartUp();
364 // Shuts down the backend sync components.
365 // |sync_disabled| indicates if syncing is being disabled or not.
366 void Shutdown(bool sync_disabled);
367
[email protected]48352c12009-08-15 01:19:11368 // Methods to register and remove preferences.
369 void RegisterPreferences();
370 void ClearPreferences();
371
[email protected]e8234d32010-09-09 20:36:39372 // Return SyncCredentials from the TokenService.
373 sync_api::SyncCredentials GetCredentials();
374
[email protected]18af9a22010-08-11 00:47:19375 // Test need to override this to create backends that allow setting up
376 // initial conditions, such as populating sync nodes.
377 virtual void CreateBackend();
[email protected]132c85652009-08-05 01:18:27378
[email protected]7cef1c442010-07-07 17:05:22379 const browser_sync::DataTypeController::TypeMap& data_type_controllers() {
380 return data_type_controllers_;
381 }
382
[email protected]e8234d32010-09-09 20:36:39383 // The wizard will try to read the auth state out of the profile sync
384 // service using this member. Captcha and error state are reflected.
[email protected]712257e2009-11-11 22:57:46385 GoogleServiceAuthError last_auth_error_;
[email protected]132c85652009-08-05 01:18:27386
[email protected]7cef1c442010-07-07 17:05:22387 // Our asynchronous backend to communicate with sync components living on
388 // other threads.
389 scoped_ptr<browser_sync::SyncBackendHost> backend_;
390
[email protected]132c85652009-08-05 01:18:27391 // Cache of the last name the client attempted to authenticate.
392 std::string last_attempted_user_email_;
393
394 private:
[email protected]132c85652009-08-05 01:18:27395 friend class ProfileSyncServiceTest;
[email protected]4f5732a42010-09-21 22:39:09396 friend class ProfileSyncServicePasswordTest;
[email protected]65b3aa12010-02-22 22:49:00397 friend class ProfileSyncServicePreferenceTest;
[email protected]5edb9222010-08-18 00:23:29398 friend class ProfileSyncServiceSessionTest;
[email protected]626a84f2010-09-25 18:02:54399 friend class ProfileSyncServiceTestHarness;
[email protected]61b694a2010-06-10 10:40:46400 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState);
401 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest,
402 UnrecoverableErrorSuspendsService);
[email protected]132c85652009-08-05 01:18:27403
[email protected]18af9a22010-08-11 00:47:19404 // If |delete_sync_data_folder| is true, then this method will delete all
405 // previous "Sync Data" folders. (useful if the folder is partial/corrupt).
406 void InitializeBackend(bool delete_sync_data_folder);
407
[email protected]132c85652009-08-05 01:18:27408 // Initializes the various settings from the command line.
409 void InitSettings();
410
[email protected]132c85652009-08-05 01:18:27411 // Sets the last synced time to the current time.
412 void UpdateLastSyncedTime();
413
[email protected]57ecc4b2010-08-11 03:02:51414 static const char* GetPrefNameForDataType(syncable::ModelType data_type);
[email protected]a1c2aef62010-04-02 02:58:05415
[email protected]cb4c06e2009-08-22 00:24:39416 // Time at which we begin an attempt a GAIA authorization.
417 base::TimeTicks auth_start_time_;
418
419 // Time at which error UI is presented for the new tab page.
[email protected]1f97a112009-08-11 02:17:06420 base::TimeTicks auth_error_time_;
421
[email protected]e3e43d92010-02-26 22:02:38422 // Factory used to create various dependent objects.
423 ProfileSyncFactory* factory_;
424
[email protected]132c85652009-08-05 01:18:27425 // The profile whose data we are synchronizing.
426 Profile* profile_;
427
[email protected]e8234d32010-09-09 20:36:39428 // Email for the ChromiumOS user, if we're running under ChromiumOS.
429 std::string cros_user_;
[email protected]72a31b42010-02-17 22:26:33430
[email protected]132c85652009-08-05 01:18:27431 // TODO(ncarter): Put this in a profile, once there is UI for it.
432 // This specifies where to find the sync server.
433 GURL sync_service_url_;
434
[email protected]132c85652009-08-05 01:18:27435 // The last time we detected a successful transition from SYNCING state.
436 // Our backend notifies us whenever we should take a new snapshot.
437 base::Time last_synced_time_;
438
[email protected]4aea04a2010-02-10 20:13:43439 // List of available data type controllers.
[email protected]72a31b42010-02-17 22:26:33440 browser_sync::DataTypeController::TypeMap data_type_controllers_;
[email protected]db1df0f2009-08-18 22:36:05441
[email protected]132c85652009-08-05 01:18:27442 // Whether the SyncBackendHost has been initialized.
443 bool backend_initialized_;
444
[email protected]132c85652009-08-05 01:18:27445 // Various pieces of UI query this value to determine if they should show
446 // an "Authenticating.." type of message. We are the only central place
447 // all auth attempts funnel through, so it makes sense to provide this.
448 // As its name suggests, this should NOT be used for anything other than UI.
449 bool is_auth_in_progress_;
450
[email protected]44b78f90a2009-10-15 17:32:20451 SyncSetupWizard wizard_;
452
[email protected]e8234d32010-09-09 20:36:39453 // Encapsulates user signin with TokenService.
454 SigninManager signin_;
455
[email protected]132c85652009-08-05 01:18:27456 // True if an unrecoverable error (e.g. violation of an assumed invariant)
457 // occurred during syncer operation. This value should be checked before
458 // doing any work that might corrupt things further.
459 bool unrecoverable_error_detected_;
460
[email protected]f6ec8b22010-06-08 23:40:06461 // A message sent when an unrecoverable error occurred.
462 std::string unrecoverable_error_message_;
463 scoped_ptr<tracked_objects::Location> unrecoverable_error_location_;
464
[email protected]33cd0042010-09-08 19:25:28465 // Contains options specific to how sync clients send and listen to
466 // notifications.
467 notifier::NotifierOptions notifier_options_;
[email protected]93d960ce2010-02-11 04:27:00468
[email protected]e3e43d92010-02-26 22:02:38469 // Manages the start and stop of the various data types.
470 scoped_ptr<browser_sync::DataTypeManager> data_type_manager_;
471
[email protected]132c85652009-08-05 01:18:27472 ObserverList<Observer> observers_;
473
[email protected]c4c672a2010-03-23 21:47:04474 NotificationRegistrar registrar_;
475
[email protected]2be7bf22010-04-23 21:02:37476 ScopedRunnableMethodFactory<ProfileSyncService>
477 scoped_runnable_method_factory_;
478
[email protected]d3b98c82010-07-14 07:45:59479 // The preference that controls whether sync is under control by configuration
480 // management.
481 BooleanPrefMember pref_sync_managed_;
482
[email protected]a47eeb52010-07-15 17:54:25483 // This allows us to gracefully handle an ABORTED return code from the
484 // DataTypeManager in the event that the server informed us to cease and
485 // desist syncing immediately.
486 bool expect_sync_configuration_aborted_;
487
[email protected]e8234d32010-09-09 20:36:39488 scoped_ptr<TokenMigrator> token_migrator_;
489
[email protected]48a98b32010-09-17 20:26:59490 // Sometimes we need to temporarily hold on to a passphrase because we don't
491 // yet have a backend to send it to. This happens during initialization as
492 // we don't StartUp until we have a valid token, which happens after valid
493 // credentials were provided.
494 std::string cached_passphrase_;
495
[email protected]dc39dd1b2010-10-07 18:08:11496 // Whether we have seen a SYNC_PASSPHRASE_REQUIRED since initializing the
497 // backend, telling us that it is safe to send a passphrase down ASAP.
498 bool observed_passphrase_required_;
499
[email protected]689a7a72010-09-29 19:56:41500 // Keep track of where we are in a server clear operation
501 ClearServerDataState clear_server_data_state_;
502
[email protected]990de362010-10-13 17:55:50503 // Timeout for the clear data command. This timeout is a temporary hack
504 // and is necessary becaue the nudge sync framework can drop nudges for
505 // a wide variety of sync-related conditions (throttling, connections issues,
506 // syncer paused, etc.). It can only be removed correctly when the framework
507 // is reworked to allow one-shot commands like clearing server data.
508 base::OneShotTimer<ProfileSyncService> clear_server_data_timer_;
509
[email protected]132c85652009-08-05 01:18:27510 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
511};
512
513#endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_