OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "app/gtk_signal.h" | 9 #include "chrome/browser/ui/gtk/back_forward_button_gtk.h" |
10 #include "base/scoped_ptr.h" | 10 // TODO(msw): remove this file once all includes have been updated. |
11 #include "base/task.h" | |
12 #include "chrome/browser/gtk/custom_button.h" | |
13 #include "chrome/browser/gtk/menu_gtk.h" | |
14 | |
15 class BackForwardMenuModel; | |
16 class Browser; | |
17 | |
18 typedef struct _GtkWidget GtkWidget; | |
19 | |
20 // When clicked, these buttons will navigate forward or backward. When | |
21 // pressed and held, they show a dropdown menu of recent web sites. | |
22 class BackForwardButtonGtk : MenuGtk::Delegate { | |
23 public: | |
24 BackForwardButtonGtk(Browser* browser, bool is_forward); | |
25 virtual ~BackForwardButtonGtk(); | |
26 | |
27 // MenuGtk::Delegate implementation. | |
28 virtual void StoppedShowing(); | |
29 virtual bool AlwaysShowIconForCmd(int command_id) const; | |
30 | |
31 GtkWidget* widget() { return button_->widget(); } | |
32 | |
33 private: | |
34 // Executes the browser command. | |
35 CHROMEGTK_CALLBACK_0(BackForwardButtonGtk, void, OnClick); | |
36 | |
37 // Starts a timer to show the dropdown menu. | |
38 CHROMEGTK_CALLBACK_1(BackForwardButtonGtk, gboolean, OnButtonPress, | |
39 GdkEventButton*); | |
40 | |
41 // If there is a timer to show the dropdown menu, and the mouse has moved | |
42 // sufficiently down the screen, cancel the timer and immediately show the | |
43 // menu. | |
44 CHROMEGTK_CALLBACK_1(BackForwardButtonGtk, gboolean, OnMouseMove, | |
45 GdkEventMotion*); | |
46 | |
47 // Shows the dropdown menu. | |
48 void ShowBackForwardMenu(); | |
49 | |
50 // The menu gets reset every time it is shown. | |
51 scoped_ptr<MenuGtk> menu_; | |
52 | |
53 scoped_ptr<CustomDrawButton> button_; | |
54 | |
55 // The browser to which we will send commands. | |
56 Browser* browser_; | |
57 | |
58 // Whether this button is a forward button. | |
59 bool is_forward_; | |
60 | |
61 // The dropdown menu model. | |
62 scoped_ptr<BackForwardMenuModel> menu_model_; | |
63 | |
64 // The y position of the last mouse down event. | |
65 int y_position_of_last_press_; | |
66 | |
67 ScopedRunnableMethodFactory<BackForwardButtonGtk> show_menu_factory_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(BackForwardButtonGtk); | |
70 }; | |
71 | 11 |
72 #endif // CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ | 12 #endif // CHROME_BROWSER_GTK_BACK_FORWARD_BUTTON_GTK_H_ |
OLD | NEW |