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

Unified Diff: chrome/browser/chromeos/preferences.cc

Issue 7670022: Automatically remove invalid virtual keyboard prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/preferences.cc
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 40571d83f037327d1ba6e7eac6b9cd59882376af..2359c1a189e2035a254e7f8953a0f12448d6a81f 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/chromeos/system/touchpad_settings.h"
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/common/notification_details.h"
@@ -575,13 +576,27 @@ void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) {
input_method_manager->ClearAllVirtualKeyboardPreferences();
std::string url;
+ std::vector<std::string> layouts_to_remove;
for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys();
iter != virtual_keyboard_pref->end_keys();
++iter) {
- const std::string& xkb_layout = *iter;
- if (!virtual_keyboard_pref->GetString(xkb_layout, &url))
+ const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk"
+ if (!virtual_keyboard_pref->GetString(layout_id, &url))
continue;
- input_method_manager->SetVirtualKeyboardPreference(xkb_layout, GURL(url));
+ if (!input_method_manager->SetVirtualKeyboardPreference(
+ layout_id, GURL(url))) {
+ // Either |layout_id| or |url| is invalid. Remove the key from |prefs|
+ // later.
+ layouts_to_remove.push_back(layout_id);
+ LOG(ERROR) << "Removing invalid virtual keyboard pref: layout=" << layout;
+ }
+ }
+
+ // Remove invalid prefs.
+ DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard);
+ DictionaryValue* pref_value = updater.Get();
+ for (size_t i = 0; i < layouts_to_remove.size(); ++i) {
+ pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698