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

Unified Diff: chrome/browser/translate/translate_prefs.cc

Issue 18114010: Bug fix: Merging language sets to create 'translate_blocked_languages' may be evaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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/translate/translate_prefs.cc
diff --git a/chrome/browser/translate/translate_prefs.cc b/chrome/browser/translate/translate_prefs.cc
index 11c2f49547f9d99d8cd294a639715503f6f28515..8ec9736ee8d82300cf31518062b42bf20d22ba3b 100644
--- a/chrome/browser/translate/translate_prefs.cc
+++ b/chrome/browser/translate/translate_prefs.cc
@@ -324,22 +324,23 @@ void TranslatePrefs::MigrateUserPrefs(PrefService* user_prefs) {
// keep auto-translated.
DictionaryPrefUpdate update(user_prefs, kPrefTranslateWhitelists);
DictionaryValue* dict = update.Get();
- if (!dict || dict->empty())
- return;
- DictionaryValue::Iterator iter(*dict);
- while (!iter.IsAtEnd()) {
- const ListValue* list = NULL;
- if (!iter.value().GetAsList(&list) || !list)
- break; // Dictionary has either been migrated or new format.
- std::string key = iter.key();
- // Advance the iterator before removing the current element.
- iter.Advance();
- std::string target_lang;
- if (list->empty() || !list->GetString(list->GetSize() - 1, &target_lang) ||
- target_lang.empty()) {
- dict->Remove(key, NULL);
- } else {
- dict->SetString(key, target_lang);
+ if (dict && !dict->empty()) {
+ DictionaryValue::Iterator iter(*dict);
+ while (!iter.IsAtEnd()) {
+ const ListValue* list = NULL;
+ if (!iter.value().GetAsList(&list) || !list)
+ break; // Dictionary has either been migrated or new format.
+ std::string key = iter.key();
+ // Advance the iterator before removing the current element.
+ iter.Advance();
+ std::string target_lang;
+ if (list->empty() ||
+ !list->GetString(list->GetSize() - 1, &target_lang) ||
+ target_lang.empty()) {
+ dict->Remove(key, NULL);
+ } else {
+ dict->SetString(key, target_lang);
+ }
}
}
« 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