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

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: Addressed review comments 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
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_button.h ('k') | chrome/browser/ui/views/bubble/bubble.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cda4ca0f568347ae9c8b583a3e8f68b207dbe5a3 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_)
+ OnBubbleClosing();
// 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_->RemoveObserver(this);
+ bubble_ = NULL;
}
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_button.h ('k') | chrome/browser/ui/views/bubble/bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698