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); | |
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); | |
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. | |
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. | |
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 // Sets the value if the webpage in the |from_language| should be | |
137 // translated into the |to_language| automatically. Note that every | |
138 // |from_language| will only store the last |to_language| as the target. | |
139 void SetAlwaysTranslate(bool value, | |
140 const std::string& from_language, | |
141 const std::string& to_language); | |
142 | |
143 // Returns the language to always translate |from_language| to, or empty | |
144 // string if none is found. | |
Hiroshi Ichikawa
2017/05/11 04:14:15
s/if none is found/if it doesn't always translate
jzw1
2017/05/11 04:43:00
I'll update the comment differently.
| |
145 std::string GetAlwaysTranslateToLanguage(const std::string& from_language); | |
146 | |
121 // Returns true if the Always Translate checkbox should be checked by default. | 147 // Returns true if the Always Translate checkbox should be checked by default. |
122 bool ShouldAlwaysTranslateBeCheckedByDefault(); | 148 bool ShouldAlwaysTranslateBeCheckedByDefault(); |
123 | 149 |
124 private: | 150 private: |
125 // Gets the host of the page being translated, or an empty string if no URL is | 151 // Gets the host of the page being translated, or an empty string if no URL is |
126 // associated with the current page. | 152 // associated with the current page. |
127 std::string GetPageHost(); | 153 std::string GetPageHost(); |
128 | 154 |
129 TranslateDriver* translate_driver_; | 155 TranslateDriver* translate_driver_; |
130 base::WeakPtr<TranslateManager> translate_manager_; | 156 base::WeakPtr<TranslateManager> translate_manager_; |
(...skipping 20 matching lines...) Expand all Loading... | |
151 | 177 |
152 // The translation related preferences. | 178 // The translation related preferences. |
153 std::unique_ptr<TranslatePrefs> prefs_; | 179 std::unique_ptr<TranslatePrefs> prefs_; |
154 | 180 |
155 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); | 181 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); |
156 }; | 182 }; |
157 | 183 |
158 } // namespace translate | 184 } // namespace translate |
159 | 185 |
160 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ | 186 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ |
OLD | NEW |