OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 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 #include "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/sync/glue/session_data_type_controller.h" | 32 #include "chrome/browser/sync/glue/session_data_type_controller.h" |
33 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" | 33 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" |
34 #include "chrome/browser/sync/glue/data_type_manager.h" | 34 #include "chrome/browser/sync/glue/data_type_manager.h" |
35 #include "chrome/browser/sync/glue/session_data_type_controller.h" | 35 #include "chrome/browser/sync/glue/session_data_type_controller.h" |
36 #include "chrome/browser/sync/internal_api/configure_reason.h" | 36 #include "chrome/browser/sync/internal_api/configure_reason.h" |
37 #include "chrome/browser/sync/internal_api/sync_manager.h" | 37 #include "chrome/browser/sync/internal_api/sync_manager.h" |
38 #include "chrome/browser/sync/js/js_arg_list.h" | 38 #include "chrome/browser/sync/js/js_arg_list.h" |
39 #include "chrome/browser/sync/js/js_event_details.h" | 39 #include "chrome/browser/sync/js/js_event_details.h" |
40 #include "chrome/browser/sync/profile_sync_factory.h" | 40 #include "chrome/browser/sync/profile_sync_factory.h" |
41 #include "chrome/browser/sync/signin_manager.h" | 41 #include "chrome/browser/sync/signin_manager.h" |
| 42 #include "chrome/browser/sync/sync_global_error.h" |
42 #include "chrome/browser/sync/util/cryptographer.h" | 43 #include "chrome/browser/sync/util/cryptographer.h" |
43 #include "chrome/browser/sync/util/oauth.h" | 44 #include "chrome/browser/sync/util/oauth.h" |
44 #include "chrome/browser/ui/browser.h" | 45 #include "chrome/browser/ui/browser.h" |
45 #include "chrome/browser/ui/browser_list.h" | 46 #include "chrome/browser/ui/browser_list.h" |
46 #include "chrome/browser/ui/browser_window.h" | 47 #include "chrome/browser/ui/browser_window.h" |
| 48 #include "chrome/browser/ui/global_error_service.h" |
| 49 #include "chrome/browser/ui/global_error_service_factory.h" |
47 #include "chrome/common/chrome_notification_types.h" | 50 #include "chrome/common/chrome_notification_types.h" |
48 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/chrome_version_info.h" | 52 #include "chrome/common/chrome_version_info.h" |
50 #include "chrome/common/net/gaia/gaia_constants.h" | 53 #include "chrome/common/net/gaia/gaia_constants.h" |
51 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
52 #include "chrome/common/time_format.h" | 55 #include "chrome/common/time_format.h" |
53 #include "chrome/common/url_constants.h" | 56 #include "chrome/common/url_constants.h" |
54 #include "content/common/notification_details.h" | 57 #include "content/common/notification_details.h" |
55 #include "content/common/notification_source.h" | 58 #include "content/common/notification_source.h" |
56 #include "grit/generated_resources.h" | 59 #include "grit/generated_resources.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 443 |
441 last_synced_time_ = base::Time::FromInternalValue( | 444 last_synced_time_ = base::Time::FromInternalValue( |
442 profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); | 445 profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); |
443 | 446 |
444 CreateBackend(); | 447 CreateBackend(); |
445 | 448 |
446 // Initialize the backend. Every time we start up a new SyncBackendHost, | 449 // Initialize the backend. Every time we start up a new SyncBackendHost, |
447 // we'll want to start from a fresh SyncDB, so delete any old one that might | 450 // we'll want to start from a fresh SyncDB, so delete any old one that might |
448 // be there. | 451 // be there. |
449 InitializeBackend(!HasSyncSetupCompleted()); | 452 InitializeBackend(!HasSyncSetupCompleted()); |
| 453 |
| 454 if (!sync_global_error_.get()) { |
| 455 sync_global_error_.reset(new SyncGlobalError(this)); |
| 456 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
| 457 sync_global_error_.get()); |
| 458 AddObserver(sync_global_error_.get()); |
| 459 } |
450 } | 460 } |
451 | 461 |
452 void ProfileSyncService::Shutdown(bool sync_disabled) { | 462 void ProfileSyncService::Shutdown(bool sync_disabled) { |
453 // Stop all data type controllers, if needed. | 463 // Stop all data type controllers, if needed. |
454 if (data_type_manager_.get()) { | 464 if (data_type_manager_.get()) { |
455 if (data_type_manager_->state() != DataTypeManager::STOPPED) { | 465 if (data_type_manager_->state() != DataTypeManager::STOPPED) { |
456 data_type_manager_->Stop(); | 466 data_type_manager_->Stop(); |
457 } | 467 } |
458 | 468 |
459 registrar_.Remove(this, | 469 registrar_.Remove(this, |
(...skipping 23 matching lines...) Expand all Loading... |
483 | 493 |
484 // Clear various flags. | 494 // Clear various flags. |
485 expect_sync_configuration_aborted_ = false; | 495 expect_sync_configuration_aborted_ = false; |
486 is_auth_in_progress_ = false; | 496 is_auth_in_progress_ = false; |
487 backend_initialized_ = false; | 497 backend_initialized_ = false; |
488 cached_passphrases_ = CachedPassphrases(); | 498 cached_passphrases_ = CachedPassphrases(); |
489 encryption_pending_ = false; | 499 encryption_pending_ = false; |
490 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; | 500 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
491 last_attempted_user_email_.clear(); | 501 last_attempted_user_email_.clear(); |
492 last_auth_error_ = GoogleServiceAuthError::None(); | 502 last_auth_error_ = GoogleServiceAuthError::None(); |
| 503 |
| 504 if (sync_global_error_.get()) { |
| 505 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( |
| 506 sync_global_error_.get()); |
| 507 RemoveObserver(sync_global_error_.get()); |
| 508 sync_global_error_.reset(NULL); |
| 509 } |
493 } | 510 } |
494 | 511 |
495 void ProfileSyncService::ClearServerData() { | 512 void ProfileSyncService::ClearServerData() { |
496 clear_server_data_state_ = CLEAR_CLEARING; | 513 clear_server_data_state_ = CLEAR_CLEARING; |
497 clear_server_data_timer_.Start(FROM_HERE, | 514 clear_server_data_timer_.Start(FROM_HERE, |
498 base::TimeDelta::FromSeconds(kSyncClearDataTimeoutInSeconds), this, | 515 base::TimeDelta::FromSeconds(kSyncClearDataTimeoutInSeconds), this, |
499 &ProfileSyncService::OnClearServerDataTimeout); | 516 &ProfileSyncService::OnClearServerDataTimeout); |
500 backend_->RequestClearServerData(); | 517 backend_->RequestClearServerData(); |
501 } | 518 } |
502 | 519 |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 syncable::ModelTypeBitSetFromValue( | 1643 syncable::ModelTypeBitSetFromValue( |
1627 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1644 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
1628 syncable::ModelTypeSet registered; | 1645 syncable::ModelTypeSet registered; |
1629 GetRegisteredDataTypes(®istered); | 1646 GetRegisteredDataTypes(®istered); |
1630 syncable::ModelTypeBitSet registered_bit_set = | 1647 syncable::ModelTypeBitSet registered_bit_set = |
1631 syncable::ModelTypeBitSetFromSet(registered); | 1648 syncable::ModelTypeBitSetFromSet(registered); |
1632 unacknowledged = registered_bit_set & ~acknowledged; | 1649 unacknowledged = registered_bit_set & ~acknowledged; |
1633 } | 1650 } |
1634 return unacknowledged; | 1651 return unacknowledged; |
1635 } | 1652 } |
OLD | NEW |