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 2dbe5ce2d78d09e25f24f809e43129c0ff01883f..d46cc840d5c5df831f165a4f9f51b0d52c5339e3 100644 |
--- a/chrome/browser/ui/gtk/reload_button_gtk.h |
+++ b/chrome/browser/ui/gtk/reload_button_gtk.h |
@@ -11,8 +11,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" |
@@ -20,7 +22,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 }; |
@@ -38,6 +42,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; |
@@ -55,11 +71,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_; |
@@ -89,6 +129,16 @@ 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_; |
+ // Indicates if menu is currently shown. |
+ bool menu_visible_; |
+ |
// TESTING ONLY |
// True if we should pretend the button is hovered. |
bool testing_mouse_hovered_; |