| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // Factory method to create an error translate infobar. | 47 // Factory method to create an error translate infobar. |
| 48 static TranslateInfoBarDelegate* CreateErrorDelegate( | 48 static TranslateInfoBarDelegate* CreateErrorDelegate( |
| 49 TranslateErrors::Type error_type, | 49 TranslateErrors::Type error_type, |
| 50 TabContents* tab_contents, | 50 TabContents* tab_contents, |
| 51 const std::string& original_language, | 51 const std::string& original_language, |
| 52 const std::string& target_language); | 52 const std::string& target_language); |
| 53 | 53 |
| 54 virtual ~TranslateInfoBarDelegate(); | 54 virtual ~TranslateInfoBarDelegate(); |
| 55 | 55 |
| 56 // Returns the number of languages supported. | 56 // Returns the number of languages supported. |
| 57 int GetLanguageCount() const; | 57 int GetLanguageCount() const { return static_cast<int>(languages_.size()); } |
| 58 | 58 |
| 59 // Returns the ISO code for the language at |index|. | 59 // Returns the ISO code for the language at |index|. |
| 60 std::string GetLanguageCodeAt(int index) const; | 60 std::string GetLanguageCodeAt(int index) const; |
| 61 | 61 |
| 62 // Returns the displayable name for the language at |index|. | 62 // Returns the displayable name for the language at |index|. |
| 63 string16 GetLanguageDisplayableNameAt(int index) const; | 63 string16 GetLanguageDisplayableNameAt(int index) const; |
| 64 | 64 |
| 65 TabContents* tab_contents() const { return tab_contents_; } | 65 TabContents* tab_contents() const { return tab_contents_; } |
| 66 | 66 |
| 67 Type type() const { return type_; } | 67 Type type() const { return type_; } |
| 68 | 68 |
| 69 TranslateErrors::Type error() const { return error_; } | 69 TranslateErrors::Type error() const { return error_; } |
| 70 | 70 |
| 71 int original_language_index() const { return original_language_index_; } | 71 int original_language_index() const { return original_language_index_; } |
| 72 int target_language_index() const { return target_language_index_; } | 72 int target_language_index() const { return target_language_index_; } |
| 73 | 73 |
| 74 // Convenience methods. | 74 // Convenience methods. |
| 75 std::string GetOriginalLanguageCode() const; | 75 std::string GetOriginalLanguageCode() const; |
| 76 std::string GetTargetLanguageCode() const; | 76 std::string GetTargetLanguageCode() const; |
| 77 | 77 |
| 78 // Called by the InfoBar to notify that the original/target language has | 78 // Called by the InfoBar to notify that the original/target language has |
| 79 // changed and is now the language at |language_index|. | 79 // changed and is now the language at |language_index|. |
| 80 virtual void SetOriginalLanguage(int language_index); | 80 virtual void SetOriginalLanguage(int language_index); |
| 81 virtual void SetTargetLanguage(int language_index); | 81 virtual void SetTargetLanguage(int language_index); |
| 82 | 82 |
| 83 // Returns true if the current infobar indicates an error (in which case it | 83 // Returns true if the current infobar indicates an error (in which case it |
| 84 // should get a yellow background instead of a blue one). | 84 // should get a yellow background instead of a blue one). |
| 85 bool IsError(); | 85 bool IsError() const { return type_ == TRANSLATION_ERROR; } |
| 86 | 86 |
| 87 // Returns what kind of background fading effect the infobar should use when | 87 // Returns what kind of background fading effect the infobar should use when |
| 88 // its is shown. | 88 // its is shown. |
| 89 BackgroundAnimationType background_animation_type() const { | 89 BackgroundAnimationType background_animation_type() const { |
| 90 return background_animation_; | 90 return background_animation_; |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void Translate(); | 93 virtual void Translate(); |
| 94 virtual void RevertTranslation(); | 94 virtual void RevertTranslation(); |
| 95 virtual void ReportLanguageDetectionError(); | 95 virtual void ReportLanguageDetectionError(); |
| 96 | 96 |
| 97 // Called when the user declines to translate a page, by either closing the | 97 // Called when the user declines to translate a page, by either closing the |
| 98 // infobar or pressing the "Don't translate" button. | 98 // infobar or pressing the "Don't translate" button. |
| 99 void TranslationDeclined(); | 99 void TranslationDeclined(); |
| 100 | 100 |
| 101 // InfoBarDelegate implementation: | |
| 102 virtual InfoBar* CreateInfoBar(); | |
| 103 virtual void InfoBarDismissed(); | |
| 104 virtual void InfoBarClosed(); | |
| 105 virtual SkBitmap* GetIcon() const; | |
| 106 virtual InfoBarDelegate::Type GetInfoBarType(); | |
| 107 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); | |
| 108 | |
| 109 // Methods called by the Options menu delegate. | 101 // Methods called by the Options menu delegate. |
| 110 virtual bool IsLanguageBlacklisted(); | 102 virtual bool IsLanguageBlacklisted(); |
| 111 virtual void ToggleLanguageBlacklist(); | 103 virtual void ToggleLanguageBlacklist(); |
| 112 virtual bool IsSiteBlacklisted(); | 104 virtual bool IsSiteBlacklisted(); |
| 113 virtual void ToggleSiteBlacklist(); | 105 virtual void ToggleSiteBlacklist(); |
| 114 virtual bool ShouldAlwaysTranslate(); | 106 virtual bool ShouldAlwaysTranslate(); |
| 115 virtual void ToggleAlwaysTranslate(); | 107 virtual void ToggleAlwaysTranslate(); |
| 116 | 108 |
| 117 // Methods called by the extra-buttons that can appear on the "before | 109 // Methods called by the extra-buttons that can appear on the "before |
| 118 // translate" infobar (when the user has accepted/declined the translation | 110 // translate" infobar (when the user has accepted/declined the translation |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 TranslateInfoBarDelegate(Type infobar_type, | 149 TranslateInfoBarDelegate(Type infobar_type, |
| 158 TranslateErrors::Type error, | 150 TranslateErrors::Type error, |
| 159 TabContents* tab_contents, | 151 TabContents* tab_contents, |
| 160 const std::string& original_language, | 152 const std::string& original_language, |
| 161 const std::string& target_language); | 153 const std::string& target_language); |
| 162 Type type_; | 154 Type type_; |
| 163 | 155 |
| 164 private: | 156 private: |
| 165 typedef std::pair<std::string, string16> LanguageNamePair; | 157 typedef std::pair<std::string, string16> LanguageNamePair; |
| 166 | 158 |
| 159 // InfoBarDelegate implementation: |
| 160 virtual InfoBar* CreateInfoBar(); |
| 161 virtual void InfoBarDismissed(); |
| 162 virtual void InfoBarClosed(); |
| 163 virtual SkBitmap* GetIcon() const; |
| 164 virtual InfoBarDelegate::Type GetInfoBarType() const; |
| 165 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
| 166 |
| 167 // Gets the host of the page being translated, or an empty string if no URL is | 167 // Gets the host of the page being translated, or an empty string if no URL is |
| 168 // associated with the current page. | 168 // associated with the current page. |
| 169 std::string GetPageHost(); | 169 std::string GetPageHost(); |
| 170 | 170 |
| 171 // The type of fading animation if any that should be used when showing this | 171 // The type of fading animation if any that should be used when showing this |
| 172 // infobar. | 172 // infobar. |
| 173 BackgroundAnimationType background_animation_; | 173 BackgroundAnimationType background_animation_; |
| 174 | 174 |
| 175 TabContents* tab_contents_; | 175 TabContents* tab_contents_; |
| 176 | 176 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 199 // The current infobar view. | 199 // The current infobar view. |
| 200 TranslateInfoBarView* infobar_view_; | 200 TranslateInfoBarView* infobar_view_; |
| 201 | 201 |
| 202 // The translation related preferences. | 202 // The translation related preferences. |
| 203 TranslatePrefs prefs_; | 203 TranslatePrefs prefs_; |
| 204 | 204 |
| 205 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); | 205 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 208 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| OLD | NEW |