| 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_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "chrome/browser/profiles/avatar_menu_model_observer.h" | 13 #include "chrome/browser/profiles/avatar_menu_model_observer.h" |
| 14 #include "chrome/browser/ui/views/bubble/bubble.h" | 14 #include "ui/views/bubble/bubble_delegate.h" |
| 15 #include "views/controls/button/button.h" | 15 #include "views/controls/button/button.h" |
| 16 #include "views/controls/link_listener.h" | 16 #include "views/controls/link_listener.h" |
| 17 | 17 |
| 18 class AvatarMenuModel; | 18 class AvatarMenuModel; |
| 19 class Browser; | 19 class Browser; |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 class CustomButton; | 22 class CustomButton; |
| 23 class Link; | 23 class Link; |
| 24 class Separator; | 24 class Separator; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // This bubble view is displayed when the user clicks on the avatar button. | 27 // This bubble view is displayed when the user clicks on the avatar button. |
| 28 // It displays a list of profiles and allows users to switch between profiles. | 28 // It displays a list of profiles and allows users to switch between profiles. |
| 29 class AvatarMenuBubbleView : public views::View, | 29 class AvatarMenuBubbleView : public views::BubbleDelegateView, |
| 30 public views::ButtonListener, | 30 public views::ButtonListener, |
| 31 public views::LinkListener, | 31 public views::LinkListener, |
| 32 public BubbleDelegate, | |
| 33 public AvatarMenuModelObserver { | 32 public AvatarMenuModelObserver { |
| 34 public: | 33 public: |
| 35 explicit AvatarMenuBubbleView(Browser* browser); | 34 AvatarMenuBubbleView(views::View* anchor_view, |
| 35 views::BubbleBorder::ArrowLocation arrow_location, |
| 36 const gfx::Rect& anchor_rect, |
| 37 Browser* browser); |
| 36 virtual ~AvatarMenuBubbleView(); | 38 virtual ~AvatarMenuBubbleView(); |
| 37 | 39 |
| 38 // views::View implementation. | 40 // views::View implementation. |
| 39 virtual gfx::Size GetPreferredSize() OVERRIDE; | 41 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 40 virtual void Layout() OVERRIDE; | 42 virtual void Layout() OVERRIDE; |
| 41 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 43 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 42 | 44 |
| 43 // views::ButtonListener implementation. | 45 // views::ButtonListener implementation. |
| 44 virtual void ButtonPressed(views::Button* sender, | 46 virtual void ButtonPressed(views::Button* sender, |
| 45 const views::Event& event) OVERRIDE; | 47 const views::Event& event) OVERRIDE; |
| 46 | 48 |
| 47 // views::LinkListener implementation. | 49 // views::LinkListener implementation. |
| 48 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 50 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 49 | 51 |
| 50 // BubbleDelegate implementation. | 52 // BubbleDelegate implementation. |
| 51 virtual void BubbleShown() OVERRIDE; | 53 virtual gfx::Point GetAnchorPoint() OVERRIDE; |
| 52 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE; | 54 virtual void Init() OVERRIDE; |
| 53 virtual bool CloseOnEscape() OVERRIDE; | |
| 54 virtual bool FadeInOnShow() OVERRIDE; | |
| 55 | 55 |
| 56 // AvatarMenuModelObserver implementation. | 56 // AvatarMenuModelObserver implementation. |
| 57 virtual void OnAvatarMenuModelChanged( | 57 virtual void OnAvatarMenuModelChanged( |
| 58 AvatarMenuModel* avatar_menu_model) OVERRIDE; | 58 AvatarMenuModel* avatar_menu_model) OVERRIDE; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 views::Link* add_profile_link_; | 61 views::Link* add_profile_link_; |
| 62 scoped_ptr<AvatarMenuModel> avatar_menu_model_; | 62 scoped_ptr<AvatarMenuModel> avatar_menu_model_; |
| 63 gfx::Rect anchor_rect_; |
| 63 Browser* browser_; | 64 Browser* browser_; |
| 64 std::vector<views::CustomButton*> item_views_; | 65 std::vector<views::CustomButton*> item_views_; |
| 65 views::Separator* separator_; | 66 views::Separator* separator_; |
| 66 | 67 |
| 67 DISALLOW_COPY_AND_ASSIGN(AvatarMenuBubbleView); | 68 DISALLOW_COPY_AND_ASSIGN(AvatarMenuBubbleView); |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_ | 71 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_ |
| OLD | NEW |