OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "base/prefs/pref_change_registrar.h" | |
13 #include "chrome/browser/command_observer.h" | |
14 #include "ui/base/glib/glib_signal.h" | |
15 #include "ui/views/widget/desktop_aura/desktop_root_window_host_observer_x11.h" | |
16 | |
17 typedef struct _DbusmenuMenuitem DbusmenuMenuitem; | |
18 typedef struct _DbusmenuServer DbusmenuServer; | |
19 | |
20 namespace ui { | |
21 class Accelerator; | |
22 } | |
23 | |
24 class Browser; | |
25 class BrowserView; | |
26 | |
27 class BrowserDesktopRootWindowHostX11; | |
28 struct GlobalMenuBarCommand; | |
29 | |
30 // Controls the Mac style menu bar on Unity. | |
31 // | |
32 // Unity has an Apple-like menu bar at the top of the screen that changes | |
33 // depending on the active window. In the GTK port, we had a hidden GtkMenuBar | |
34 // object in each GtkWindow which existed only to be scrapped by the | |
35 // libdbusmenu-gtk code. Since we don't have GtkWindows anymore, we need to | |
36 // interface directly with the lower level libdbusmenu-glib, which we | |
37 // opportunistically dlopen() since not everyone is running Ubuntu. | |
38 class GlobalMenuBarX11 : public CommandObserver, | |
39 public views::DesktopRootWindowHostObserverX11 { | |
40 public: | |
41 explicit GlobalMenuBarX11(BrowserView* browser_view, | |
sadrul
2013/08/01 20:57:45
Don't need explicit
| |
42 BrowserDesktopRootWindowHostX11* host); | |
43 virtual ~GlobalMenuBarX11(); | |
44 | |
45 // Creates the object path for DbusemenuServer which is attached to |xid|. | |
46 static std::string GetPathForWindow(unsigned long xid); | |
47 | |
48 private: | |
49 typedef std::map<int, DbusmenuMenuitem*> CommandIDMenuItemMap; | |
50 | |
51 // Creates a DbusmenuServer, and attaches all the menu items. | |
52 void InitServer(unsigned long xid); | |
53 | |
54 // Stops listening to enable state changed events. | |
55 void Disable(); | |
56 | |
57 void BuildMenuFrom(DbusmenuMenuitem* parent, | |
sadrul
2013/08/01 20:57:45
Doc
| |
58 int menu_str_id, | |
59 CommandIDMenuItemMap* id_to_menu_item, | |
60 GlobalMenuBarCommand* commands); | |
61 | |
62 DbusmenuMenuitem* BuildMenuItem( | |
sadrul
2013/08/01 20:57:45
Doc
| |
63 int string_id, | |
64 int command_id, | |
65 int tag_id, | |
66 CommandIDMenuItemMap* id_to_menu_item); | |
67 | |
68 void RegisterAccelerator(DbusmenuMenuitem* item, | |
69 const ui::Accelerator& accelerator); | |
70 | |
71 // Updates the visibility of the bookmark bar on pref changes. | |
72 void OnBookmarkBarVisibilityChanged(); | |
73 | |
74 // Overridden from CommandObserver: | |
75 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE; | |
76 | |
77 // Overridden from DesktopRootWindowHostObserverX11: | |
78 virtual void OnWindowMapped(unsigned long xid) OVERRIDE; | |
79 virtual void OnWindowUnmapped(unsigned long xid) OVERRIDE; | |
80 | |
81 CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, | |
82 unsigned int); | |
83 | |
84 Browser* browser_; | |
85 BrowserView* browser_view_; | |
86 BrowserDesktopRootWindowHostX11* host_; | |
87 | |
88 CommandIDMenuItemMap id_to_menu_item_; | |
89 | |
90 DbusmenuServer* server_; | |
91 DbusmenuMenuitem* root_item_; | |
92 | |
93 // Tracks value of the kShowBookmarkBar preference. | |
94 PrefChangeRegistrar pref_change_registrar_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); | |
97 }; | |
98 | |
99 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ | |
OLD | NEW |