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

Side by Side Diff: chrome/browser/ui/gtk/avatar_menu_item_gtk.h

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, 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 #ifndef CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/profiles/avatar_menu_model.h" 12 #include "chrome/browser/profiles/avatar_menu_model.h"
12 #include "ui/base/gtk/gtk_signal.h" 13 #include "ui/base/gtk/gtk_signal.h"
13 #include "ui/base/gtk/owned_widget_gtk.h" 14 #include "ui/base/gtk/owned_widget_gtk.h"
14 15
15 class GtkThemeService; 16 class GtkThemeService;
16 17
17 // This widget contains the profile icon, user name, and synchronization status 18 // This widget contains the profile icon, user name, and synchronization status
18 // to be displayed in the AvatarMenuBubble. Clicking the profile will open a new 19 // to be displayed in the AvatarMenuBubble. Clicking the profile will open a new
19 // browser window, and when the user hovers over an active profile item, a link 20 // browser window, and when the user hovers over an active profile item, a link
20 // is displayed that will allow editing the profile. 21 // is displayed that will allow editing the profile.
21 class AvatarMenuItemGtk { 22 class AvatarMenuItemGtk {
22 public: 23 public:
23 // Delegates opening or editing a profile. 24 // Delegates opening or editing a profile.
24 class Delegate { 25 class Delegate {
25 public: 26 public:
26 // Open a new browser window using the profile at |profile_index|. 27 // Open a new browser window using the profile at |profile_index|.
27 virtual void OpenProfile(size_t profile_index) = 0; 28 virtual void OpenProfile(size_t profile_index) = 0;
28 29
29 // Edit the profile given by |profile_index|. 30 // Edit the profile given by |profile_index|.
30 virtual void EditProfile(size_t profile_index) = 0; 31 virtual void EditProfile(size_t profile_index) = 0;
31 }; 32 };
32 33
33 AvatarMenuItemGtk(Delegate* delegate, 34 AvatarMenuItemGtk(Delegate* delegate,
34 const AvatarMenuModel::Item& item, 35 const AvatarMenuModel::Item& item,
35 size_t item_index, 36 size_t item_index,
36 GtkThemeService* theme_service); 37 GtkThemeService* theme_service);
37 virtual ~AvatarMenuItemGtk(); 38 virtual ~AvatarMenuItemGtk();
38 39
40 void OpenProfile();
41 void EditProfile();
42
39 // Returns the root widget for this menu item. 43 // Returns the root widget for this menu item.
40 GtkWidget* widget() { return widget_.get(); } 44 GtkWidget* widget() { return widget_.get(); }
41 45
42 private: 46 private:
43 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileClick, 47 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileClick,
44 GdkEventButton*); 48 GdkEventButton*);
45 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileEnter, 49 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileEnter,
46 GdkEventCrossing*); 50 GdkEventCrossing*);
47 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileLeave, 51 CHROMEGTK_CALLBACK_1(AvatarMenuItemGtk, gboolean, OnProfileLeave,
48 GdkEventCrossing*); 52 GdkEventCrossing*);
(...skipping 16 matching lines...) Expand all
65 ui::OwnedWidgetGtk widget_; 69 ui::OwnedWidgetGtk widget_;
66 70
67 // A weak pointer to a label that displays the sync status. It is not shown 71 // A weak pointer to a label that displays the sync status. It is not shown
68 // when the user is hovering over the item if the profile is the active 72 // when the user is hovering over the item if the profile is the active
69 // profile. 73 // profile.
70 GtkWidget* status_label_; 74 GtkWidget* status_label_;
71 75
72 // A weak pointer to a link button to edit the given profile. It is shown only 76 // A weak pointer to a link button to edit the given profile. It is shown only
73 // when the user is hovering over the active profile. 77 // when the user is hovering over the active profile.
74 GtkWidget* link_alignment_; 78 GtkWidget* link_alignment_;
79
80 base::WeakPtrFactory<AvatarMenuItemGtk> weak_factory_;
75 }; 81 };
76 82
77 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_ 83 #endif // CHROME_BROWSER_UI_GTK_AVATAR_MENU_ITEM_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc ('k') | chrome/browser/ui/gtk/avatar_menu_item_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698