| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/translate/core/browser/translate_prefs.h" | 5 #include "components/translate/core/browser/translate_prefs.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "components/pref_registry/pref_registry_syncable.h" | 14 #include "components/pref_registry/pref_registry_syncable.h" |
| 15 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 16 #include "components/prefs/scoped_user_pref_update.h" | 16 #include "components/prefs/scoped_user_pref_update.h" |
| 17 #include "components/translate/core/browser/translate_accept_languages.h" | 17 #include "components/translate/core/browser/translate_accept_languages.h" |
| 18 #include "components/translate/core/browser/translate_download_manager.h" | 18 #include "components/translate/core/browser/translate_download_manager.h" |
| 19 #include "components/translate/core/browser/translate_experiment.h" | 19 #include "components/translate/core/browser/translate_experiment.h" |
| 20 #include "components/translate/core/browser/translate_pref_names.h" |
| 20 #include "components/translate/core/common/translate_util.h" | 21 #include "components/translate/core/common/translate_util.h" |
| 21 | 22 |
| 22 namespace translate { | 23 namespace translate { |
| 23 | 24 |
| 24 const char TranslatePrefs::kPrefLanguageProfile[] = "language_profile"; | 25 const char TranslatePrefs::kPrefLanguageProfile[] = "language_profile"; |
| 25 const char TranslatePrefs::kPrefTranslateSiteBlacklist[] = | 26 const char TranslatePrefs::kPrefTranslateSiteBlacklist[] = |
| 26 "translate_site_blacklist"; | 27 "translate_site_blacklist"; |
| 27 const char TranslatePrefs::kPrefTranslateWhitelists[] = "translate_whitelists"; | 28 const char TranslatePrefs::kPrefTranslateWhitelists[] = "translate_whitelists"; |
| 28 const char TranslatePrefs::kPrefTranslateDeniedCount[] = | 29 const char TranslatePrefs::kPrefTranslateDeniedCount[] = |
| 29 "translate_denied_count_for_language"; | 30 "translate_denied_count_for_language"; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const char* accept_languages_pref, | 154 const char* accept_languages_pref, |
| 154 const char* preferred_languages_pref) | 155 const char* preferred_languages_pref) |
| 155 : accept_languages_pref_(accept_languages_pref), prefs_(user_prefs) { | 156 : accept_languages_pref_(accept_languages_pref), prefs_(user_prefs) { |
| 156 #if defined(OS_CHROMEOS) | 157 #if defined(OS_CHROMEOS) |
| 157 preferred_languages_pref_ = preferred_languages_pref; | 158 preferred_languages_pref_ = preferred_languages_pref; |
| 158 #else | 159 #else |
| 159 DCHECK(!preferred_languages_pref); | 160 DCHECK(!preferred_languages_pref); |
| 160 #endif | 161 #endif |
| 161 } | 162 } |
| 162 | 163 |
| 164 bool TranslatePrefs::IsEnabled() const { |
| 165 return prefs_->GetBoolean(prefs::kEnableTranslate); |
| 166 } |
| 167 |
| 163 void TranslatePrefs::SetCountry(const std::string& country) { | 168 void TranslatePrefs::SetCountry(const std::string& country) { |
| 164 country_ = country; | 169 country_ = country; |
| 165 } | 170 } |
| 166 | 171 |
| 167 std::string TranslatePrefs::GetCountry() const { | 172 std::string TranslatePrefs::GetCountry() const { |
| 168 return country_; | 173 return country_; |
| 169 } | 174 } |
| 170 | 175 |
| 171 void TranslatePrefs::ResetToDefaults() { | 176 void TranslatePrefs::ResetToDefaults() { |
| 172 ClearBlockedLanguages(); | 177 ClearBlockedLanguages(); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 out_value->push_back(it); | 636 out_value->push_back(it); |
| 632 std::sort(out_value->begin(), out_value->end(), | 637 std::sort(out_value->begin(), out_value->end(), |
| 633 [](const LanguageAndProbability& left, | 638 [](const LanguageAndProbability& left, |
| 634 const LanguageAndProbability& right) { | 639 const LanguageAndProbability& right) { |
| 635 return left.second > right.second; | 640 return left.second > right.second; |
| 636 }); | 641 }); |
| 637 return confidence; | 642 return confidence; |
| 638 } | 643 } |
| 639 | 644 |
| 640 } // namespace translate | 645 } // namespace translate |
| OLD | NEW |