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

Unified Diff: chrome/browser/ui/gtk/avatar_menu_item_gtk.cc

Issue 8370021: Make avatar menu bubble as singleton and destroy all the menu items and menu model when bubble cl... (Closed) Base URL: http://src.chromium.org/svn/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
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_item_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/avatar_menu_item_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/avatar_menu_item_gtk.cc (revision 106832)
+++ chrome/browser/ui/gtk/avatar_menu_item_gtk.cc (working copy)
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/gtk/avatar_menu_item_gtk.h"
+#include "base/bind.h"
+#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
@@ -40,16 +42,29 @@
item_(item),
item_index_(item_index),
status_label_(NULL),
- link_alignment_(NULL) {
+ link_alignment_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
Init(theme_service);
}
AvatarMenuItemGtk::~AvatarMenuItemGtk() {
+ widget_.Destroy();
}
+void AvatarMenuItemGtk::OpenProfile() {
+ delegate_->OpenProfile(item_index_);
+}
+
gboolean AvatarMenuItemGtk::OnProfileClick(GtkWidget* widget,
GdkEventButton* event) {
- delegate_->OpenProfile(item_index_);
+ // delegate_->EditProfile() will close the avatar bubble which in turn
+ // try to destroy this AvatarMenuItemGtk.
+ // This is not OK to do this from the signal handler, so we'll
+ // defer it.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AvatarMenuItemGtk::OpenProfile,
+ weak_factory_.GetWeakPtr()));
return FALSE;
}
@@ -83,10 +98,21 @@
return FALSE;
}
-void AvatarMenuItemGtk::OnEditProfileLinkClicked(GtkWidget* link) {
+void AvatarMenuItemGtk::EditProfile() {
delegate_->EditProfile(item_index_);
}
+void AvatarMenuItemGtk::OnEditProfileLinkClicked(GtkWidget* link) {
+ // delegate_->EditProfile() will close the avatar bubble which in turn
+ // try to destroy this AvatarMenuItemGtk.
+ // This is not OK to do this from the signal handler, so we'll
+ // defer it.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AvatarMenuItemGtk::EditProfile,
+ weak_factory_.GetWeakPtr()));
+}
+
void AvatarMenuItemGtk::Init(GtkThemeService* theme_service) {
widget_.Own(gtk_event_box_new());
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_item_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698