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; | |
| 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. Return the confidence of the list | |
|
groby-ooo-7-16
2016/08/04 02:33:43
What is the list ordered by? I assume the double?
ftang
2016/08/05 04:45:28
Done.
| |
| 175 // or 0.0 if there no ULP "reading list". | |
| 176 virtual double GetReadingFromUserLanguageProfile( | |
|
groby-ooo-7-16
2016/08/04 02:33:42
Please don't make this virtual (relates to the "no
ftang
2016/08/05 04:45:28
Done.
| |
| 177 LanguageAndProbabilityList* list) const; | |
| 178 | |
| 168 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 179 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 169 static void MigrateUserPrefs(PrefService* user_prefs, | 180 static void MigrateUserPrefs(PrefService* user_prefs, |
| 170 const char* accept_languages_pref); | 181 const char* accept_languages_pref); |
| 171 | 182 |
| 172 private: | 183 private: |
| 173 friend class TranslatePrefsTest; | 184 friend class TranslatePrefsTest; |
| 174 | 185 |
| 175 // Merges two language sets to migrate to the language setting UI. | 186 // Merges two language sets to migrate to the language setting UI. |
| 176 static void CreateBlockedLanguages( | 187 static void CreateBlockedLanguages( |
| 177 std::vector<std::string>* blocked_languages, | 188 std::vector<std::string>* blocked_languages, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 208 PrefService* prefs_; // Weak. | 219 PrefService* prefs_; // Weak. |
| 209 | 220 |
| 210 std::string country_; // The country the app runs in. | 221 std::string country_; // The country the app runs in. |
| 211 | 222 |
| 212 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); | 223 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); |
| 213 }; | 224 }; |
| 214 | 225 |
| 215 } // namespace translate | 226 } // namespace translate |
| 216 | 227 |
| 217 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ | 228 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ |
| OLD | NEW |