| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/command_observer.h" | 15 #include "chrome/browser/command_observer.h" |
| 15 #include "chrome/browser/profiles/avatar_menu.h" | 16 #include "chrome/browser/profiles/avatar_menu.h" |
| 16 #include "chrome/browser/profiles/avatar_menu_observer.h" | 17 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 17 #include "chrome/browser/sessions/tab_restore_service.h" | 18 #include "chrome/browser/sessions/tab_restore_service.h" |
| 18 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 19 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 19 #include "chrome/browser/ui/browser_list_observer.h" | 20 #include "chrome/browser/ui/browser_list_observer.h" |
| 20 #include "components/history/core/browser/history_types.h" | 21 #include "components/history/core/browser/history_types.h" |
| 21 #include "content/public/browser/notification_observer.h" | 22 #include "components/history/core/browser/top_sites_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | |
| 23 #include "ui/base/glib/glib_signal.h" | 23 #include "ui/base/glib/glib_signal.h" |
| 24 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" | 24 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_observer_x11.h" |
| 25 | 25 |
| 26 typedef struct _DbusmenuMenuitem DbusmenuMenuitem; | 26 typedef struct _DbusmenuMenuitem DbusmenuMenuitem; |
| 27 typedef struct _DbusmenuServer DbusmenuServer; | 27 typedef struct _DbusmenuServer DbusmenuServer; |
| 28 | 28 |
| 29 namespace history { | 29 namespace history { |
| 30 class TopSites; | 30 class TopSites; |
| 31 } | 31 } |
| 32 | 32 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 // | 45 // |
| 46 // Unity has an Apple-like menu bar at the top of the screen that changes | 46 // Unity has an Apple-like menu bar at the top of the screen that changes |
| 47 // depending on the active window. In the GTK port, we had a hidden GtkMenuBar | 47 // depending on the active window. In the GTK port, we had a hidden GtkMenuBar |
| 48 // object in each GtkWindow which existed only to be scrapped by the | 48 // object in each GtkWindow which existed only to be scrapped by the |
| 49 // libdbusmenu-gtk code. Since we don't have GtkWindows anymore, we need to | 49 // libdbusmenu-gtk code. Since we don't have GtkWindows anymore, we need to |
| 50 // interface directly with the lower level libdbusmenu-glib, which we | 50 // interface directly with the lower level libdbusmenu-glib, which we |
| 51 // opportunistically dlopen() since not everyone is running Ubuntu. | 51 // opportunistically dlopen() since not everyone is running Ubuntu. |
| 52 class GlobalMenuBarX11 : public AvatarMenuObserver, | 52 class GlobalMenuBarX11 : public AvatarMenuObserver, |
| 53 public chrome::BrowserListObserver, | 53 public chrome::BrowserListObserver, |
| 54 public CommandObserver, | 54 public CommandObserver, |
| 55 public content::NotificationObserver, | 55 public history::TopSitesObserver, |
| 56 public TabRestoreServiceObserver, | 56 public TabRestoreServiceObserver, |
| 57 public views::DesktopWindowTreeHostObserverX11 { | 57 public views::DesktopWindowTreeHostObserverX11 { |
| 58 public: | 58 public: |
| 59 GlobalMenuBarX11(BrowserView* browser_view, | 59 GlobalMenuBarX11(BrowserView* browser_view, |
| 60 BrowserDesktopWindowTreeHostX11* host); | 60 BrowserDesktopWindowTreeHostX11* host); |
| 61 ~GlobalMenuBarX11() override; | 61 ~GlobalMenuBarX11() override; |
| 62 | 62 |
| 63 // Creates the object path for DbusemenuServer which is attached to |xid|. | 63 // Creates the object path for DbusemenuServer which is attached to |xid|. |
| 64 static std::string GetPathForWindow(unsigned long xid); | 64 static std::string GetPathForWindow(unsigned long xid); |
| 65 | 65 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // Overridden from AvatarMenuObserver: | 124 // Overridden from AvatarMenuObserver: |
| 125 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; | 125 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; |
| 126 | 126 |
| 127 // Overridden from chrome::BrowserListObserver: | 127 // Overridden from chrome::BrowserListObserver: |
| 128 void OnBrowserSetLastActive(Browser* browser) override; | 128 void OnBrowserSetLastActive(Browser* browser) override; |
| 129 | 129 |
| 130 // Overridden from CommandObserver: | 130 // Overridden from CommandObserver: |
| 131 void EnabledStateChangedForCommand(int id, bool enabled) override; | 131 void EnabledStateChangedForCommand(int id, bool enabled) override; |
| 132 | 132 |
| 133 // Overridden from content::NotificationObserver: | 133 // Overridden from history::TopSitesObserver: |
| 134 void Observe(int type, | 134 void TopSitesLoaded(history::TopSites* top_sites) override; |
| 135 const content::NotificationSource& source, | 135 void TopSitesChanged(history::TopSites* top_sites) override; |
| 136 const content::NotificationDetails& details) override; | |
| 137 | 136 |
| 138 // Overridden from TabRestoreServiceObserver: | 137 // Overridden from TabRestoreServiceObserver: |
| 139 void TabRestoreServiceChanged(TabRestoreService* service) override; | 138 void TabRestoreServiceChanged(TabRestoreService* service) override; |
| 140 void TabRestoreServiceDestroyed(TabRestoreService* service) override; | 139 void TabRestoreServiceDestroyed(TabRestoreService* service) override; |
| 141 | 140 |
| 142 // Overridden from views::DesktopWindowTreeHostObserverX11: | 141 // Overridden from views::DesktopWindowTreeHostObserverX11: |
| 143 void OnWindowMapped(unsigned long xid) override; | 142 void OnWindowMapped(unsigned long xid) override; |
| 144 void OnWindowUnmapped(unsigned long xid) override; | 143 void OnWindowUnmapped(unsigned long xid) override; |
| 145 | 144 |
| 146 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, | 145 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 172 | 171 |
| 173 // Tracks value of the kShowBookmarkBar preference. | 172 // Tracks value of the kShowBookmarkBar preference. |
| 174 PrefChangeRegistrar pref_change_registrar_; | 173 PrefChangeRegistrar pref_change_registrar_; |
| 175 | 174 |
| 176 history::TopSites* top_sites_; | 175 history::TopSites* top_sites_; |
| 177 | 176 |
| 178 TabRestoreService* tab_restore_service_; // weak | 177 TabRestoreService* tab_restore_service_; // weak |
| 179 | 178 |
| 180 scoped_ptr<AvatarMenu> avatar_menu_; | 179 scoped_ptr<AvatarMenu> avatar_menu_; |
| 181 | 180 |
| 182 content::NotificationRegistrar registrar_; | 181 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_; |
| 183 | 182 |
| 184 // For callbacks may be run after destruction. | 183 // For callbacks may be run after destruction. |
| 185 base::WeakPtrFactory<GlobalMenuBarX11> weak_ptr_factory_; | 184 base::WeakPtrFactory<GlobalMenuBarX11> weak_ptr_factory_; |
| 186 | 185 |
| 187 DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); | 186 DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); |
| 188 }; | 187 }; |
| 189 | 188 |
| 190 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | 189 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |
| OLD | NEW |