| 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_AVATAR_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/ui/views/bubble/bubble.h" |
| 12 #include "ui/base/models/simple_menu_model.h" | 13 #include "ui/base/models/simple_menu_model.h" |
| 13 #include "views/controls/button/menu_button.h" | 14 #include "views/controls/button/menu_button.h" |
| 14 #include "views/controls/menu/view_menu_delegate.h" | 15 #include "views/controls/menu/view_menu_delegate.h" |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Canvas; | 18 class Canvas; |
| 18 } | 19 } |
| 19 class Browser; | 20 class Browser; |
| 20 | 21 |
| 21 // AvatarMenuButton | 22 // AvatarMenuButton |
| 22 // | 23 // |
| 23 // A button used to show either the incognito avatar or the profile avatar. | 24 // 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 // The button can optionally have a menu attached to it. |
| 25 | 26 |
| 26 class AvatarMenuButton : public views::MenuButton, | 27 class AvatarMenuButton : public views::MenuButton, |
| 27 public views::ViewMenuDelegate { | 28 public views::ViewMenuDelegate, |
| 29 public Bubble::Observer { |
| 28 public: | 30 public: |
| 29 // Creates a new button. If |has_menu| is true then clicking on the button | 31 // Creates a new button. If |has_menu| is true then clicking on the button |
| 30 // will cause the profile menu to be displayed. | 32 // will cause the profile menu to be displayed. |
| 31 AvatarMenuButton(Browser* browser, bool has_menu); | 33 AvatarMenuButton(Browser* browser, bool has_menu); |
| 32 | 34 |
| 33 virtual ~AvatarMenuButton(); | 35 virtual ~AvatarMenuButton(); |
| 34 | 36 |
| 35 // views::MenuButton | 37 // views::MenuButton |
| 36 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 38 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 37 virtual bool HitTest(const gfx::Point& point) const OVERRIDE; | 39 virtual bool HitTest(const gfx::Point& point) const OVERRIDE; |
| 38 | 40 |
| 39 // views::TextButton | 41 // views::TextButton |
| 40 virtual void SetIcon(const SkBitmap& icon) OVERRIDE; | 42 virtual void SetIcon(const SkBitmap& icon) OVERRIDE; |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 // views::ViewMenuDelegate | 45 // views::ViewMenuDelegate |
| 44 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 46 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; |
| 45 | 47 |
| 48 // Bubble::Observer implementation. |
| 49 virtual void OnBubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE; |
| 50 |
| 46 Browser* browser_; | 51 Browser* browser_; |
| 52 Bubble* bubble_; |
| 47 bool has_menu_; | 53 bool has_menu_; |
| 48 bool set_taskbar_decoration_; | 54 bool set_taskbar_decoration_; |
| 49 scoped_ptr<ui::MenuModel> menu_model_; | 55 scoped_ptr<ui::MenuModel> menu_model_; |
| 50 | 56 |
| 51 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); | 57 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ | 60 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
| OLD | NEW |