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

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

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: fix build 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_bubble_view.h ('k') | chrome/browser/ui/views/avatar_menu_button.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_bubble_view.cc
diff --git a/chrome/browser/ui/views/avatar_menu_bubble_view.cc b/chrome/browser/ui/views/avatar_menu_bubble_view.cc
index f3665bd46e60a3ddbdfec3257163d34e97831586..58e8964074b7e5efcbf97c8d60f368e3598948d7 100644
--- a/chrome/browser/ui/views/avatar_menu_bubble_view.cc
+++ b/chrome/browser/ui/views/avatar_menu_bubble_view.cc
@@ -7,12 +7,14 @@
#include <algorithm>
#include "base/utf_string_conversions.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/avatar_menu_model.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_info_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -27,6 +29,7 @@
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/separator.h"
+#include "ui/views/widget/widget.h"
namespace {
@@ -387,6 +390,38 @@ bool ProfileItemView::IsHighlighted() {
// AvatarMenuBubbleView -------------------------------------------------------
+// static
+AvatarMenuBubbleView* AvatarMenuBubbleView::avatar_bubble_ = NULL;
+
+// static
+void AvatarMenuBubbleView::ShowBubble(
+ views::View* anchor_view,
+ views::BubbleBorder::ArrowLocation arrow_location,
+ views::BubbleBorder::BubbleAlignment border_alignment,
+ const gfx::Rect& anchor_rect,
+ Browser* browser) {
+ if (IsShowing())
+ return;
+
+ DCHECK(chrome::IsCommandEnabled(browser, IDC_SHOW_AVATAR_MENU));
+ avatar_bubble_ = new AvatarMenuBubbleView(
+ anchor_view, arrow_location, anchor_rect, browser);
+ views::BubbleDelegateView::CreateBubble(avatar_bubble_);
+ avatar_bubble_->SetAlignment(border_alignment);
+ avatar_bubble_->Show();
+}
+
+// static
+bool AvatarMenuBubbleView::IsShowing() {
+ return avatar_bubble_ != NULL;
+}
+
+// static
+void AvatarMenuBubbleView::Hide() {
+ if (IsShowing())
+ avatar_bubble_->GetWidget()->Close();
+}
+
AvatarMenuBubbleView::AvatarMenuBubbleView(
views::View* anchor_view,
views::BubbleBorder::ArrowLocation arrow_location,
@@ -520,6 +555,11 @@ void AvatarMenuBubbleView::Init() {
AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE));
}
+void AvatarMenuBubbleView::WindowClosing() {
+ DCHECK_EQ(avatar_bubble_, this);
+ avatar_bubble_ = NULL;
+}
+
void AvatarMenuBubbleView::OnAvatarMenuModelChanged(
AvatarMenuModel* avatar_menu_model) {
// Unset all our child view references and call RemoveAllChildViews() which
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_bubble_view.h ('k') | chrome/browser/ui/views/avatar_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698