| OLD | NEW |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool TranslatePrefs::HasBlacklistedLanguages() const { | 92 bool TranslatePrefs::HasBlacklistedLanguages() const { |
| 93 return !IsListEmpty(kPrefTranslateLanguageBlacklist); | 93 return !IsListEmpty(kPrefTranslateLanguageBlacklist); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TranslatePrefs::ClearBlacklistedLanguages() { | 96 void TranslatePrefs::ClearBlacklistedLanguages() { |
| 97 prefs_->ClearPref(kPrefTranslateLanguageBlacklist); | 97 prefs_->ClearPref(kPrefTranslateLanguageBlacklist); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool TranslatePrefs::HasBlacklistedSites() { | 100 bool TranslatePrefs::HasBlacklistedSites() const { |
| 101 return !IsListEmpty(kPrefTranslateSiteBlacklist); | 101 return !IsListEmpty(kPrefTranslateSiteBlacklist); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void TranslatePrefs::ClearBlacklistedSites() { | 104 void TranslatePrefs::ClearBlacklistedSites() { |
| 105 prefs_->ClearPref(kPrefTranslateSiteBlacklist); | 105 prefs_->ClearPref(kPrefTranslateSiteBlacklist); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool TranslatePrefs::HasWhitelistedLanguagePairs() const { | 108 bool TranslatePrefs::HasWhitelistedLanguagePairs() const { |
| 109 return !IsDictionaryEmpty(kPrefTranslateWhitelists); | 109 return !IsDictionaryEmpty(kPrefTranslateWhitelists); |
| 110 } | 110 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 bool TranslatePrefs::IsListEmpty(const char* pref_id) const { | 282 bool TranslatePrefs::IsListEmpty(const char* pref_id) const { |
| 283 const ListValue* blacklist = prefs_->GetList(pref_id); | 283 const ListValue* blacklist = prefs_->GetList(pref_id); |
| 284 return (blacklist == NULL || blacklist->empty()); | 284 return (blacklist == NULL || blacklist->empty()); |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { | 287 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { |
| 288 const DictionaryValue* dict = prefs_->GetDictionary(pref_id); | 288 const DictionaryValue* dict = prefs_->GetDictionary(pref_id); |
| 289 return (dict == NULL || dict->empty()); | 289 return (dict == NULL || dict->empty()); |
| 290 } | 290 } |
| OLD | NEW |