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