| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // | 28 // |
| 29 // It is assumed that |prefs_| is alive while this instance is alive. | 29 // It is assumed that |prefs_| is alive while this instance is alive. |
| 30 class TranslatePrefs { | 30 class TranslatePrefs { |
| 31 public: | 31 public: |
| 32 static const char kPrefTranslateLanguageBlacklist[]; | 32 static const char kPrefTranslateLanguageBlacklist[]; |
| 33 static const char kPrefTranslateSiteBlacklist[]; | 33 static const char kPrefTranslateSiteBlacklist[]; |
| 34 static const char kPrefTranslateWhitelists[]; | 34 static const char kPrefTranslateWhitelists[]; |
| 35 static const char kPrefTranslateDeniedCount[]; | 35 static const char kPrefTranslateDeniedCount[]; |
| 36 static const char kPrefTranslateAcceptedCount[]; | 36 static const char kPrefTranslateAcceptedCount[]; |
| 37 static const char kPrefTranslateBlockedLanguages[]; | 37 static const char kPrefTranslateBlockedLanguages[]; |
| 38 static const char kPrefTranslateLastDeniedTime[]; |
| 39 static const char kPrefTranslateTooOftenDenied[]; |
| 38 | 40 |
| 39 // |preferred_languages_pref| is only used on Chrome OS, other platforms must | 41 // |preferred_languages_pref| is only used on Chrome OS, other platforms must |
| 40 // pass NULL. | 42 // pass NULL. |
| 41 TranslatePrefs(PrefService* user_prefs, | 43 TranslatePrefs(PrefService* user_prefs, |
| 42 const char* accept_languages_pref, | 44 const char* accept_languages_pref, |
| 43 const char* preferred_languages_pref); | 45 const char* preferred_languages_pref); |
| 44 | 46 |
| 45 // Resets the blocked languages list, the sites blacklist, the languages | 47 // Resets the blocked languages list, the sites blacklist, the languages |
| 46 // whitelist, and the accepted/denied counts. | 48 // whitelist, and the accepted/denied counts. |
| 47 void ResetToDefaults(); | 49 void ResetToDefaults(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void IncrementTranslationDeniedCount(const std::string& language); | 82 void IncrementTranslationDeniedCount(const std::string& language); |
| 81 void ResetTranslationDeniedCount(const std::string& language); | 83 void ResetTranslationDeniedCount(const std::string& language); |
| 82 | 84 |
| 83 // These methods are used to track how many times the user has accepted the | 85 // These methods are used to track how many times the user has accepted the |
| 84 // translation for a specific language. (So we can present a UI to white-list | 86 // translation for a specific language. (So we can present a UI to white-list |
| 85 // that language if the user keeps accepting translations). | 87 // that language if the user keeps accepting translations). |
| 86 int GetTranslationAcceptedCount(const std::string& language); | 88 int GetTranslationAcceptedCount(const std::string& language); |
| 87 void IncrementTranslationAcceptedCount(const std::string& language); | 89 void IncrementTranslationAcceptedCount(const std::string& language); |
| 88 void ResetTranslationAcceptedCount(const std::string& language); | 90 void ResetTranslationAcceptedCount(const std::string& language); |
| 89 | 91 |
| 92 // Update the last time on closing the Translate UI without translation. |
| 93 void UpdateLastDeniedTime(); |
| 94 |
| 95 // Returns true if translation is denied too often. |
| 96 bool IsTooOftenDenied() const; |
| 97 |
| 90 // Gets the language list of the language settings. | 98 // Gets the language list of the language settings. |
| 91 void GetLanguageList(std::vector<std::string>* languages); | 99 void GetLanguageList(std::vector<std::string>* languages); |
| 92 | 100 |
| 93 // Updates the language list of the language settings. | 101 // Updates the language list of the language settings. |
| 94 void UpdateLanguageList(const std::vector<std::string>& languages); | 102 void UpdateLanguageList(const std::vector<std::string>& languages); |
| 95 | 103 |
| 96 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, | 104 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, |
| 97 const std::string& language); | 105 const std::string& language); |
| 98 bool ShouldAutoTranslate(const std::string& original_language, | 106 bool ShouldAutoTranslate(const std::string& original_language, |
| 99 std::string* target_language); | 107 std::string* target_language); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Retrieves the dictionary mapping the number of times translation has been | 153 // Retrieves the dictionary mapping the number of times translation has been |
| 146 // accepted for a language, creating it if necessary. | 154 // accepted for a language, creating it if necessary. |
| 147 base::DictionaryValue* GetTranslationAcceptedCountDictionary() const; | 155 base::DictionaryValue* GetTranslationAcceptedCountDictionary() const; |
| 148 | 156 |
| 149 PrefService* prefs_; // Weak. | 157 PrefService* prefs_; // Weak. |
| 150 | 158 |
| 151 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); | 159 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); |
| 152 }; | 160 }; |
| 153 | 161 |
| 154 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ | 162 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ |
| OLD | NEW |