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

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: rebase to remove conflicts 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
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/gtk/reload_button_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/gtk/reload_button_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698