| OLD | NEW |
| 1 // Copyright (c) 2011 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_UI_VIEWS_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/translate/languages_menu_model.h" | |
| 10 #include "chrome/browser/translate/translate_infobar_view.h" | |
| 11 #include "chrome/browser/ui/views/infobars/infobar_background.h" | 9 #include "chrome/browser/ui/views/infobars/infobar_background.h" |
| 12 #include "chrome/browser/ui/views/infobars/infobar_view.h" | 10 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
| 13 | 11 |
| 14 class TranslateInfoBarDelegate; | 12 class TranslateInfoBarDelegate; |
| 15 | 13 |
| 16 namespace views { | 14 namespace views { |
| 17 class MenuButton; | 15 class MenuButton; |
| 18 } | 16 } |
| 19 | 17 |
| 20 // This class contains some of the base functionality that translate infobars | 18 // This class contains some of the base functionality that translate infobars |
| 21 // use. | 19 // use. |
| 22 class TranslateInfoBarBase : public TranslateInfoBarView, | 20 class TranslateInfoBarBase : public InfoBarView { |
| 23 public InfoBarView { | |
| 24 public: | 21 public: |
| 25 TranslateInfoBarBase(InfoBarTabHelper* owner, | 22 TranslateInfoBarBase(InfoBarTabHelper* owner, |
| 26 TranslateInfoBarDelegate* delegate); | 23 TranslateInfoBarDelegate* delegate); |
| 27 virtual ~TranslateInfoBarBase(); | 24 virtual ~TranslateInfoBarBase(); |
| 28 | 25 |
| 26 // Sets the text of the provided language menu button. |
| 27 void UpdateLanguageButtonText(views::MenuButton* button, |
| 28 const string16& text); |
| 29 |
| 29 protected: | 30 protected: |
| 30 static const int kButtonInLabelSpacing; | 31 static const int kButtonInLabelSpacing; |
| 31 | 32 |
| 32 // InfoBarView: | 33 // InfoBarView: |
| 33 virtual void ViewHierarchyChanged(bool is_add, | 34 virtual void ViewHierarchyChanged(bool is_add, |
| 34 View* parent, | 35 View* parent, |
| 35 View* child) OVERRIDE; | 36 View* child) OVERRIDE; |
| 36 | 37 |
| 37 // Sets the text of the provided language menu button to reflect the current | |
| 38 // value from the delegate. | |
| 39 void UpdateLanguageButtonText(views::MenuButton* button, | |
| 40 LanguagesMenuModel::LanguageType language); | |
| 41 | |
| 42 // Convenience to retrieve the TranslateInfoBarDelegate for this infobar. | 38 // Convenience to retrieve the TranslateInfoBarDelegate for this infobar. |
| 43 TranslateInfoBarDelegate* GetDelegate(); | 39 TranslateInfoBarDelegate* GetDelegate(); |
| 44 | 40 |
| 45 private: | 41 private: |
| 46 // InfoBarView: | 42 // InfoBarView: |
| 47 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 43 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; |
| 48 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 44 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 49 | 45 |
| 50 // Returns the background that should be displayed when not animating. | 46 // Returns the background that should be displayed when not animating. |
| 51 const views::Background& GetBackground(); | 47 const views::Background& GetBackground(); |
| 52 | 48 |
| 53 // Paints |background| to |canvas| with the opacity level based on | 49 // Paints |background| to |canvas| with the opacity level based on |
| 54 // |animation_value|. | 50 // |animation_value|. |
| 55 void FadeBackground(gfx::Canvas* canvas, | 51 void FadeBackground(gfx::Canvas* canvas, |
| 56 double animation_value, | 52 double animation_value, |
| 57 const views::Background& background); | 53 const views::Background& background); |
| 58 | 54 |
| 59 InfoBarBackground error_background_; | 55 InfoBarBackground error_background_; |
| 60 scoped_ptr<ui::SlideAnimation> background_color_animation_; | 56 scoped_ptr<ui::SlideAnimation> background_color_animation_; |
| 61 | 57 |
| 62 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarBase); | 58 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarBase); |
| 63 }; | 59 }; |
| 64 | 60 |
| 65 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ | 61 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_TRANSLATE_INFOBAR_BASE_H_ |
| OLD | NEW |