Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Unified Diff: chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc

Issue 10055003: Keep emtpy List/Dictionary pref value with non-empty default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
index 0eb6e30bcbcbfceac7299b682d873869aa836de6..81c0eeb05f382a44ed007598e0e08b249d130a7c 100644
--- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
+++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc
@@ -140,19 +140,31 @@ ChromeLauncherDelegate::~ChromeLauncherDelegate() {
}
void ChromeLauncherDelegate::Init() {
- const base::ListValue* pinned_apps =
- profile_->GetPrefs()->GetList(prefs::kPinnedLauncherApps);
-
- // Use default pinned apps only when current pinned apps list is empty and
- // kUseDefaultPinnedApps is true.
- // TODO(xiyuan): Remove this after http://crbug.com/122679 is resolved.
- scoped_ptr<base::ListValue> default_pinned_apps;
- if (pinned_apps->empty() &&
- profile_->GetPrefs()->GetBoolean(prefs::kUseDefaultPinnedApps)) {
- default_pinned_apps.reset(CreateDefaultPinnedAppsList());
- pinned_apps = default_pinned_apps.get();
+ // TODO(xiyuan): Remove migration code and kUseDefaultPinnedApp after M20.
+ // Migration cases:
+ // - Users that unpin all apps:
+ // - have default pinned apps
+ // - kUseDefaultPinnedApps set to false
+ // Migrate them by setting an empty list for kPinnedLauncherApps.
+ //
+ // - Users that have customized pinned apps:
+ // - have non-default non-empty pinned apps list
+ // - kUseDefaultPinnedApps set to false
+ // Nothing needs to be done because customized pref overrides default.
+ //
+ // - Users that have default apps (i.e. new user or never pin/unpin):
+ // - have default pinned apps
+ // - kUseDefaultPinnedApps is still true
+ // Nothing needs to be done because they should get the default.
+ if (profile_->GetPrefs()->FindPreference(
+ prefs::kPinnedLauncherApps)->IsDefaultValue() &&
+ !profile_->GetPrefs()->GetBoolean(prefs::kUseDefaultPinnedApps)) {
+ ListPrefUpdate updater(profile_->GetPrefs(), prefs::kPinnedLauncherApps);
+ updater.Get()->Clear();
}
+ const base::ListValue* pinned_apps =
+ profile_->GetPrefs()->GetList(prefs::kPinnedLauncherApps);
for (size_t i = 0; i < pinned_apps->GetSize(); ++i) {
DictionaryValue* app = NULL;
if (pinned_apps->GetDictionary(i, &app)) {
@@ -201,6 +213,7 @@ void ChromeLauncherDelegate::RegisterUserPrefs(PrefService* user_prefs) {
true,
PrefService::SYNCABLE_PREF);
user_prefs->RegisterListPref(prefs::kPinnedLauncherApps,
+ CreateDefaultPinnedAppsList(),
PrefService::SYNCABLE_PREF);
user_prefs->RegisterStringPref(prefs::kShelfAutoHideBehavior,
kShelfAutoHideBehaviorDefault,

Powered by Google App Engine
This is Rietveld 408576698