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_UI_DELEGATE_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ |
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ | 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 std::string GetTargetLanguageCode() const; | 70 std::string GetTargetLanguageCode() const; |
71 | 71 |
72 // Updates the target language index. | 72 // Updates the target language index. |
73 void UpdateTargetLanguageIndex(size_t language_index); | 73 void UpdateTargetLanguageIndex(size_t language_index); |
74 | 74 |
75 void UpdateTargetLanguage(const std::string& language_code); | 75 void UpdateTargetLanguage(const std::string& language_code); |
76 | 76 |
77 // Returns the ISO code for the language at |index|. | 77 // Returns the ISO code for the language at |index|. |
78 std::string GetLanguageCodeAt(size_t index) const; | 78 std::string GetLanguageCodeAt(size_t index) const; |
79 | 79 |
80 // Returns the index of |language_code|. | |
81 size_t GetLanguageIndex(const std::string& language_code); | |
michaeldo
2017/05/11 23:51:33
Should this be avoided per comment above about crb
jzw1
2017/05/12 03:46:46
I think it's mainly concerned with updating langua
| |
82 | |
80 // Returns the displayable name for the language at |index|. | 83 // Returns the displayable name for the language at |index|. |
81 base::string16 GetLanguageNameAt(size_t index) const; | 84 base::string16 GetLanguageNameAt(size_t index) const; |
82 | 85 |
83 // Starts translating the current page. | 86 // Starts translating the current page. |
84 void Translate(); | 87 void Translate(); |
85 | 88 |
86 // Reverts translation. | 89 // Reverts translation. |
87 void RevertTranslation(); | 90 void RevertTranslation(); |
88 | 91 |
89 // Processes when the user declines translation. | 92 // Processes when the user declines translation. |
90 // The function name is not accurate. It only means the user did not take | 93 // The function name is not accurate. It only means the user did not take |
91 // affirmative action after the translation ui show up. The user either | 94 // affirmative action after the translation ui show up. The user either |
92 // actively decline the translation or ignore the prompt of translation. | 95 // actively decline the translation or ignore the prompt of translation. |
93 // Pass |explicitly_closed| as true if user explicityly decline the | 96 // Pass |explicitly_closed| as true if user explicityly decline the |
94 // translation. | 97 // translation. |
95 // Pass |explicitly_closed| as false if the translation UI is dismissed | 98 // Pass |explicitly_closed| as false if the translation UI is dismissed |
96 // implicit by some user actions which ignore the translation UI, | 99 // implicit by some user actions which ignore the translation UI, |
97 // such as switch to a new tab/window or navigate to another page by | 100 // such as switch to a new tab/window or navigate to another page by |
98 // click a link. | 101 // click a link. |
99 void TranslationDeclined(bool explicitly_closed); | 102 void TranslationDeclined(bool explicitly_closed); |
100 | 103 |
101 // Returns true if the current language is blocked. | 104 // Returns true if the current language is blocked. |
102 bool IsLanguageBlocked(); | 105 bool IsLanguageBlocked(); |
103 | 106 |
107 // Returns true if |language_code| is blocked. | |
108 bool IsLanguageBlocked(const std::string& language_code); | |
Eugene But (OOO till 7-30)
2017/05/11 15:48:59
Please document if strings can be empty and what h
jzw1
2017/05/12 03:46:45
Do you mean string.empty() or null? I updated the
Hiroshi Ichikawa
2017/05/12 06:06:06
I believe he means string.empty(). It will be a co
| |
109 | |
104 // Sets the value if the current language is blocked. | 110 // Sets the value if the current language is blocked. |
105 void SetLanguageBlocked(bool value); | 111 void SetLanguageBlocked(bool value); |
106 | 112 |
113 // Sets the value if the |language_code| is blocked. | |
Eugene But (OOO till 7-30)
2017/05/11 15:48:59
This method unconditionally sets the value, not on
jzw1
2017/05/12 03:46:46
Updated comments to be more clear.
| |
114 void SetLanguageBlocked(bool value, const std::string& language_code); | |
115 | |
107 // Returns true if the current webpage is blacklisted. | 116 // Returns true if the current webpage is blacklisted. |
108 bool IsSiteBlacklisted(); | 117 bool IsSiteBlacklisted(); |
109 | 118 |
119 // Returns true if |page_host| is blacklisted. | |
120 bool IsSiteBlacklisted(const std::string& page_host); | |
121 | |
110 // Sets the value if the current webpage is blacklisted. | 122 // Sets the value if the current webpage is blacklisted. |
111 void SetSiteBlacklist(bool value); | 123 void SetSiteBlacklist(bool value); |
112 | 124 |
125 // Sets the value if the |page_host| is blacklisted. | |
Eugene But (OOO till 7-30)
2017/05/11 15:48:59
ditto
jzw1
2017/05/12 03:46:45
Done.
| |
126 void SetSiteBlacklist(bool value, const std::string& page_host); | |
127 | |
113 // Returns true if the webpage in the current original language should be | 128 // Returns true if the webpage in the current original language should be |
114 // translated into the current target language automatically. | 129 // translated into the current target language automatically. |
115 bool ShouldAlwaysTranslate(); | 130 bool ShouldAlwaysTranslate(); |
116 | 131 |
117 // Sets the value if the webpage in the current original language should be | 132 // Sets the value if the webpage in the current original language should be |
118 // translated into the current target language automatically. | 133 // translated into the current target language automatically. |
119 void SetAlwaysTranslate(bool value); | 134 void SetAlwaysTranslate(bool value); |
120 | 135 |
136 // If |value| is true, update the preference to always translate | |
Eugene But (OOO till 7-30)
2017/05/11 15:48:59
s/update/updates
jzw1
2017/05/12 03:46:45
Done and did same for below.
| |
137 // |from_language| to |to_language| without prompting. If it is called | |
138 // multiple times for the same |from_language|, the last specified | |
139 // |to_language| is used. | |
140 // If |value| is false, update the preference not to always translate | |
141 // |from_language|. |target_language| is ignored. | |
142 void SetAlwaysTranslate(bool value, | |
143 const std::string& from_language, | |
144 const std::string& to_language); | |
145 | |
146 // Returns the language to always translate |from_language| to, or empty | |
147 // string if no such language has been set. | |
148 std::string GetAlwaysTranslateToLanguage(const std::string& from_language); | |
149 | |
121 // Returns true if the Always Translate checkbox should be checked by default. | 150 // Returns true if the Always Translate checkbox should be checked by default. |
122 bool ShouldAlwaysTranslateBeCheckedByDefault(); | 151 bool ShouldAlwaysTranslateBeCheckedByDefault(); |
123 | 152 |
124 private: | 153 private: |
125 // Gets the host of the page being translated, or an empty string if no URL is | 154 // Gets the host of the page being translated, or an empty string if no URL is |
126 // associated with the current page. | 155 // associated with the current page. |
127 std::string GetPageHost(); | 156 std::string GetPageHost(); |
128 | 157 |
129 TranslateDriver* translate_driver_; | 158 TranslateDriver* translate_driver_; |
130 base::WeakPtr<TranslateManager> translate_manager_; | 159 base::WeakPtr<TranslateManager> translate_manager_; |
(...skipping 20 matching lines...) Expand all Loading... | |
151 | 180 |
152 // The translation related preferences. | 181 // The translation related preferences. |
153 std::unique_ptr<TranslatePrefs> prefs_; | 182 std::unique_ptr<TranslatePrefs> prefs_; |
154 | 183 |
155 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); | 184 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); |
156 }; | 185 }; |
157 | 186 |
158 } // namespace translate | 187 } // namespace translate |
159 | 188 |
160 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ | 189 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ |
OLD | NEW |