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

Side by Side Diff: chrome/browser/translate/translate_prefs.cc

Issue 14622003: components: Move PrefRegistrySyncable into user_prefs namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/translate/translate_prefs.h" 5 #include "chrome/browser/translate/translate_prefs.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" 9 #include "chrome/browser/prefs/scoped_user_pref_update.h"
10 #include "components/user_prefs/pref_registry_syncable.h" 10 #include "components/user_prefs/pref_registry_syncable.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return false; 167 return false;
168 return (!prefs.IsLanguageBlacklisted(original_language)); 168 return (!prefs.IsLanguageBlacklisted(original_language));
169 } 169 }
170 170
171 bool TranslatePrefs::ShouldAutoTranslate(PrefService* user_prefs, 171 bool TranslatePrefs::ShouldAutoTranslate(PrefService* user_prefs,
172 const std::string& original_language, std::string* target_language) { 172 const std::string& original_language, std::string* target_language) {
173 TranslatePrefs prefs(user_prefs); 173 TranslatePrefs prefs(user_prefs);
174 return prefs.IsLanguageWhitelisted(original_language, target_language); 174 return prefs.IsLanguageWhitelisted(original_language, target_language);
175 } 175 }
176 176
177 void TranslatePrefs::RegisterUserPrefs(PrefRegistrySyncable* registry) { 177 void TranslatePrefs::RegisterUserPrefs(
178 user_prefs::PrefRegistrySyncable* registry) {
178 registry->RegisterListPref(kPrefTranslateLanguageBlacklist, 179 registry->RegisterListPref(kPrefTranslateLanguageBlacklist,
179 PrefRegistrySyncable::SYNCABLE_PREF); 180 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
180 registry->RegisterListPref(kPrefTranslateSiteBlacklist, 181 registry->RegisterListPref(kPrefTranslateSiteBlacklist,
181 PrefRegistrySyncable::SYNCABLE_PREF); 182 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
182 registry->RegisterDictionaryPref(kPrefTranslateWhitelists, 183 registry->RegisterDictionaryPref(
183 PrefRegistrySyncable::SYNCABLE_PREF); 184 kPrefTranslateWhitelists,
184 registry->RegisterDictionaryPref(kPrefTranslateDeniedCount, 185 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
185 PrefRegistrySyncable::SYNCABLE_PREF); 186 registry->RegisterDictionaryPref(
186 registry->RegisterDictionaryPref(kPrefTranslateAcceptedCount, 187 kPrefTranslateDeniedCount,
187 PrefRegistrySyncable::SYNCABLE_PREF); 188 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
189 registry->RegisterDictionaryPref(
190 kPrefTranslateAcceptedCount,
191 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
188 } 192 }
189 193
190 void TranslatePrefs::MigrateUserPrefs(PrefService* user_prefs) { 194 void TranslatePrefs::MigrateUserPrefs(PrefService* user_prefs) {
191 // Old format of kPrefTranslateWhitelists 195 // Old format of kPrefTranslateWhitelists
192 // - original language -> list of target langs to auto-translate 196 // - original language -> list of target langs to auto-translate
193 // - list of langs is in order of being enabled i.e. last in list is the 197 // - list of langs is in order of being enabled i.e. last in list is the
194 // most recent language that user enabled via 198 // most recent language that user enabled via
195 // Always translate |source_lang| to |target_lang|" 199 // Always translate |source_lang| to |target_lang|"
196 // - this results in a one-to-n relationship between source lang and target 200 // - this results in a one-to-n relationship between source lang and target
197 // langs. 201 // langs.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 285
282 bool TranslatePrefs::IsListEmpty(const char* pref_id) const { 286 bool TranslatePrefs::IsListEmpty(const char* pref_id) const {
283 const ListValue* blacklist = prefs_->GetList(pref_id); 287 const ListValue* blacklist = prefs_->GetList(pref_id);
284 return (blacklist == NULL || blacklist->empty()); 288 return (blacklist == NULL || blacklist->empty());
285 } 289 }
286 290
287 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { 291 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const {
288 const DictionaryValue* dict = prefs_->GetDictionary(pref_id); 292 const DictionaryValue* dict = prefs_->GetDictionary(pref_id);
289 return (dict == NULL || dict->empty()); 293 return (dict == NULL || dict->empty());
290 } 294 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_prefs.h ('k') | chrome/browser/ui/alternate_error_tab_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698