#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_change_registrar.h"
#include "chrome/browser/command_observer.h"
-#include "chrome/browser/history/history_types.h"
+#include "chrome/browser/profiles/avatar_menu.h"
+#include "chrome/browser/profiles/avatar_menu_observer.h"
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_observer.h"
+#include "chrome/browser/ui/browser_list_observer.h"
+#include "components/history/core/browser/history_types.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/base/glib/glib_signal.h"
// libdbusmenu-gtk code. Since we don't have GtkWindows anymore, we need to
// interface directly with the lower level libdbusmenu-glib, which we
// opportunistically dlopen() since not everyone is running Ubuntu.
-class GlobalMenuBarX11 : public CommandObserver,
+class GlobalMenuBarX11 : public AvatarMenuObserver,
+ public chrome::BrowserListObserver,
+ public CommandObserver,
public content::NotificationObserver,
public TabRestoreServiceObserver,
public views::DesktopWindowTreeHostObserverX11 {
public:
GlobalMenuBarX11(BrowserView* browser_view,
BrowserDesktopWindowTreeHostX11* host);
- virtual ~GlobalMenuBarX11();
+ ~GlobalMenuBarX11() override;
// Creates the object path for DbusemenuServer which is attached to |xid|.
static std::string GetPathForWindow(unsigned long xid);
// Updates the visibility of the bookmark bar on pref changes.
void OnBookmarkBarVisibilityChanged();
+ void RebuildProfilesMenu();
+
// Find the first index of the item in |menu| with the tag |tag_id|.
int GetIndexOfMenuItemWithTag(DbusmenuMenuitem* menu, int tag_id);
// Deleter function for HistoryItem implementation detail.
static void DeleteHistoryItem(void* void_item);
+ // Overridden from AvatarMenuObserver:
+ void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override;
+
+ // Overridden from chrome::BrowserListObserver:
+ void OnBrowserSetLastActive(Browser* browser) override;
+
// Overridden from CommandObserver:
- virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE;
+ void EnabledStateChangedForCommand(int id, bool enabled) override;
// Overridden from content::NotificationObserver:
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
// Overridden from TabRestoreServiceObserver:
- virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE;
- virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE;
+ void TabRestoreServiceChanged(TabRestoreService* service) override;
+ void TabRestoreServiceDestroyed(TabRestoreService* service) override;
// Overridden from views::DesktopWindowTreeHostObserverX11:
- virtual void OnWindowMapped(unsigned long xid) OVERRIDE;
- virtual void OnWindowUnmapped(unsigned long xid) OVERRIDE;
+ void OnWindowMapped(unsigned long xid) override;
+ void OnWindowUnmapped(unsigned long xid) override;
CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*,
unsigned int);
DbusmenuMenuitem*, unsigned int);
CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnHistoryMenuAboutToShow,
DbusmenuMenuitem*);
+ CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnProfileItemActivated,
+ DbusmenuMenuitem*, unsigned int);
+ CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnEditProfileItemActivated,
+ DbusmenuMenuitem*, unsigned int);
+ CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnCreateProfileItemActivated,
+ DbusmenuMenuitem*, unsigned int);
Browser* browser_;
Profile* profile_;
DbusmenuServer* server_;
DbusmenuMenuitem* root_item_;
DbusmenuMenuitem* history_menu_;
+ DbusmenuMenuitem* profiles_menu_;
// Tracks value of the kShowBookmarkBar preference.
PrefChangeRegistrar pref_change_registrar_;
TabRestoreService* tab_restore_service_; // weak
+ scoped_ptr<AvatarMenu> avatar_menu_;
+
content::NotificationRegistrar registrar_;
// For callbacks may be run after destruction.