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

Unified Diff: chrome/browser/ui/gtk/reload_button_gtk.h

Issue 10736008: Added reload drop-down menu for the Reload button on Linux when in the DevTools mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment about browser interface. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/reload_button_gtk.h
diff --git a/chrome/browser/ui/gtk/reload_button_gtk.h b/chrome/browser/ui/gtk/reload_button_gtk.h
index 6ca22156e1c43825d62d634879764ad59284252f..bb3f2fbce27944630fff0a90de2f109c8d55b526 100644
--- a/chrome/browser/ui/gtk/reload_button_gtk.h
+++ b/chrome/browser/ui/gtk/reload_button_gtk.h
@@ -12,8 +12,10 @@
#include "base/compiler_specific.h"
#include "base/timer.h"
#include "chrome/browser/ui/gtk/custom_button.h"
+#include "chrome/browser/ui/gtk/menu_gtk.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "ui/base/models/simple_menu_model.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/gtk/owned_widget_gtk.h"
@@ -21,7 +23,9 @@ class Browser;
class GtkThemeService;
class LocationBarViewGtk;
-class ReloadButtonGtk : public content::NotificationObserver {
+class ReloadButtonGtk : public content::NotificationObserver,
+ MenuGtk::Delegate,
+ public ui::SimpleMenuModel::Delegate {
public:
enum Mode { MODE_RELOAD = 0, MODE_STOP };
@@ -39,6 +43,18 @@ class ReloadButtonGtk : public content::NotificationObserver {
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Provide MenuGtk::Delegate implementation.
+ virtual void StoppedShowing() OVERRIDE;
+
+ // Provide SimpleMenuModel::Delegate implementation.
+ virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
+ virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
+ virtual bool IsCommandIdVisible(int command_id) const OVERRIDE;
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) OVERRIDE;
+ virtual void ExecuteCommand(int command_id) OVERRIDE;
+
private:
friend class ReloadButtonGtkTest;
@@ -56,11 +72,35 @@ class ReloadButtonGtk : public content::NotificationObserver {
gboolean,
GtkTooltip*);
+ // Starts a timer to show the dropdown menu.
+ CHROMEGTK_CALLBACK_1(ReloadButtonGtk,
+ gboolean,
+ OnButtonPress,
+ GdkEventButton*);
+
+ // If there is a timer to show the dropdown menu, and the mouse has moved
+ // sufficiently down the screen, cancel the timer and immediately show the
+ // menu.
+ CHROMEGTK_CALLBACK_1(ReloadButtonGtk,
+ gboolean,
+ OnMouseMove,
+ GdkEventMotion*);
+
void UpdateThemeButtons();
void OnDoubleClickTimer();
void OnStopToReloadTimer();
+ // Shows the dropdown menu.
+ void ShowReloadMenu(int button, guint32 event_time);
+
+ // Do actual reload. command == 0, indicates default dehaviour.
+ void DoReload(int command);
+
+ // Indicates if reload menu is currently enabled.
+ bool ReloadMenuEnabled();
+ void ClearCache();
+
base::OneShotTimer<ReloadButtonGtk> double_click_timer_;
base::OneShotTimer<ReloadButtonGtk> stop_to_reload_timer_;
@@ -90,6 +130,14 @@ class ReloadButtonGtk : public content::NotificationObserver {
base::TimeDelta double_click_timer_delay_;
base::TimeDelta stop_to_reload_timer_delay_;
+ // The y position of the last mouse down event.
+ int y_position_of_last_press_;
+ base::WeakPtrFactory<ReloadButtonGtk> weak_factory_;
+ // The menu gets reset every time it is shown.
+ scoped_ptr<MenuGtk> menu_;
+ // The dropdown menu model.
+ scoped_ptr<ui::SimpleMenuModel> menu_model_;
+
// TESTING ONLY
// True if we should pretend the button is hovered.
bool testing_mouse_hovered_;

Powered by Google App Engine
This is Rietveld 408576698