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

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

Issue 8621004: Revert 111018 - Rebase AvatarMenuBubbleView on the new views bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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/frame/browser_view.cc » ('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
===================================================================
--- chrome/browser/ui/views/avatar_menu_button.cc (revision 111023)
+++ chrome/browser/ui/views/avatar_menu_button.cc (working copy)
@@ -78,6 +78,7 @@
AvatarMenuButton::AvatarMenuButton(Browser* browser, bool has_menu)
: MenuButton(NULL, string16(), 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.
@@ -85,6 +86,8 @@
}
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())
@@ -144,18 +147,26 @@
}
void AvatarMenuButton::ShowAvatarBubble() {
- if (!has_menu_)
+ if (!has_menu_ || bubble_)
return;
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
gfx::Point origin;
views::View::ConvertPointToScreen(this, &origin);
- gfx::Rect bounds(origin, size());
+ gfx::Rect bounds(0, 0, width(), height());
+ bounds.set_origin(origin);
- AvatarMenuBubbleView* bubble = new AvatarMenuBubbleView(this,
- views::BubbleBorder::TOP_LEFT, bounds, browser_);
- views::BubbleDelegateView::CreateBubble(bubble);
- bubble->Show();
+ AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_);
+ // Bubble::Show() takes ownership of the view.
+ bubble_ = Bubble::Show(browser_view->GetWidget(), bounds,
+ views::BubbleBorder::TOP_LEFT,
+ views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bubble_view, bubble_view);
+ bubble_->AddObserver(this);
ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE);
}
+
+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/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698