Bug fix: Merging language sets to create 'translate_blocked_languages' may be evaded

Because of the 'return' sentence in the previous migrating, the merging process may have been evaded.

BUG=253794
TEST=unit_tests

Review URL: https://chromiumcodereview.appspot.com/18114010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209331 0039d316-1c4b-4281-b951-d872f2087c98
parent 6704f1f8
......@@ -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);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment