1 // Copyright (c) 2012 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_AVATAR_MENU_BUTTON_H_ 6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "ui/base/models/simple_menu_model.h" 12 #include "ui/views/controls/button/menu_button.h" 13 #include "ui/views/controls/button/menu_button_listener.h" 14 15 namespace gfx { 16 class Canvas; 17 class Image; 18 } 19 class Browser; 20 21 // AvatarMenuButton 22 // 23 // A button used to show either the incognito avatar or the profile avatar. 24 // The button can optionally have a menu attached to it. 25 26 class AvatarMenuButton : public views::MenuButton, 27 public views::MenuButtonListener { 28 public: 29 // Creates a new button. If |incognito| is true and we're not in managed mode, 30 // clicking on the button will cause the profile menu to be displayed. 31 AvatarMenuButton(Browser* browser, bool incognito); 32 33 virtual ~AvatarMenuButton(); 34 35 // views::MenuButton: 36 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 37 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; 38 39 virtual void SetAvatarIcon(const gfx::Image& icon, bool is_gaia_picture); 40 41 void ShowAvatarBubble(); 42 43 private: 44 // views::MenuButtonListener: 45 virtual void OnMenuButtonClicked(views::View* source, 46 const gfx::Point& point) OVERRIDE; 47 48 Browser* browser_; 49 bool incognito_; 50 scoped_ptr<ui::MenuModel> menu_model_; 51 52 // Use a scoped ptr because gfx::Image doesn't have a default constructor. 53 scoped_ptr<gfx::Image> icon_; 54 gfx::ImageSkia button_icon_; 55 bool is_gaia_picture_; 56 int old_height_; 57 58 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); 59 }; 60 61 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ 62