OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/timer.h" | 17 #include "base/timer.h" |
18 #include "chrome/browser/browser_signin.h" | |
19 #include "chrome/browser/prefs/pref_member.h" | 18 #include "chrome/browser/prefs/pref_member.h" |
20 #include "chrome/browser/sync/engine/syncapi.h" | 19 #include "chrome/browser/sync/engine/syncapi.h" |
21 #include "chrome/browser/sync/glue/data_type_controller.h" | 20 #include "chrome/browser/sync/glue/data_type_controller.h" |
22 #include "chrome/browser/sync/glue/data_type_manager.h" | 21 #include "chrome/browser/sync/glue/data_type_manager.h" |
23 #include "chrome/browser/sync/glue/session_model_associator.h" | 22 #include "chrome/browser/sync/glue/session_model_associator.h" |
24 #include "chrome/browser/sync/glue/sync_backend_host.h" | 23 #include "chrome/browser/sync/glue/sync_backend_host.h" |
25 #include "chrome/browser/sync/profile_sync_service_observer.h" | 24 #include "chrome/browser/sync/profile_sync_service_observer.h" |
26 #include "chrome/browser/sync/signin_manager.h" | 25 #include "chrome/browser/sync/signin_manager.h" |
27 #include "chrome/browser/sync/sync_setup_wizard.h" | 26 #include "chrome/browser/sync/sync_setup_wizard.h" |
28 #include "chrome/browser/sync/syncable/model_type.h" | 27 #include "chrome/browser/sync/syncable/model_type.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // actively installed ChangeProcessor that listens for changes to this | 77 // actively installed ChangeProcessor that listens for changes to this |
79 // datatype, propagating such changes into and out of the sync backend | 78 // datatype, propagating such changes into and out of the sync backend |
80 // as necessary. | 79 // as necessary. |
81 // | 80 // |
82 // When a datatype is in the process of becoming active, it may be | 81 // When a datatype is in the process of becoming active, it may be |
83 // in some intermediate state. Those finer-grained intermediate states | 82 // in some intermediate state. Those finer-grained intermediate states |
84 // are differentiated by the DataTypeController state. | 83 // are differentiated by the DataTypeController state. |
85 // | 84 // |
86 class ProfileSyncService : public browser_sync::SyncFrontend, | 85 class ProfileSyncService : public browser_sync::SyncFrontend, |
87 public browser_sync::UnrecoverableErrorHandler, | 86 public browser_sync::UnrecoverableErrorHandler, |
88 public BrowserSignin::SigninDelegate, | |
89 public NotificationObserver { | 87 public NotificationObserver { |
90 public: | 88 public: |
91 typedef ProfileSyncServiceObserver Observer; | 89 typedef ProfileSyncServiceObserver Observer; |
92 typedef browser_sync::SyncBackendHost::Status Status; | 90 typedef browser_sync::SyncBackendHost::Status Status; |
93 | 91 |
94 enum SyncEventCodes { | 92 enum SyncEventCodes { |
95 MIN_SYNC_EVENT_CODE = 0, | 93 MIN_SYNC_EVENT_CODE = 0, |
96 | 94 |
97 // Events starting the sync service. | 95 // Events starting the sync service. |
98 START_FROM_NTP = 1, // Sync was started from the ad in NTP | 96 START_FROM_NTP = 1, // Sync was started from the ad in NTP |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 return wizard_.IsVisible(); | 225 return wizard_.IsVisible(); |
228 } | 226 } |
229 virtual void ShowLoginDialog(gfx::NativeWindow parent_window); | 227 virtual void ShowLoginDialog(gfx::NativeWindow parent_window); |
230 | 228 |
231 // This method handles clicks on "sync error" UI, showing the appropriate | 229 // This method handles clicks on "sync error" UI, showing the appropriate |
232 // dialog for the error condition (relogin / enter passphrase). | 230 // dialog for the error condition (relogin / enter passphrase). |
233 virtual void ShowErrorUI(gfx::NativeWindow parent_window); | 231 virtual void ShowErrorUI(gfx::NativeWindow parent_window); |
234 | 232 |
235 void ShowConfigure(gfx::NativeWindow parent_window); | 233 void ShowConfigure(gfx::NativeWindow parent_window); |
236 void PromptForExistingPassphrase(gfx::NativeWindow parent_window); | 234 void PromptForExistingPassphrase(gfx::NativeWindow parent_window); |
237 void SigninForPassphrase(TabContents* container); | 235 void SigninForPassphraseMigration(gfx::NativeWindow parent_window); |
238 void ShowPassphraseMigration(gfx::NativeWindow parent_window); | |
239 | 236 |
240 // Pretty-printed strings for a given StatusSummary. | 237 // Pretty-printed strings for a given StatusSummary. |
241 static std::string BuildSyncStatusSummaryText( | 238 static std::string BuildSyncStatusSummaryText( |
242 const browser_sync::SyncBackendHost::StatusSummary& summary); | 239 const browser_sync::SyncBackendHost::StatusSummary& summary); |
243 | 240 |
244 // Returns true if the SyncBackendHost has told us it's ready to accept | 241 // Returns true if the SyncBackendHost has told us it's ready to accept |
245 // changes. | 242 // changes. |
246 // [REMARK] - it is safe to call this function only from the ui thread. | 243 // [REMARK] - it is safe to call this function only from the ui thread. |
247 // because the variable is not thread safe and should only be accessed from | 244 // because the variable is not thread safe and should only be accessed from |
248 // single thread. If we want multiple threads to access this(and there is | 245 // single thread. If we want multiple threads to access this(and there is |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 browser_sync::ChangeProcessor* change_processor); | 330 browser_sync::ChangeProcessor* change_processor); |
334 virtual void DeactivateDataType( | 331 virtual void DeactivateDataType( |
335 browser_sync::DataTypeController* data_type_controller, | 332 browser_sync::DataTypeController* data_type_controller, |
336 browser_sync::ChangeProcessor* change_processor); | 333 browser_sync::ChangeProcessor* change_processor); |
337 | 334 |
338 // NotificationObserver implementation. | 335 // NotificationObserver implementation. |
339 virtual void Observe(NotificationType type, | 336 virtual void Observe(NotificationType type, |
340 const NotificationSource& source, | 337 const NotificationSource& source, |
341 const NotificationDetails& details); | 338 const NotificationDetails& details); |
342 | 339 |
343 // BrowserSignin::SigninDelegate interface. | |
344 virtual void OnLoginSuccess(); | |
345 virtual void OnLoginFailure(const GoogleServiceAuthError& error); | |
346 | |
347 // Changes which data types we're going to be syncing to |preferred_types|. | 340 // Changes which data types we're going to be syncing to |preferred_types|. |
348 // If it is running, the DataTypeManager will be instructed to reconfigure | 341 // If it is running, the DataTypeManager will be instructed to reconfigure |
349 // the sync backend so that exactly these datatypes are actively synced. See | 342 // the sync backend so that exactly these datatypes are actively synced. See |
350 // class comment for more on what it means for a datatype to be Preferred. | 343 // class comment for more on what it means for a datatype to be Preferred. |
351 virtual void ChangePreferredDataTypes( | 344 virtual void ChangePreferredDataTypes( |
352 const syncable::ModelTypeSet& preferred_types); | 345 const syncable::ModelTypeSet& preferred_types); |
353 | 346 |
354 // Get the set of currently enabled data types (as chosen or configured by | 347 // Get the set of currently enabled data types (as chosen or configured by |
355 // the user). See class comment for more on what it means for a datatype | 348 // the user). See class comment for more on what it means for a datatype |
356 // to be Preferred. | 349 // to be Preferred. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 bool tried_setting_explicit_passphrase_; | 439 bool tried_setting_explicit_passphrase_; |
447 | 440 |
448 // Whether we have seen a SYNC_PASSPHRASE_REQUIRED since initializing the | 441 // Whether we have seen a SYNC_PASSPHRASE_REQUIRED since initializing the |
449 // backend, telling us that it is safe to send a passphrase down ASAP. | 442 // backend, telling us that it is safe to send a passphrase down ASAP. |
450 bool observed_passphrase_required_; | 443 bool observed_passphrase_required_; |
451 | 444 |
452 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it | 445 // Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it |
453 // was required for decryption? | 446 // was required for decryption? |
454 bool passphrase_required_for_decryption_; | 447 bool passphrase_required_for_decryption_; |
455 | 448 |
| 449 // Is the user in a passphrase migration? |
| 450 bool passphrase_migration_in_progress_; |
| 451 |
456 private: | 452 private: |
457 friend class ProfileSyncServiceTest; | 453 friend class ProfileSyncServiceTest; |
458 friend class ProfileSyncServicePasswordTest; | 454 friend class ProfileSyncServicePasswordTest; |
459 friend class ProfileSyncServicePreferenceTest; | 455 friend class ProfileSyncServicePreferenceTest; |
460 friend class ProfileSyncServiceSessionTest; | 456 friend class ProfileSyncServiceSessionTest; |
461 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); | 457 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); |
462 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, | 458 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, |
463 UnrecoverableErrorSuspendsService); | 459 UnrecoverableErrorSuspendsService); |
464 | 460 |
465 // If |delete_sync_data_folder| is true, then this method will delete all | 461 // If |delete_sync_data_folder| is true, then this method will delete all |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 // and is necessary because the nudge sync framework can drop nudges for | 574 // and is necessary because the nudge sync framework can drop nudges for |
579 // a wide variety of sync-related conditions (throttling, connections issues, | 575 // a wide variety of sync-related conditions (throttling, connections issues, |
580 // syncer paused, etc.). It can only be removed correctly when the framework | 576 // syncer paused, etc.). It can only be removed correctly when the framework |
581 // is reworked to allow one-shot commands like clearing server data. | 577 // is reworked to allow one-shot commands like clearing server data. |
582 base::OneShotTimer<ProfileSyncService> clear_server_data_timer_; | 578 base::OneShotTimer<ProfileSyncService> clear_server_data_timer_; |
583 | 579 |
584 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 580 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
585 }; | 581 }; |
586 | 582 |
587 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 583 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |