| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace ui { | 30 namespace ui { |
| 31 class Accelerator; | 31 class Accelerator; |
| 32 } | 32 } |
| 33 | 33 |
| 34 class Browser; | 34 class Browser; |
| 35 class BrowserView; | 35 class BrowserView; |
| 36 class Profile; | 36 class Profile; |
| 37 | 37 |
| 38 class BrowserDesktopWindowTreeHostX11; | 38 class BrowserDesktopRootWindowHostX11; |
| 39 struct GlobalMenuBarCommand; | 39 struct GlobalMenuBarCommand; |
| 40 | 40 |
| 41 // Controls the Mac style menu bar on Unity. | 41 // Controls the Mac style menu bar on Unity. |
| 42 // | 42 // |
| 43 // Unity has an Apple-like menu bar at the top of the screen that changes | 43 // Unity has an Apple-like menu bar at the top of the screen that changes |
| 44 // depending on the active window. In the GTK port, we had a hidden GtkMenuBar | 44 // depending on the active window. In the GTK port, we had a hidden GtkMenuBar |
| 45 // object in each GtkWindow which existed only to be scrapped by the | 45 // object in each GtkWindow which existed only to be scrapped by the |
| 46 // libdbusmenu-gtk code. Since we don't have GtkWindows anymore, we need to | 46 // libdbusmenu-gtk code. Since we don't have GtkWindows anymore, we need to |
| 47 // interface directly with the lower level libdbusmenu-glib, which we | 47 // interface directly with the lower level libdbusmenu-glib, which we |
| 48 // opportunistically dlopen() since not everyone is running Ubuntu. | 48 // opportunistically dlopen() since not everyone is running Ubuntu. |
| 49 class GlobalMenuBarX11 : public CommandObserver, | 49 class GlobalMenuBarX11 : public CommandObserver, |
| 50 public content::NotificationObserver, | 50 public content::NotificationObserver, |
| 51 public TabRestoreServiceObserver, | 51 public TabRestoreServiceObserver, |
| 52 public views::DesktopWindowTreeHostObserverX11 { | 52 public views::DesktopRootWindowHostObserverX11 { |
| 53 public: | 53 public: |
| 54 GlobalMenuBarX11(BrowserView* browser_view, | 54 GlobalMenuBarX11(BrowserView* browser_view, |
| 55 BrowserDesktopWindowTreeHostX11* host); | 55 BrowserDesktopRootWindowHostX11* host); |
| 56 virtual ~GlobalMenuBarX11(); | 56 virtual ~GlobalMenuBarX11(); |
| 57 | 57 |
| 58 // Creates the object path for DbusemenuServer which is attached to |xid|. | 58 // Creates the object path for DbusemenuServer which is attached to |xid|. |
| 59 static std::string GetPathForWindow(unsigned long xid); | 59 static std::string GetPathForWindow(unsigned long xid); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 struct HistoryItem; | 62 struct HistoryItem; |
| 63 typedef std::map<int, DbusmenuMenuitem*> CommandIDMenuItemMap; | 63 typedef std::map<int, DbusmenuMenuitem*> CommandIDMenuItemMap; |
| 64 | 64 |
| 65 // Builds a separator. | 65 // Builds a separator. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 // Overridden from content::NotificationObserver: | 120 // Overridden from content::NotificationObserver: |
| 121 virtual void Observe(int type, | 121 virtual void Observe(int type, |
| 122 const content::NotificationSource& source, | 122 const content::NotificationSource& source, |
| 123 const content::NotificationDetails& details) OVERRIDE; | 123 const content::NotificationDetails& details) OVERRIDE; |
| 124 | 124 |
| 125 // Overridden from TabRestoreServiceObserver: | 125 // Overridden from TabRestoreServiceObserver: |
| 126 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; | 126 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; |
| 127 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; | 127 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; |
| 128 | 128 |
| 129 // Overridden from views::DesktopWindowTreeHostObserverX11: | 129 // Overridden from views::DesktopRootWindowHostObserverX11: |
| 130 virtual void OnWindowMapped(unsigned long xid) OVERRIDE; | 130 virtual void OnWindowMapped(unsigned long xid) OVERRIDE; |
| 131 virtual void OnWindowUnmapped(unsigned long xid) OVERRIDE; | 131 virtual void OnWindowUnmapped(unsigned long xid) OVERRIDE; |
| 132 | 132 |
| 133 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, | 133 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, |
| 134 unsigned int); | 134 unsigned int); |
| 135 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnHistoryItemActivated, | 135 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnHistoryItemActivated, |
| 136 DbusmenuMenuitem*, unsigned int); | 136 DbusmenuMenuitem*, unsigned int); |
| 137 CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnHistoryMenuAboutToShow, | 137 CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnHistoryMenuAboutToShow, |
| 138 DbusmenuMenuitem*); | 138 DbusmenuMenuitem*); |
| 139 | 139 |
| 140 Browser* browser_; | 140 Browser* browser_; |
| 141 Profile* profile_; | 141 Profile* profile_; |
| 142 BrowserView* browser_view_; | 142 BrowserView* browser_view_; |
| 143 BrowserDesktopWindowTreeHostX11* host_; | 143 BrowserDesktopRootWindowHostX11* host_; |
| 144 | 144 |
| 145 // Maps command ids to DbusmenuMenuitems so we can modify their | 145 // Maps command ids to DbusmenuMenuitems so we can modify their |
| 146 // enabled/checked state in response to state change notifications. | 146 // enabled/checked state in response to state change notifications. |
| 147 CommandIDMenuItemMap id_to_menu_item_; | 147 CommandIDMenuItemMap id_to_menu_item_; |
| 148 | 148 |
| 149 DbusmenuServer* server_; | 149 DbusmenuServer* server_; |
| 150 DbusmenuMenuitem* root_item_; | 150 DbusmenuMenuitem* root_item_; |
| 151 DbusmenuMenuitem* history_menu_; | 151 DbusmenuMenuitem* history_menu_; |
| 152 | 152 |
| 153 // Tracks value of the kShowBookmarkBar preference. | 153 // Tracks value of the kShowBookmarkBar preference. |
| 154 PrefChangeRegistrar pref_change_registrar_; | 154 PrefChangeRegistrar pref_change_registrar_; |
| 155 | 155 |
| 156 history::TopSites* top_sites_; | 156 history::TopSites* top_sites_; |
| 157 | 157 |
| 158 TabRestoreService* tab_restore_service_; // weak | 158 TabRestoreService* tab_restore_service_; // weak |
| 159 | 159 |
| 160 content::NotificationRegistrar registrar_; | 160 content::NotificationRegistrar registrar_; |
| 161 | 161 |
| 162 // For callbacks may be run after destruction. | 162 // For callbacks may be run after destruction. |
| 163 base::WeakPtrFactory<GlobalMenuBarX11> weak_ptr_factory_; | 163 base::WeakPtrFactory<GlobalMenuBarX11> weak_ptr_factory_; |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); | 165 DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | 168 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |
| OLD | NEW |