diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-04 20:29:19 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-04 20:29:19 +0000 |
commit | 8acfa0427d4a27763b8cf63a846e55b75e9073d9 (patch) | |
tree | 8365eacdb3c2c94b0f482ddcc55fb750df6e6dca | |
parent | 2751680b75378284da24b09bcba9ef05d4ea7957 (diff) | |
download | chromium_src-8acfa0427d4a27763b8cf63a846e55b75e9073d9.zip chromium_src-8acfa0427d4a27763b8cf63a846e55b75e9073d9.tar.gz chromium_src-8acfa0427d4a27763b8cf63a846e55b75e9073d9.tar.bz2 |
Sync Promo: Remember promo expanded state
With this change we save the expanded/collapsed state of the sync promo to preferences.
BUG=
TEST=Collapsed the promo and verified that it stayed collapsed on the next launch.
Review URL: http://codereview.chromium.org/7566026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95478 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/profiles/profile.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc | 14 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
5 files changed, 25 insertions, 1 deletions
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index 2867fcf..f83cbd7 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -188,6 +188,10 @@ void Profile::RegisterUserPrefs(PrefService* prefs) { "", PrefService::UNSYNCABLE_PREF); #endif + + prefs->RegisterBooleanPref(prefs::kSyncPromoExpanded, + true, + PrefService::UNSYNCABLE_PREF); } // static diff --git a/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc index 1036241..ba21e55 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.cc @@ -82,17 +82,23 @@ void NewTabSyncSetupHandler::HandleInitializeSyncPromo(const ListValue* args) { // If the user has not signed into sync then expand the sync promo. // TODO(sail): Need to throttle this behind a server side flag. - if (!service->HasSyncSetupCompleted()) + if (!service->HasSyncSetupCompleted() && + web_ui_->GetProfile()->GetPrefs()->GetBoolean( + prefs::kSyncPromoExpanded)) { OpenSyncSetup(); + SaveExpandedPreference(true); + } } void NewTabSyncSetupHandler::HandleCollapseSyncPromo(const ListValue* args) { CloseSyncSetup(); + SaveExpandedPreference(false); } void NewTabSyncSetupHandler::HandleExpandSyncPromo(const ListValue* args) { OpenSyncSetup(); + SaveExpandedPreference(true); } void NewTabSyncSetupHandler::UpdateLogin() { @@ -102,3 +108,9 @@ void NewTabSyncSetupHandler::UpdateLogin() { web_ui_->CallJavascriptFunction("new_tab.NewTabSyncPromo.updateLogin", string_value); } + +void NewTabSyncSetupHandler::SaveExpandedPreference(bool is_expanded) { + web_ui_->GetProfile()->GetPrefs()->SetBoolean(prefs::kSyncPromoExpanded, + is_expanded); + web_ui_->GetProfile()->GetPrefs()->ScheduleSavePersistentPrefs(); +} diff --git a/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h b/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h index 5275f14..5c7c7e1 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h +++ b/chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h @@ -43,6 +43,9 @@ class NewTabSyncSetupHandler : public SyncSetupHandler { // Sends the sync login name to the page. void UpdateLogin(); + // Saves the expanded state to preferences. + void SaveExpandedPreference(bool is_expanded); + // Preference for the sync login name. StringPrefMember username_pref_; }; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 126d0ce..573c735 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -40,6 +40,10 @@ const char kRestoreOnStartup[] = "session.restore_on_startup"; // are only restored on startup if kRestoreOnStartup is 4. const char kURLsToRestoreOnStartup[] = "session.urls_to_restore_on_startup"; +// A bool pref to used to determine if the sync promo should be expanded or +// collapsed. +const char kSyncPromoExpanded[] = "profile.sync_promo_expanded"; + // The application locale. // For OS_CHROMEOS we maintain kApplicationLocale property in both local state // and user's profile. Global property determines locale of login screen, diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 6da18fc..3d008e4 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -20,6 +20,7 @@ extern const char kHomePage[]; extern const char kSessionExitedCleanly[]; extern const char kRestoreOnStartup[]; extern const char kURLsToRestoreOnStartup[]; +extern const char kSyncPromoExpanded[]; // For OS_CHROMEOS we maintain kApplicationLocale property in both local state // and user's profile. Global property determines locale of login screen, |