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 | |
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
-rw-r--r-- | chrome/browser/sync/profile_sync_service.cc | 17 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service_startup_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
4 files changed, 28 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(); +} diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 7c9ca69..4037af9 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -664,6 +664,9 @@ const wchar_t kSyncLastSyncedTime[] = L"sync.last_synced_time"; // Boolean specifying whether the user finished setting up sync. const wchar_t kSyncHasSetupCompleted[] = L"sync.has_setup_completed"; +// Whether sync auth was bootstrapped for Chrome OS. +const wchar_t kSyncBootstrappedAuth[] = L"sync.bootstrapped_auth"; + // Create web application shortcut dialog preferences. const wchar_t kWebAppCreateOnDesktop[] = L"browser.web_app.create_on_desktop"; const wchar_t kWebAppCreateInAppsMenu[] = diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 5659995..5b23bb4 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -244,6 +244,7 @@ extern const wchar_t kDevToolsSplitLocation[]; extern const wchar_t kSyncLastSyncedTime[]; extern const wchar_t kSyncHasSetupCompleted[]; +extern const wchar_t kSyncBootstrappedAuth[]; extern const wchar_t kWebAppCreateOnDesktop[]; extern const wchar_t kWebAppCreateInAppsMenu[]; |