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

Unified Diff: chrome/browser/ui/browser_ui_prefs.cc

Issue 511393003: No longer register app window placement preference keys on the fly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 3 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/browser_ui_prefs.cc
diff --git a/chrome/browser/ui/browser_ui_prefs.cc b/chrome/browser/ui/browser_ui_prefs.cc
index 68215e479040a57a669fa2aa32a73b8d65eb87a7..f188731707123faaacb5e4f2a2141804d2c54240 100644
--- a/chrome/browser/ui/browser_ui_prefs.cc
+++ b/chrome/browser/ui/browser_ui_prefs.cc
@@ -6,6 +6,8 @@
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
+#include "base/prefs/scoped_user_pref_update.h"
+#include "base/strings/string_util.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
@@ -14,6 +16,36 @@
namespace chrome {
+void MigrateBrowserUIUserPrefs(PrefService* prefs) {
+ scoped_ptr<base::DictionaryValue> browser_dict =
+ prefs->GetBrowserDictionary();
gab 2014/09/05 00:53:10 I'm torn here, you could do this without requiring
dgrogan 2014/09/06 00:47:06 I moved the migration to work off a PrefStoreObser
+ if (!browser_dict)
+ return;
+
+ DictionaryPrefUpdate update(prefs, prefs::kAppWindowPlacement);
+ const std::string search_for =
+ std::string(prefs::kBrowserWindowPlacement) + "_";
+ for (base::DictionaryValue::Iterator it(*browser_dict); !it.IsAtEnd();
+ it.Advance()) {
+ std::string full_key("browser." + it.key());
+ if (StartsWithASCII(full_key, search_for, true /* case_sensitive */)) {
+ if (full_key == prefs::kBrowserWindowPlacementPopup)
+ continue;
+ std::string new_key(full_key);
+ ReplaceFirstSubstringAfterOffset(&new_key, 0, search_for, "");
gab 2014/09/05 00:53:10 |new_key| (which is equal to |full_key| at this po
dgrogan 2014/09/06 00:47:06 Done.
+ update->Set(new_key, it.value().DeepCopy());
+
+ user_prefs::PrefRegistrySyncable* registry =
+ static_cast<user_prefs::PrefRegistrySyncable*>(
+ prefs->DeprecatedGetPrefRegistry());
+ registry->RegisterDictionaryPref(
+ full_key.c_str(),
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ prefs->ClearPref(full_key.c_str());
+ }
+ }
+}
+
void RegisterBrowserPrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0);
registry->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true);
@@ -125,6 +157,9 @@ void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(
prefs::kBrowserWindowPlacementPopup,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ registry->RegisterDictionaryPref(
+ prefs::kAppWindowPlacement,
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kImportBookmarks,
true,
@@ -184,24 +219,4 @@ void RegisterBrowserUserPrefs(user_prefs::PrefRegistrySyncable* registry) {
#endif
}
-void RegisterAppPrefs(const std::string& app_name, Profile* profile) {
- // We need to register the window position pref.
- //
- // TODO(mnissler): Use a separate pref name pointing to a single
- // dictionary instead. Also tracked as http://crbug.com/167256
- std::string window_pref(prefs::kBrowserWindowPlacement);
- window_pref.append("_");
- window_pref.append(app_name);
- PrefService* prefs = profile->GetPrefs();
- if (!prefs->FindPreference(window_pref.c_str())) {
- // TODO(joi): Do all registration up front.
- scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
- static_cast<user_prefs::PrefRegistrySyncable*>(
- prefs->DeprecatedGetPrefRegistry()));
- registry->RegisterDictionaryPref(
- window_pref.c_str(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
- }
-}
-
-
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698