| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_TOOLBAR_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_TOOLBAR_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_BROWSER_TOOLBAR_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_BROWSER_TOOLBAR_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/prefs/public/pref_observer.h" |
| 13 #include "chrome/browser/api/prefs/pref_member.h" | 14 #include "chrome/browser/api/prefs/pref_member.h" |
| 14 #include "chrome/browser/command_observer.h" | 15 #include "chrome/browser/command_observer.h" |
| 15 #include "chrome/browser/ui/gtk/custom_button.h" | 16 #include "chrome/browser/ui/gtk/custom_button.h" |
| 16 #include "chrome/browser/ui/gtk/menu_gtk.h" | 17 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 17 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 18 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 #include "ui/base/accelerators/accelerator.h" | 21 #include "ui/base/accelerators/accelerator.h" |
| 21 #include "ui/base/gtk/gtk_signal.h" | 22 #include "ui/base/gtk/gtk_signal.h" |
| 22 #include "ui/base/gtk/gtk_signal_registrar.h" | 23 #include "ui/base/gtk/gtk_signal_registrar.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 36 | 37 |
| 37 namespace content { | 38 namespace content { |
| 38 class WebContents; | 39 class WebContents; |
| 39 } | 40 } |
| 40 | 41 |
| 41 // View class that displays the GTK version of the toolbar and routes gtk | 42 // View class that displays the GTK version of the toolbar and routes gtk |
| 42 // events back to the Browser. | 43 // events back to the Browser. |
| 43 class BrowserToolbarGtk : public CommandObserver, | 44 class BrowserToolbarGtk : public CommandObserver, |
| 44 public ui::AcceleratorProvider, | 45 public ui::AcceleratorProvider, |
| 45 public MenuGtk::Delegate, | 46 public MenuGtk::Delegate, |
| 46 public content::NotificationObserver { | 47 public content::NotificationObserver, |
| 48 public PrefObserver { |
| 47 public: | 49 public: |
| 48 BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window); | 50 BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window); |
| 49 virtual ~BrowserToolbarGtk(); | 51 virtual ~BrowserToolbarGtk(); |
| 50 | 52 |
| 51 // Create the contents of the toolbar. |top_level_window| is the GtkWindow | 53 // Create the contents of the toolbar. |top_level_window| is the GtkWindow |
| 52 // to which we attach our accelerators. | 54 // to which we attach our accelerators. |
| 53 void Init(GtkWindow* top_level_window); | 55 void Init(GtkWindow* top_level_window); |
| 54 | 56 |
| 55 // Set the various widgets' ViewIDs. | 57 // Set the various widgets' ViewIDs. |
| 56 void SetViewIDs(); | 58 void SetViewIDs(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Overridden from ui::AcceleratorProvider: | 99 // Overridden from ui::AcceleratorProvider: |
| 98 virtual bool GetAcceleratorForCommandId( | 100 virtual bool GetAcceleratorForCommandId( |
| 99 int id, | 101 int id, |
| 100 ui::Accelerator* accelerator) OVERRIDE; | 102 ui::Accelerator* accelerator) OVERRIDE; |
| 101 | 103 |
| 102 // content::NotificationObserver implementation. | 104 // content::NotificationObserver implementation. |
| 103 virtual void Observe(int type, | 105 virtual void Observe(int type, |
| 104 const content::NotificationSource& source, | 106 const content::NotificationSource& source, |
| 105 const content::NotificationDetails& details) OVERRIDE; | 107 const content::NotificationDetails& details) OVERRIDE; |
| 106 | 108 |
| 109 // PrefObserver implementation. |
| 110 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 111 const std::string& pref_name) OVERRIDE; |
| 112 |
| 107 // Whether the wrench/hotdogs menu is currently visible to the user. | 113 // Whether the wrench/hotdogs menu is currently visible to the user. |
| 108 bool IsWrenchMenuShowing() const; | 114 bool IsWrenchMenuShowing() const; |
| 109 | 115 |
| 110 // Message that we should react to a state change. | 116 // Message that we should react to a state change. |
| 111 void UpdateWebContents(content::WebContents* contents, | 117 void UpdateWebContents(content::WebContents* contents, |
| 112 bool should_restore_state); | 118 bool should_restore_state); |
| 113 | 119 |
| 114 private: | 120 private: |
| 115 // Connect/Disconnect signals for dragging a url onto the home button. | 121 // Connect/Disconnect signals for dragging a url onto the home button. |
| 116 void SetUpDragForHomeButton(bool enable); | 122 void SetUpDragForHomeButton(bool enable); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 | 142 |
| 137 // Used for drags onto home button. | 143 // Used for drags onto home button. |
| 138 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived, | 144 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived, |
| 139 GdkDragContext*, gint, gint, GtkSelectionData*, | 145 GdkDragContext*, gint, gint, GtkSelectionData*, |
| 140 guint, guint); | 146 guint, guint); |
| 141 | 147 |
| 142 // Used to draw the upgrade notification badge. | 148 // Used to draw the upgrade notification badge. |
| 143 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnWrenchMenuButtonExpose, | 149 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnWrenchMenuButtonExpose, |
| 144 GdkEventExpose*); | 150 GdkEventExpose*); |
| 145 | 151 |
| 146 // Updates preference-dependent state. | 152 // Updates preference-dependent state. |pref| may be NULL. |
| 147 void NotifyPrefChanged(const std::string* pref); | 153 void NotifyPrefChanged(const std::string* pref); |
| 148 | 154 |
| 149 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata); | 155 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata); |
| 150 | 156 |
| 151 // Sometimes we only want to show the location w/o the toolbar buttons (e.g., | 157 // Sometimes we only want to show the location w/o the toolbar buttons (e.g., |
| 152 // in a popup window). | 158 // in a popup window). |
| 153 bool ShouldOnlyShowLocation() const; | 159 bool ShouldOnlyShowLocation() const; |
| 154 | 160 |
| 155 // Rebuilds the wrench menu. | 161 // Rebuilds the wrench menu. |
| 156 void RebuildWrenchMenu(); | 162 void RebuildWrenchMenu(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // rendering. | 224 // rendering. |
| 219 ui::OwnedWidgetGtk offscreen_entry_; | 225 ui::OwnedWidgetGtk offscreen_entry_; |
| 220 | 226 |
| 221 // Manages the home button drop signal handler. | 227 // Manages the home button drop signal handler. |
| 222 scoped_ptr<ui::GtkSignalRegistrar> drop_handler_; | 228 scoped_ptr<ui::GtkSignalRegistrar> drop_handler_; |
| 223 | 229 |
| 224 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); | 230 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); |
| 225 }; | 231 }; |
| 226 | 232 |
| 227 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TOOLBAR_GTK_H_ | 233 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TOOLBAR_GTK_H_ |
| OLD | NEW |