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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 std::string GetCountry() const; | 92 std::string GetCountry() const; |
93 | 93 |
94 // Resets the blocked languages list, the sites blacklist, the languages | 94 // Resets the blocked languages list, the sites blacklist, the languages |
95 // whitelist, and the accepted/denied counts. | 95 // whitelist, and the accepted/denied counts. |
96 void ResetToDefaults(); | 96 void ResetToDefaults(); |
97 | 97 |
98 bool IsBlockedLanguage(const std::string& original_language) const; | 98 bool IsBlockedLanguage(const std::string& original_language) const; |
99 void BlockLanguage(const std::string& original_language); | 99 void BlockLanguage(const std::string& original_language); |
100 void UnblockLanguage(const std::string& original_language); | 100 void UnblockLanguage(const std::string& original_language); |
101 | 101 |
102 // Removes a language from the old blacklist. Only used internally for | |
103 // diagnostics. Don't use this if there is no special reason. | |
104 void RemoveLanguageFromLegacyBlacklist(const std::string& original_language); | |
105 | |
106 bool IsSiteBlacklisted(const std::string& site) const; | 102 bool IsSiteBlacklisted(const std::string& site) const; |
107 void BlacklistSite(const std::string& site); | 103 void BlacklistSite(const std::string& site); |
108 void RemoveSiteFromBlacklist(const std::string& site); | 104 void RemoveSiteFromBlacklist(const std::string& site); |
109 | 105 |
110 bool HasWhitelistedLanguagePairs() const; | 106 bool HasWhitelistedLanguagePairs() const; |
111 | 107 |
112 bool IsLanguagePairWhitelisted(const std::string& original_language, | 108 bool IsLanguagePairWhitelisted(const std::string& original_language, |
113 const std::string& target_language); | 109 const std::string& target_language); |
114 void WhitelistLanguagePair(const std::string& original_language, | 110 void WhitelistLanguagePair(const std::string& original_language, |
115 const std::string& target_language); | 111 const std::string& target_language); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, | 156 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, |
161 const std::string& language); | 157 const std::string& language); |
162 bool ShouldAutoTranslate(const std::string& original_language, | 158 bool ShouldAutoTranslate(const std::string& original_language, |
163 std::string* target_language); | 159 std::string* target_language); |
164 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 160 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
165 static void MigrateUserPrefs(PrefService* user_prefs, | 161 static void MigrateUserPrefs(PrefService* user_prefs, |
166 const char* accept_languages_pref); | 162 const char* accept_languages_pref); |
167 | 163 |
168 private: | 164 private: |
169 friend class TranslatePrefsTest; | 165 friend class TranslatePrefsTest; |
170 FRIEND_TEST_ALL_PREFIXES(TranslatePrefsTest, CreateBlockedLanguages); | |
171 FRIEND_TEST_ALL_PREFIXES(TranslatePrefsTest, | |
172 CreateBlockedLanguagesNonEnglishUI); | |
173 | 166 |
174 // Merges two language sets to migrate to the language setting UI. | 167 // Merges two language sets to migrate to the language setting UI. |
175 static void CreateBlockedLanguages( | 168 static void CreateBlockedLanguages( |
176 std::vector<std::string>* blocked_languages, | 169 std::vector<std::string>* blocked_languages, |
177 const std::vector<std::string>& blacklisted_languages, | 170 const std::vector<std::string>& blacklisted_languages, |
178 const std::vector<std::string>& accept_languages); | 171 const std::vector<std::string>& accept_languages); |
179 | 172 |
180 void ClearBlockedLanguages(); | 173 void ClearBlockedLanguages(); |
181 void ClearBlacklistedSites(); | 174 void ClearBlacklistedSites(); |
182 void ClearWhitelistedLanguagePairs(); | 175 void ClearWhitelistedLanguagePairs(); |
(...skipping 24 matching lines...) Expand all Loading... |
207 PrefService* prefs_; // Weak. | 200 PrefService* prefs_; // Weak. |
208 | 201 |
209 std::string country_; // The country the app runs in. | 202 std::string country_; // The country the app runs in. |
210 | 203 |
211 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); | 204 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); |
212 }; | 205 }; |
213 | 206 |
214 } // namespace translate | 207 } // namespace translate |
215 | 208 |
216 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ | 209 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ |
OLD | NEW |