| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_GTK_BACK_FORWARD_BUTTON_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "chrome/browser/gtk/custom_button.h" | 10 #include "chrome/browser/gtk/custom_button.h" |
| 11 #include "chrome/browser/gtk/menu_gtk.h" |
| 11 | 12 |
| 12 class BackForwardMenuModelGtk; | 13 class BackForwardMenuModel; |
| 13 class Browser; | 14 class Browser; |
| 14 class MenuGtk; | |
| 15 | 15 |
| 16 typedef struct _GtkWidget GtkWidget; | 16 typedef struct _GtkWidget GtkWidget; |
| 17 | 17 |
| 18 // When clicked, these buttons will navigate forward or backward. When | 18 // When clicked, these buttons will navigate forward or backward. When |
| 19 // pressed and held, they show a dropdown menu of recent web sites. | 19 // pressed and held, they show a dropdown menu of recent web sites. |
| 20 class BackForwardButtonGtk { | 20 class BackForwardButtonGtk : MenuGtk::Delegate { |
| 21 public: | 21 public: |
| 22 BackForwardButtonGtk(Browser* browser, bool is_forward); | 22 BackForwardButtonGtk(Browser* browser, bool is_forward); |
| 23 virtual ~BackForwardButtonGtk(); | 23 virtual ~BackForwardButtonGtk(); |
| 24 | 24 |
| 25 // The dropdown menu is no longer showing. | 25 // MenuGtk::Delegate implementation. |
| 26 void StoppedShowingMenu(); | 26 virtual void StoppedShowing(); |
| 27 virtual bool IsCommandEnabled(int command_id) const; |
| 28 virtual void ExecuteCommand(int command_id); |
| 29 bool AlwaysShowImages() const; |
| 27 | 30 |
| 28 GtkWidget* widget() { return button_->widget(); } | 31 GtkWidget* widget() { return button_->widget(); } |
| 29 | 32 |
| 30 private: | 33 private: |
| 31 // Executes the browser command. | 34 // Executes the browser command. |
| 32 static void OnClick(GtkWidget* widget, BackForwardButtonGtk* button); | 35 static void OnClick(GtkWidget* widget, BackForwardButtonGtk* button); |
| 33 | 36 |
| 34 // Starts a timer to show the dropdown menu. | 37 // Starts a timer to show the dropdown menu. |
| 35 static gboolean OnButtonPress(GtkWidget* button, | 38 static gboolean OnButtonPress(GtkWidget* button, |
| 36 GdkEventButton* event, | 39 GdkEventButton* event, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 scoped_ptr<MenuGtk> menu_; | 53 scoped_ptr<MenuGtk> menu_; |
| 51 | 54 |
| 52 scoped_ptr<CustomDrawButton> button_; | 55 scoped_ptr<CustomDrawButton> button_; |
| 53 | 56 |
| 54 // The browser to which we will send commands. | 57 // The browser to which we will send commands. |
| 55 Browser* browser_; | 58 Browser* browser_; |
| 56 | 59 |
| 57 // Whether this button is a forward button. | 60 // Whether this button is a forward button. |
| 58 bool is_forward_; | 61 bool is_forward_; |
| 59 | 62 |
| 60 // The dropdown menu delegate. | 63 // The dropdown menu model. |
| 61 scoped_ptr<BackForwardMenuModelGtk> menu_model_; | 64 scoped_ptr<BackForwardMenuModel> menu_model_; |
| 62 | 65 |
| 63 // The y position of the last mouse down event. | 66 // The y position of the last mouse down event. |
| 64 int y_position_of_last_press_; | 67 int y_position_of_last_press_; |
| 65 | 68 |
| 66 ScopedRunnableMethodFactory<BackForwardButtonGtk> show_menu_factory_; | 69 ScopedRunnableMethodFactory<BackForwardButtonGtk> show_menu_factory_; |
| 67 | 70 |
| 68 DISALLOW_COPY_AND_ASSIGN(BackForwardButtonGtk); | 71 DISALLOW_COPY_AND_ASSIGN(BackForwardButtonGtk); |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 #endif // CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ | 74 #endif // CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ |
| OLD | NEW |