diff options
author | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 18:51:46 +0000 |
---|---|---|
committer | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 18:51:46 +0000 |
commit | 2dac19b5d381ed5230fe0bc3f96b6476b1150ddd (patch) | |
tree | bdb64c5b2b488ea639b9866e598bc5a148f5236d /chrome/browser/sync | |
parent | 53b9c0d8a7ddcfc0cce954ea081e667fc9678a68 (diff) | |
download | chromium_src-2dac19b5d381ed5230fe0bc3f96b6476b1150ddd.zip chromium_src-2dac19b5d381ed5230fe0bc3f96b6476b1150ddd.tar.gz chromium_src-2dac19b5d381ed5230fe0bc3f96b6476b1150ddd.tar.bz2 |
Under Chromium OS, keep track of whether sync auth has been bootstrapped
already to avoid re-enabling sync everytime the machine boots.
BUG=37164
TEST=unit test
Review URL: http://codereview.chromium.org/669099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/profile_sync_service.cc | 17 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service_startup_unittest.cc | 10 |
2 files changed, 24 insertions, 3 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index fc0ddba..bffb833 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -72,8 +72,14 @@ void ProfileSyncService::Initialize() { // If the LSID is empty, we're in a UI test that is not testing sync // behavior, so we don't want the sync service to start. if (bootstrap_sync_authentication_ && - !GetLsidForAuthBootstraping().empty()) - StartUp(); // We always start sync for Chromium OS. + !profile()->GetPrefs()->GetBoolean(prefs::kSyncBootstrappedAuth) && + !GetLsidForAuthBootstraping().empty()) { + // If we're under Chromium OS and have never bootstrapped the + // authentication (ie. this is the first time we start sync for this + // profile,) then bootstrap it. + StartUp(); + profile()->GetPrefs()->SetBoolean(prefs::kSyncBootstrappedAuth, true); + } } else { StartUp(); } @@ -120,13 +126,18 @@ void ProfileSyncService::RegisterPreferences() { return; pref_service->RegisterInt64Pref(prefs::kSyncLastSyncedTime, 0); pref_service->RegisterBooleanPref(prefs::kSyncHasSetupCompleted, false); + + // TODO(albertb): Consider getting rid of this preference once we have a UI + // for per-data type disabling. + if (bootstrap_sync_authentication_ && + !pref_service->FindPreference(prefs::kSyncBootstrappedAuth)) + pref_service->RegisterBooleanPref(prefs::kSyncBootstrappedAuth, false); } void ProfileSyncService::ClearPreferences() { PrefService* pref_service = profile_->GetPrefs(); pref_service->ClearPref(prefs::kSyncLastSyncedTime); pref_service->ClearPref(prefs::kSyncHasSetupCompleted); - pref_service->ScheduleSavePersistentPrefs(); } diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index 851f9b9..5be62fc 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc @@ -152,3 +152,13 @@ TEST_F(ProfileSyncServiceStartupBootstrapTest, SKIP_MACOSX(StartFirstTime)) { // setup is bypassed when bootstrapping is enabled). service_->Initialize(); } + +TEST_F(ProfileSyncServiceStartupBootstrapTest, SKIP_MACOSX(StartUserDisabled)) { + EXPECT_CALL(observer_, OnStateChanged()).Times(1); + + profile_.GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); + profile_.GetPrefs()->SetBoolean(prefs::kSyncBootstrappedAuth, true); + // Will not start sync because it is currently disabled, but was bootstrapped + // before. + service_->Initialize(); +} |