Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Side by Side Diff: chrome/browser/ui/views/avatar_menu_bubble_view.h

Issue 11646008: Close avatar bubble when avatar button is clicked a second time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/avatar_menu_bubble_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 12 matching lines...) Expand all
23 class Separator; 23 class Separator;
24 } 24 }
25 25
26 // This bubble view is displayed when the user clicks on the avatar button. 26 // This bubble view is displayed when the user clicks on the avatar button.
27 // It displays a list of profiles and allows users to switch between profiles. 27 // It displays a list of profiles and allows users to switch between profiles.
28 class AvatarMenuBubbleView : public views::BubbleDelegateView, 28 class AvatarMenuBubbleView : public views::BubbleDelegateView,
29 public views::ButtonListener, 29 public views::ButtonListener,
30 public views::LinkListener, 30 public views::LinkListener,
31 public AvatarMenuModelObserver { 31 public AvatarMenuModelObserver {
32 public: 32 public:
33 AvatarMenuBubbleView(views::View* anchor_view, 33 // Helper function to show the bubble and ensure that it doesn't reshow.
34 views::BubbleBorder::ArrowLocation arrow_location, 34 // Normally this bubble is shown when there's a mouse down event on a button.
35 const gfx::Rect& anchor_rect, 35 // If the bubble is already showing when the user clicks on the button then
36 Browser* browser); 36 // this will cause two things to happen:
37 // - (1) the button will show a new instance of the bubble
38 // - (2) the old instance of the bubble will get a deactivate event and
39 // close
40 // To prevent this reshow this function checks if an instance of the bubble
41 // is already showing and do nothing. This means that (1) will do nothing
42 // and (2) will correctly hide the old bubble instance.
43 static void ShowBubble(views::View* anchor_view,
44 views::BubbleBorder::ArrowLocation arrow_location,
45 views::BubbleBorder::BubbleAlignment border_alignment,
46 const gfx::Rect& anchor_rect,
47 Browser* browser);
48 static bool IsShowing();
49 static void Hide();
50
37 virtual ~AvatarMenuBubbleView(); 51 virtual ~AvatarMenuBubbleView();
38 52
39 // views::View implementation. 53 // views::View implementation.
40 virtual gfx::Size GetPreferredSize() OVERRIDE; 54 virtual gfx::Size GetPreferredSize() OVERRIDE;
41 virtual void Layout() OVERRIDE; 55 virtual void Layout() OVERRIDE;
42 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 56 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
43 57
44 // views::ButtonListener implementation. 58 // views::ButtonListener implementation.
45 virtual void ButtonPressed(views::Button* sender, 59 virtual void ButtonPressed(views::Button* sender,
46 const ui::Event& event) OVERRIDE; 60 const ui::Event& event) OVERRIDE;
47 61
48 // views::LinkListener implementation. 62 // views::LinkListener implementation.
49 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 63 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
50 64
51 // BubbleDelegate implementation. 65 // BubbleDelegate implementation.
52 virtual gfx::Rect GetAnchorRect() OVERRIDE; 66 virtual gfx::Rect GetAnchorRect() OVERRIDE;
53 virtual void Init() OVERRIDE; 67 virtual void Init() OVERRIDE;
68 virtual void WindowClosing() OVERRIDE;
54 69
55 // AvatarMenuModelObserver implementation. 70 // AvatarMenuModelObserver implementation.
56 virtual void OnAvatarMenuModelChanged( 71 virtual void OnAvatarMenuModelChanged(
57 AvatarMenuModel* avatar_menu_model) OVERRIDE; 72 AvatarMenuModel* avatar_menu_model) OVERRIDE;
58 73
59 private: 74 private:
75 AvatarMenuBubbleView(views::View* anchor_view,
76 views::BubbleBorder::ArrowLocation arrow_location,
77 const gfx::Rect& anchor_rect,
78 Browser* browser);
79
60 views::Link* add_profile_link_; 80 views::Link* add_profile_link_;
61 scoped_ptr<AvatarMenuModel> avatar_menu_model_; 81 scoped_ptr<AvatarMenuModel> avatar_menu_model_;
62 gfx::Rect anchor_rect_; 82 gfx::Rect anchor_rect_;
63 Browser* browser_; 83 Browser* browser_;
64 std::vector<views::CustomButton*> item_views_; 84 std::vector<views::CustomButton*> item_views_;
65 views::Separator* separator_; 85 views::Separator* separator_;
66 86
87 static AvatarMenuBubbleView* avatar_bubble_;
88
67 DISALLOW_COPY_AND_ASSIGN(AvatarMenuBubbleView); 89 DISALLOW_COPY_AND_ASSIGN(AvatarMenuBubbleView);
68 }; 90 };
69 91
70 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_ 92 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/avatar_menu_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698