1 // Copyright 2014 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_PROFILES_AVATAR_MENU_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_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"
14 #include "ui/views/view_targeter_delegate.h"
24 // A button used to show either the incognito avatar or the profile avatar.
25 // The button can optionally have a menu attached to it.
27 class AvatarMenuButton
: public views::MenuButton
,
28 public views::MenuButtonListener
,
29 public views::ViewTargeterDelegate
{
31 // Internal class name.
32 static const char kViewClassName
[];
34 // Creates a new button. Unless |disabled| is true, clicking on the button
35 // will cause the profile menu to be displayed.
36 AvatarMenuButton(Browser
* browser
, bool disabled
);
38 virtual ~AvatarMenuButton();
41 virtual const char* GetClassName() const override
;
42 virtual void OnPaint(gfx::Canvas
* canvas
) override
;
44 // Sets the image for the avatar button. Rectangular images, as opposed
45 // to Chrome avatar icons, will be resized and modified for the title bar.
46 virtual void SetAvatarIcon(const gfx::Image
& icon
, bool is_rectangle
);
48 void set_button_on_right(bool button_on_right
) {
49 button_on_right_
= button_on_right
;
51 bool button_on_right() { return button_on_right_
; }
54 // views::ViewTargeterDelegate:
55 virtual bool DoesIntersectRect(const views::View
* target
,
56 const gfx::Rect
& rect
) const override
;
58 // views::MenuButtonListener:
59 virtual void OnMenuButtonClicked(views::View
* source
,
60 const gfx::Point
& point
) override
;
64 scoped_ptr
<ui::MenuModel
> menu_model_
;
66 // Use a scoped ptr because gfx::Image doesn't have a default constructor.
67 scoped_ptr
<gfx::Image
> icon_
;
68 gfx::ImageSkia button_icon_
;
71 // True if the avatar button is on the right side of the browser window.
72 bool button_on_right_
;
74 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton
);
77 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_