Chromium Code Reviews| 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 | |
|
Hiroshi Ichikawa
2017/05/11 04:59:44
Optional: Thanks, it's clearer now. But I feel the
jzw1
2017/05/11 07:23:46
Done.
| |
| 137 // translated into the |to_language| automatically. Every |from_language| will | |
| 138 // only store the last |to_language| as the target. |to_language| is ignored | |
| 139 // when |value| is false. | |
| 140 void SetAlwaysTranslate(bool value, | |
| 141 const std::string& from_language, | |
| 142 const std::string& to_language); | |
| 143 | |
| 144 // Returns the language to always translate |from_language| to, or empty | |
| 145 // string if no such language has been set. | |
| 146 std::string GetAlwaysTranslateToLanguage(const std::string& from_language); | |
| 147 | |
| 121 // Returns true if the Always Translate checkbox should be checked by default. | 148 // Returns true if the Always Translate checkbox should be checked by default. |
| 122 bool ShouldAlwaysTranslateBeCheckedByDefault(); | 149 bool ShouldAlwaysTranslateBeCheckedByDefault(); |
| 123 | 150 |
| 124 private: | 151 private: |
| 125 // Gets the host of the page being translated, or an empty string if no URL is | 152 // Gets the host of the page being translated, or an empty string if no URL is |
| 126 // associated with the current page. | 153 // associated with the current page. |
| 127 std::string GetPageHost(); | 154 std::string GetPageHost(); |
| 128 | 155 |
| 129 TranslateDriver* translate_driver_; | 156 TranslateDriver* translate_driver_; |
| 130 base::WeakPtr<TranslateManager> translate_manager_; | 157 base::WeakPtr<TranslateManager> translate_manager_; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 151 | 178 |
| 152 // The translation related preferences. | 179 // The translation related preferences. |
| 153 std::unique_ptr<TranslatePrefs> prefs_; | 180 std::unique_ptr<TranslatePrefs> prefs_; |
| 154 | 181 |
| 155 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); | 182 DISALLOW_COPY_AND_ASSIGN(TranslateUIDelegate); |
| 156 }; | 183 }; |
| 157 | 184 |
| 158 } // namespace translate | 185 } // namespace translate |
| 159 | 186 |
| 160 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ | 187 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_UI_DELEGATE_H_ |
| OLD | NEW |