Chromium Code Reviews| 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 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ |
| 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ | 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 std::string language_; | 71 std::string language_; |
| 72 size_t max_denial_count_; | 72 size_t max_denial_count_; |
| 73 base::ListValue* time_list_; // Weak, owned by the containing prefs service. | 73 base::ListValue* time_list_; // Weak, owned by the containing prefs service. |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // The wrapper of PrefService object for Translate. | 76 // The wrapper of PrefService object for Translate. |
| 77 // | 77 // |
| 78 // It is assumed that |prefs_| is alive while this instance is alive. | 78 // It is assumed that |prefs_| is alive while this instance is alive. |
| 79 class TranslatePrefs { | 79 class TranslatePrefs { |
| 80 public: | 80 public: |
| 81 static const char kPrefLanguageProfile[]; | |
| 81 static const char kPrefTranslateSiteBlacklist[]; | 82 static const char kPrefTranslateSiteBlacklist[]; |
| 82 static const char kPrefTranslateWhitelists[]; | 83 static const char kPrefTranslateWhitelists[]; |
| 83 static const char kPrefTranslateDeniedCount[]; | 84 static const char kPrefTranslateDeniedCount[]; |
| 84 static const char kPrefTranslateIgnoredCount[]; | 85 static const char kPrefTranslateIgnoredCount[]; |
| 85 static const char kPrefTranslateAcceptedCount[]; | 86 static const char kPrefTranslateAcceptedCount[]; |
| 86 static const char kPrefTranslateBlockedLanguages[]; | 87 static const char kPrefTranslateBlockedLanguages[]; |
| 87 static const char kPrefTranslateLastDeniedTimeForLanguage[]; | 88 static const char kPrefTranslateLastDeniedTimeForLanguage[]; |
| 88 static const char kPrefTranslateTooOftenDeniedForLanguage[]; | 89 static const char kPrefTranslateTooOftenDeniedForLanguage[]; |
| 89 | 90 |
| 90 // |preferred_languages_pref| is only used on Chrome OS, other platforms must | 91 // |preferred_languages_pref| is only used on Chrome OS, other platforms must |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 void GetLanguageList(std::vector<std::string>* languages) const; | 159 void GetLanguageList(std::vector<std::string>* languages) const; |
| 159 | 160 |
| 160 // Updates the language list of the language settings. | 161 // Updates the language list of the language settings. |
| 161 void UpdateLanguageList(const std::vector<std::string>& languages); | 162 void UpdateLanguageList(const std::vector<std::string>& languages); |
| 162 | 163 |
| 163 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, | 164 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, |
| 164 const std::string& language); | 165 const std::string& language); |
| 165 bool ShouldAutoTranslate(const std::string& original_language, | 166 bool ShouldAutoTranslate(const std::string& original_language, |
| 166 std::string* target_language); | 167 std::string* target_language); |
| 167 | 168 |
| 169 // Language and probability pair. | |
| 170 typedef std::pair<std::string, double> LanguageAndProbability; | |
|
Lei Zhang
2016/11/17 07:03:28
nit: using LanguageAndProbability = std::pair... i
| |
| 171 typedef std::vector<LanguageAndProbability> LanguageAndProbabilityList; | |
| 172 | |
| 173 // Output the User Profile Profile's (ULP) "reading list" into |list| as | |
| 174 // ordered list of <string, double> pair, sorted by the double in decreasing | |
| 175 // order. Return the confidence of the list or 0.0 if there no ULP "reading | |
| 176 // list". | |
| 177 double GetReadingFromUserLanguageProfile( | |
| 178 LanguageAndProbabilityList* list) const; | |
| 179 | |
| 168 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 180 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 169 static void MigrateUserPrefs(PrefService* user_prefs, | 181 static void MigrateUserPrefs(PrefService* user_prefs, |
| 170 const char* accept_languages_pref); | 182 const char* accept_languages_pref); |
| 171 | 183 |
| 172 private: | 184 private: |
| 173 friend class TranslatePrefsTest; | 185 friend class TranslatePrefsTest; |
| 174 | 186 |
| 175 // Merges two language sets to migrate to the language setting UI. | 187 // Merges two language sets to migrate to the language setting UI. |
| 176 static void CreateBlockedLanguages( | 188 static void CreateBlockedLanguages( |
| 177 std::vector<std::string>* blocked_languages, | 189 std::vector<std::string>* blocked_languages, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 208 PrefService* prefs_; // Weak. | 220 PrefService* prefs_; // Weak. |
| 209 | 221 |
| 210 std::string country_; // The country the app runs in. | 222 std::string country_; // The country the app runs in. |
| 211 | 223 |
| 212 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); | 224 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); |
| 213 }; | 225 }; |
| 214 | 226 |
| 215 } // namespace translate | 227 } // namespace translate |
| 216 | 228 |
| 217 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ | 229 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ |
| OLD | NEW |