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

Unified Diff: chrome/browser/ui/views/avatar_menu_button.cc

Issue 8138019: Don't reopen avatar bubble view on second click (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/avatar_menu_button.cc
diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc
index d389f7cb722865eee782da4ee1da94c4c6148b9f..3420f2c8b109353d8d4bc76673de86c754e4075b 100644
--- a/chrome/browser/ui/views/avatar_menu_button.cc
+++ b/chrome/browser/ui/views/avatar_menu_button.cc
@@ -65,6 +65,7 @@ void DrawTaskBarDecoration(const Browser* browser, const SkBitmap* bitmap) {
AvatarMenuButton::AvatarMenuButton(Browser* browser, bool has_menu)
: MenuButton(NULL, std::wstring(), this, false),
browser_(browser),
+ bubble_(NULL),
has_menu_(has_menu),
set_taskbar_decoration_(false) {
// In RTL mode, the avatar icon should be looking the opposite direction.
@@ -72,6 +73,8 @@ AvatarMenuButton::AvatarMenuButton(Browser* browser, bool has_menu)
}
AvatarMenuButton::~AvatarMenuButton() {
+ if (bubble_)
Peter Kasting 2011/10/05 01:22:51 Nit: Maybe this should just call OnBubbleClosing()
sail 2011/10/05 01:32:10 Done.
+ bubble_->RemoveObserver(this);
// During destruction of the browser frame, we might not have a window
// so the taskbar button will be removed by windows anyway.
if (browser_->IsAttemptingToCloseBrowser())
@@ -127,7 +130,7 @@ void AvatarMenuButton::SetIcon(const SkBitmap& icon) {
// views::ViewMenuDelegate implementation
void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
- if (!has_menu_)
+ if (!has_menu_ || bubble_)
return;
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
@@ -138,7 +141,12 @@ void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_);
// Bubble::Show() takes ownership of the view.
- Bubble::Show(browser_view->GetWidget(), bounds,
- views::BubbleBorder::TOP_LEFT,
- bubble_view, bubble_view);
+ bubble_ = Bubble::Show(browser_view->GetWidget(), bounds,
+ views::BubbleBorder::TOP_LEFT, bubble_view, bubble_view);
+ bubble_->AddObserver(this);
+}
+
+void AvatarMenuButton::OnBubbleClosing(Bubble* bubble, bool closed_by_escape) {
+ bubble_->RemoveObserver(this);
+ bubble_ = NULL;
}

Powered by Google App Engine
This is Rietveld 408576698