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

Side by Side Diff: chrome/browser/ui/views/avatar_menu_button.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: Created 7 years, 12 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/cancelable_callback.h"
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "ui/base/models/simple_menu_model.h" 12 #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.h"
13 #include "ui/views/controls/button/menu_button_listener.h" 14 #include "ui/views/controls/button/menu_button_listener.h"
15 #include "ui/views/widget/widget_observer.h"
14 16
15 namespace gfx { 17 namespace gfx {
16 class Canvas; 18 class Canvas;
17 class Image; 19 class Image;
18 } 20 }
19 class Browser; 21 class Browser;
20 22
21 // Draws a scaled version of the avatar in |image| on the taskbar button 23 // Draws a scaled version of the avatar in |image| on the taskbar button
22 // associated with top level, visible |window|. Currently only implemented 24 // associated with top level, visible |window|. Currently only implemented
23 // for Windows 7 and above. 25 // for Windows 7 and above.
24 void DrawTaskBarDecoration(gfx::NativeWindow window, const gfx::Image* image); 26 void DrawTaskBarDecoration(gfx::NativeWindow window, const gfx::Image* image);
25 27
26 // AvatarMenuButton 28 // AvatarMenuButton
27 // 29 //
28 // A button used to show either the incognito avatar or the profile avatar. 30 // A button used to show either the incognito avatar or the profile avatar.
29 // The button can optionally have a menu attached to it. 31 // The button can optionally have a menu attached to it.
30 32
31 class AvatarMenuButton : public views::MenuButton, 33 class AvatarMenuButton : public views::MenuButton,
32 public views::MenuButtonListener { 34 public views::MenuButtonListener,
35 public views::WidgetObserver {
33 public: 36 public:
34 // Creates a new button. If |incognito| is true and we're not in managed mode, 37 // Creates a new button. If |incognito| is true and we're not in managed mode,
35 // clicking on the button will cause the profile menu to be displayed. 38 // clicking on the button will cause the profile menu to be displayed.
36 AvatarMenuButton(Browser* browser, bool incognito); 39 AvatarMenuButton(Browser* browser, bool incognito);
37 40
38 virtual ~AvatarMenuButton(); 41 virtual ~AvatarMenuButton();
39 42
40 // views::MenuButton: 43 // views::MenuButton:
41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 44 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
42 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; 45 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
43 46
44 virtual void SetAvatarIcon(const gfx::Image& icon, 47 virtual void SetAvatarIcon(const gfx::Image& icon,
45 bool is_gaia_picture); 48 bool is_gaia_picture);
46 49
47 void ShowAvatarBubble(); 50 void ShowAvatarBubble();
48 51
52 views::Widget* bubble_widget() const { return bubble_widget_; }
53
49 private: 54 private:
50 // views::MenuButtonListener: 55 // views::MenuButtonListener:
51 virtual void OnMenuButtonClicked(views::View* source, 56 virtual void OnMenuButtonClicked(views::View* source,
52 const gfx::Point& point) OVERRIDE; 57 const gfx::Point& point) OVERRIDE;
53 58
54 void ButtonClicked(); 59 // views::WidgetObserver:
60 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
61
62 void ShowAvatarBubbleImpl();
55 63
56 Browser* browser_; 64 Browser* browser_;
57 bool incognito_; 65 bool incognito_;
58 scoped_ptr<ui::MenuModel> menu_model_; 66 scoped_ptr<ui::MenuModel> menu_model_;
59 67
60 // Use a scoped ptr because gfx::Image doesn't have a default constructor. 68 // Use a scoped ptr because gfx::Image doesn't have a default constructor.
61 scoped_ptr<gfx::Image> icon_; 69 scoped_ptr<gfx::Image> icon_;
62 gfx::ImageSkia button_icon_; 70 gfx::ImageSkia button_icon_;
63 bool is_gaia_picture_; 71 bool is_gaia_picture_;
64 int old_height_; 72 int old_height_;
65 73
74 // The current bubble that's being shown.
75 views::Widget* bubble_widget_;
76 // This allows the asynchronous process of showing the avatar bubble to be
77 // cancelled.
78 base::CancelableClosure show_avatar_bubble_closure_;
79
66 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); 80 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton);
67 }; 81 };
68 82
69 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ 83 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/avatar_menu_button.cc » ('j') | chrome/browser/ui/views/avatar_menu_button.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698