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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_
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"
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.
26 class AvatarMenuButton : public views::MenuButton,
27 public views::MenuButtonListener {
29 // Creates a new button. If |disabled| 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 disabled);
33 virtual ~AvatarMenuButton();
36 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
37 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
39 // Sets the image for the avatar button. Rectangular images, as opposed
40 // to Chrome avatar icons, will be resized and modified for the title bar.
41 virtual void SetAvatarIcon(const gfx::Image& icon, bool is_rectangle);
43 void ShowAvatarBubble();
46 // views::MenuButtonListener:
47 virtual void OnMenuButtonClicked(views::View* source,
48 const gfx::Point& point) OVERRIDE;
52 scoped_ptr<ui::MenuModel> menu_model_;
54 // Use a scoped ptr because gfx::Image doesn't have a default constructor.
55 scoped_ptr<gfx::Image> icon_;
56 gfx::ImageSkia button_icon_;
60 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton);
63 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_