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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 #include "chrome/browser/ui/views/avatar_menu_button.h" 5 #include "chrome/browser/ui/views/avatar_menu_button.h"
6 6
7 #include "chrome/browser/profiles/profile_metrics.h" 7 #include "chrome/browser/profiles/profile_metrics.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" 9 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h"
10 #include "chrome/browser/ui/views/frame/browser_view.h" 10 #include "chrome/browser/ui/views/frame/browser_view.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 taskbar->SetOverlayIcon(window, icon, L""); 72 taskbar->SetOverlayIcon(window, icon, L"");
73 if (icon) 73 if (icon)
74 DestroyIcon(icon); 74 DestroyIcon(icon);
75 #endif 75 #endif
76 } 76 }
77 77
78 AvatarMenuButton::AvatarMenuButton(Browser* browser, bool has_menu) 78 AvatarMenuButton::AvatarMenuButton(Browser* browser, bool has_menu)
79 : MenuButton(NULL, string16(), this, false), 79 : MenuButton(NULL, string16(), this, false),
80 browser_(browser), 80 browser_(browser),
81 bubble_(NULL),
81 has_menu_(has_menu), 82 has_menu_(has_menu),
82 set_taskbar_decoration_(false) { 83 set_taskbar_decoration_(false) {
83 // In RTL mode, the avatar icon should be looking the opposite direction. 84 // In RTL mode, the avatar icon should be looking the opposite direction.
84 EnableCanvasFlippingForRTLUI(true); 85 EnableCanvasFlippingForRTLUI(true);
85 } 86 }
86 87
87 AvatarMenuButton::~AvatarMenuButton() { 88 AvatarMenuButton::~AvatarMenuButton() {
89 if (bubble_)
90 OnBubbleClosing();
88 // During destruction of the browser frame, we might not have a window 91 // During destruction of the browser frame, we might not have a window
89 // so the taskbar button will be removed by windows anyway. 92 // so the taskbar button will be removed by windows anyway.
90 if (browser_->IsAttemptingToCloseBrowser()) 93 if (browser_->IsAttemptingToCloseBrowser())
91 return; 94 return;
92 DrawTaskBarDecoration(browser_, NULL); 95 DrawTaskBarDecoration(browser_, NULL);
93 } 96 }
94 97
95 void AvatarMenuButton::OnPaint(gfx::Canvas* canvas) { 98 void AvatarMenuButton::OnPaint(gfx::Canvas* canvas) {
96 const SkBitmap& icon = GetImageToPaint(); 99 const SkBitmap& icon = GetImageToPaint();
97 if (icon.isNull()) 100 if (icon.isNull())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 views::MenuButton::SetIcon(icon); 140 views::MenuButton::SetIcon(icon);
138 set_taskbar_decoration_ = true; 141 set_taskbar_decoration_ = true;
139 } 142 }
140 143
141 // views::ViewMenuDelegate implementation 144 // views::ViewMenuDelegate implementation
142 void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { 145 void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
143 ShowAvatarBubble(); 146 ShowAvatarBubble();
144 } 147 }
145 148
146 void AvatarMenuButton::ShowAvatarBubble() { 149 void AvatarMenuButton::ShowAvatarBubble() {
147 if (!has_menu_) 150 if (!has_menu_ || bubble_)
148 return; 151 return;
149 152
150 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); 153 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
151 gfx::Point origin; 154 gfx::Point origin;
152 views::View::ConvertPointToScreen(this, &origin); 155 views::View::ConvertPointToScreen(this, &origin);
153 gfx::Rect bounds(origin, size()); 156 gfx::Rect bounds(0, 0, width(), height());
157 bounds.set_origin(origin);
154 158
155 AvatarMenuBubbleView* bubble = new AvatarMenuBubbleView(this, 159 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_);
156 views::BubbleBorder::TOP_LEFT, bounds, browser_); 160 // Bubble::Show() takes ownership of the view.
157 views::BubbleDelegateView::CreateBubble(bubble); 161 bubble_ = Bubble::Show(browser_view->GetWidget(), bounds,
158 bubble->Show(); 162 views::BubbleBorder::TOP_LEFT,
163 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bubble_view, bubble_view);
164 bubble_->AddObserver(this);
159 165
160 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); 166 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE);
161 } 167 }
168
169 void AvatarMenuButton::OnBubbleClosing() {
170 bubble_->RemoveObserver(this);
171 bubble_ = NULL;
172 }
OLDNEW
« 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