Chromium Code Reviews| Index: chrome/browser/ui/views/frame/global_menu_bar_x11.h |
| diff --git a/chrome/browser/ui/views/frame/global_menu_bar_x11.h b/chrome/browser/ui/views/frame/global_menu_bar_x11.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..44d49732c80e8b30c92fe070d31ce6c4d7479065 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/frame/global_menu_bar_x11.h |
| @@ -0,0 +1,99 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/prefs/pref_change_registrar.h" |
| +#include "chrome/browser/command_observer.h" |
| +#include "ui/base/glib/glib_signal.h" |
| +#include "ui/views/widget/desktop_aura/desktop_root_window_host_observer_x11.h" |
| + |
| +typedef struct _DbusmenuMenuitem DbusmenuMenuitem; |
| +typedef struct _DbusmenuServer DbusmenuServer; |
| + |
| +namespace ui { |
| +class Accelerator; |
| +} |
| + |
| +class Browser; |
| +class BrowserView; |
| + |
| +class BrowserDesktopRootWindowHostX11; |
| +struct GlobalMenuBarCommand; |
| + |
| +// Controls the Mac style menu bar on Unity. |
| +// |
| +// Unity has an Apple-like menu bar at the top of the screen that changes |
| +// depending on the active window. In the GTK port, we had a hidden GtkMenuBar |
| +// object in each GtkWindow which existed only to be scrapped by the |
| +// 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, |
| + public views::DesktopRootWindowHostObserverX11 { |
| + public: |
| + explicit GlobalMenuBarX11(BrowserView* browser_view, |
|
sadrul
2013/08/01 20:57:45
Don't need explicit
|
| + BrowserDesktopRootWindowHostX11* host); |
| + virtual ~GlobalMenuBarX11(); |
| + |
| + // Creates the object path for DbusemenuServer which is attached to |xid|. |
| + static std::string GetPathForWindow(unsigned long xid); |
| + |
| + private: |
| + typedef std::map<int, DbusmenuMenuitem*> CommandIDMenuItemMap; |
| + |
| + // Creates a DbusmenuServer, and attaches all the menu items. |
| + void InitServer(unsigned long xid); |
| + |
| + // Stops listening to enable state changed events. |
| + void Disable(); |
| + |
| + void BuildMenuFrom(DbusmenuMenuitem* parent, |
|
sadrul
2013/08/01 20:57:45
Doc
|
| + int menu_str_id, |
| + CommandIDMenuItemMap* id_to_menu_item, |
| + GlobalMenuBarCommand* commands); |
| + |
| + DbusmenuMenuitem* BuildMenuItem( |
|
sadrul
2013/08/01 20:57:45
Doc
|
| + int string_id, |
| + int command_id, |
| + int tag_id, |
| + CommandIDMenuItemMap* id_to_menu_item); |
| + |
| + void RegisterAccelerator(DbusmenuMenuitem* item, |
| + const ui::Accelerator& accelerator); |
| + |
| + // Updates the visibility of the bookmark bar on pref changes. |
| + void OnBookmarkBarVisibilityChanged(); |
| + |
| + // Overridden from CommandObserver: |
| + virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE; |
| + |
| + // Overridden from DesktopRootWindowHostObserverX11: |
| + virtual void OnWindowMapped(unsigned long xid) OVERRIDE; |
| + virtual void OnWindowUnmapped(unsigned long xid) OVERRIDE; |
| + |
| + CHROMEG_CALLBACK_1(GlobalMenuBarX11, void, OnItemActivated, DbusmenuMenuitem*, |
| + unsigned int); |
| + |
| + Browser* browser_; |
| + BrowserView* browser_view_; |
| + BrowserDesktopRootWindowHostX11* host_; |
| + |
| + CommandIDMenuItemMap id_to_menu_item_; |
| + |
| + DbusmenuServer* server_; |
| + DbusmenuMenuitem* root_item_; |
| + |
| + // Tracks value of the kShowBookmarkBar preference. |
| + PrefChangeRegistrar pref_change_registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLOBAL_MENU_BAR_X11_H_ |