OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_ |
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 | 11 |
| 12 class PrefRegistrySyncable; |
12 class PrefService; | 13 class PrefService; |
13 class PrefServiceSyncable; | |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class DictionaryValue; | 16 class DictionaryValue; |
17 class ListValue; | 17 class ListValue; |
18 } | 18 } |
19 | 19 |
20 class TranslatePrefs { | 20 class TranslatePrefs { |
21 public: | 21 public: |
22 static const char kPrefTranslateLanguageBlacklist[]; | 22 static const char kPrefTranslateLanguageBlacklist[]; |
23 static const char kPrefTranslateSiteBlacklist[]; | 23 static const char kPrefTranslateSiteBlacklist[]; |
(...skipping 29 matching lines...) Expand all Loading... |
53 // translation for a specific language. (So we can present a UI to white-list | 53 // translation for a specific language. (So we can present a UI to white-list |
54 // that langueg if the user keeps accepting translations). | 54 // that langueg if the user keeps accepting translations). |
55 int GetTranslationAcceptedCount(const std::string& language); | 55 int GetTranslationAcceptedCount(const std::string& language); |
56 void IncrementTranslationAcceptedCount(const std::string& language); | 56 void IncrementTranslationAcceptedCount(const std::string& language); |
57 void ResetTranslationAcceptedCount(const std::string& language); | 57 void ResetTranslationAcceptedCount(const std::string& language); |
58 | 58 |
59 static bool CanTranslate(PrefService* user_prefs, | 59 static bool CanTranslate(PrefService* user_prefs, |
60 const std::string& original_language, const GURL& url); | 60 const std::string& original_language, const GURL& url); |
61 static bool ShouldAutoTranslate(PrefService* user_prefs, | 61 static bool ShouldAutoTranslate(PrefService* user_prefs, |
62 const std::string& original_language, std::string* target_language); | 62 const std::string& original_language, std::string* target_language); |
63 static void RegisterUserPrefs(PrefServiceSyncable* user_prefs); | 63 static void RegisterUserPrefs(PrefService* prefs, |
| 64 PrefRegistrySyncable* registry); |
64 | 65 |
65 private: | 66 private: |
66 static void MigrateTranslateWhitelists(PrefService* user_prefs); | 67 static void MigrateTranslateWhitelists(PrefService* user_prefs); |
67 bool IsValueBlacklisted(const char* pref_id, const std::string& value); | 68 bool IsValueBlacklisted(const char* pref_id, const std::string& value); |
68 void BlacklistValue(const char* pref_id, const std::string& value); | 69 void BlacklistValue(const char* pref_id, const std::string& value); |
69 void RemoveValueFromBlacklist(const char* pref_id, const std::string& value); | 70 void RemoveValueFromBlacklist(const char* pref_id, const std::string& value); |
70 bool IsValueInList(const base::ListValue* list, const std::string& value); | 71 bool IsValueInList(const base::ListValue* list, const std::string& value); |
71 bool IsLanguageWhitelisted(const std::string& original_language, | 72 bool IsLanguageWhitelisted(const std::string& original_language, |
72 std::string* target_language); | 73 std::string* target_language); |
73 | 74 |
74 // Retrieves the dictionary mapping the number of times translation has been | 75 // Retrieves the dictionary mapping the number of times translation has been |
75 // denied for a language, creating it if necessary. | 76 // denied for a language, creating it if necessary. |
76 base::DictionaryValue* GetTranslationDeniedCountDictionary(); | 77 base::DictionaryValue* GetTranslationDeniedCountDictionary(); |
77 | 78 |
78 // Retrieves the dictionary mapping the number of times translation has been | 79 // Retrieves the dictionary mapping the number of times translation has been |
79 // accepted for a language, creating it if necessary. | 80 // accepted for a language, creating it if necessary. |
80 base::DictionaryValue* GetTranslationAcceptedCountDictionary(); | 81 base::DictionaryValue* GetTranslationAcceptedCountDictionary(); |
81 | 82 |
82 PrefService* prefs_; // Weak. | 83 PrefService* prefs_; // Weak. |
83 }; | 84 }; |
84 | 85 |
85 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_ | 86 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_ |
OLD | NEW |