Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: chrome/browser/ui/gtk/global_bookmark_menu.h

Issue 7017028: Revert "Revert 85330 - GTK: Bring global menu out of about:flags." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GTK_GLOBAL_BOOKMARK_MENU_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARK_MENU_H_
6 #define CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARK_MENU_H_ 6 #define CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARK_MENU_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "chrome/browser/bookmarks/bookmark_model_observer.h" 12 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
13 #include "chrome/browser/ui/gtk/global_menu_owner.h"
14 #include "chrome/browser/ui/gtk/owned_widget_gtk.h"
13 #include "content/common/notification_observer.h" 15 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h" 16 #include "content/common/notification_registrar.h"
15 #include "ui/base/gtk/gtk_signal.h" 17 #include "ui/base/gtk/gtk_signal.h"
16 18
17 class Browser; 19 class Browser;
18 class Profile; 20 class Profile;
19 21
20 typedef struct _GdkPixbuf GdkPixbuf; 22 typedef struct _GdkPixbuf GdkPixbuf;
21 typedef struct _GtkWidget GtkWidget; 23 typedef struct _GtkWidget GtkWidget;
22 24
23 // Manages the global bookmarks menu. 25 // Manages the global bookmarks menu.
24 // 26 //
25 // There are a few subtleties here: we can't rely on accurate event 27 // There are a few subtleties here: we can't rely on accurate event
26 // dispositions being sent back, right click menus on menu items are placed 28 // dispositions being sent back, right click menus on menu items are placed
27 // relative to the main chrome window instead of the global menu bar, and we 29 // relative to the main chrome window instead of the global menu bar, and we
28 // need to update the menu in the background (instead of building it on showing 30 // need to update the menu in the background (instead of building it on showing
29 // and not updating it if the model changes). I'm not even thinking about 31 // and not updating it if the model changes). I'm not even thinking about
30 // making these draggable since these items aren't displayed in our process. 32 // making these draggable since these items aren't displayed in our process.
31 class GlobalBookmarkMenu : public NotificationObserver, 33 class GlobalBookmarkMenu : public GlobalMenuOwner,
34 public NotificationObserver,
32 public BookmarkModelObserver { 35 public BookmarkModelObserver {
33 public: 36 public:
34 explicit GlobalBookmarkMenu(Browser* browser); 37 explicit GlobalBookmarkMenu(Browser* browser);
35 virtual ~GlobalBookmarkMenu(); 38 virtual ~GlobalBookmarkMenu();
36 39
37 // Takes the bookmark menu we need to modify based on bookmark state. 40 // Takes the bookmark menu we need to modify based on bookmark state.
38 void Init(GtkWidget* bookmark_menu); 41 virtual void Init(GtkWidget* bookmark_menu, GtkWidget* bookmark_menu_item);
39 42
40 private: 43 private:
41 // Schedules the menu to be rebuilt. The mac version sets a boolean and 44 // Schedules the menu to be rebuilt. The mac version sets a boolean and
42 // rebuilds the menu during their pre-show callback. We don't have anything 45 // rebuilds the menu during their pre-show callback. We don't have anything
43 // like that: by the time we get a "show" signal from GTK+, the menu has 46 // like that: by the time we get a "show" signal from GTK+, the menu has
44 // already been displayed and it will take multiple dbus calls to add the 47 // already been displayed and it will take multiple dbus calls to add the
45 // menu items. 48 // menu items.
46 // 49 //
47 // Since the bookmark model works by sending us BookmarkNodeEvent 50 // Since the bookmark model works by sending us BookmarkNodeEvent
48 // notifications one by one, we use a timer to batch up calls. 51 // notifications one by one, we use a timer to batch up calls.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 CHROMEGTK_CALLBACK_0(GlobalBookmarkMenu, void, OnBookmarkItemActivated); 107 CHROMEGTK_CALLBACK_0(GlobalBookmarkMenu, void, OnBookmarkItemActivated);
105 108
106 Browser* browser_; 109 Browser* browser_;
107 Profile* profile_; 110 Profile* profile_;
108 111
109 NotificationRegistrar registrar_; 112 NotificationRegistrar registrar_;
110 113
111 GdkPixbuf* default_favicon_; 114 GdkPixbuf* default_favicon_;
112 GdkPixbuf* default_folder_; 115 GdkPixbuf* default_folder_;
113 116
114 GtkWidget* bookmark_menu_; 117 OwnedWidgetGtk bookmark_menu_;
115 118
116 // We use this factory to create callback tasks for ThreadWatcher object. We 119 // We use this factory to create callback tasks for ThreadWatcher object. We
117 // use this during ping-pong messaging between WatchDog thread and watched 120 // use this during ping-pong messaging between WatchDog thread and watched
118 // thread. 121 // thread.
119 ScopedRunnableMethodFactory<GlobalBookmarkMenu> method_factory_; 122 ScopedRunnableMethodFactory<GlobalBookmarkMenu> method_factory_;
120 123
121 // In order to appropriately update items in the bookmark menu, without 124 // In order to appropriately update items in the bookmark menu, without
122 // forcing a rebuild, map the model's nodes to menu items. 125 // forcing a rebuild, map the model's nodes to menu items.
123 std::map<const BookmarkNode*, GtkWidget*> bookmark_nodes_; 126 std::map<const BookmarkNode*, GtkWidget*> bookmark_nodes_;
124 }; 127 };
125 128
126 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARK_MENU_H_ 129 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARK_MENU_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.cc ('k') | chrome/browser/ui/gtk/global_bookmark_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698