Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: components/translate/core/browser/translate_prefs.h

Issue 345743002: Translate: Hide the bubble if the user denies translating 2 times within 24 hours (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky's review Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 kPrefTranslateBubbleLastClosedTime[];
39 static const char kPrefTranslateBubbleHidden[];
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
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 void UpdateBubbleLastClosedTime();
droger 2014/06/20 12:09:29 Can we have comments for these methods?
93 bool IsBubbleHidden() const;
droger 2014/06/20 12:09:29 This class is used both by infobars and bubbles, a
hajimehoshi 2014/06/20 14:15:45 Hmm, the confusing thing is that the new feature t
Takashi Toyoshima 2014/06/23 11:13:30 As droger said, having bubble UI specific function
hajimehoshi 2014/06/24 06:17:53 OK, I renamed them to UpdateLastDeniedTime and IsT
94
90 // Gets the language list of the language settings. 95 // Gets the language list of the language settings.
91 void GetLanguageList(std::vector<std::string>* languages); 96 void GetLanguageList(std::vector<std::string>* languages);
92 97
93 // Updates the language list of the language settings. 98 // Updates the language list of the language settings.
94 void UpdateLanguageList(const std::vector<std::string>& languages); 99 void UpdateLanguageList(const std::vector<std::string>& languages);
95 100
96 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages, 101 bool CanTranslateLanguage(TranslateAcceptLanguages* accept_languages,
97 const std::string& language); 102 const std::string& language);
98 bool ShouldAutoTranslate(const std::string& original_language, 103 bool ShouldAutoTranslate(const std::string& original_language,
99 std::string* target_language); 104 std::string* target_language);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Retrieves the dictionary mapping the number of times translation has been 150 // Retrieves the dictionary mapping the number of times translation has been
146 // accepted for a language, creating it if necessary. 151 // accepted for a language, creating it if necessary.
147 base::DictionaryValue* GetTranslationAcceptedCountDictionary() const; 152 base::DictionaryValue* GetTranslationAcceptedCountDictionary() const;
148 153
149 PrefService* prefs_; // Weak. 154 PrefService* prefs_; // Weak.
150 155
151 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs); 156 DISALLOW_COPY_AND_ASSIGN(TranslatePrefs);
152 }; 157 };
153 158
154 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_ 159 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698