OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_ACTIONS_TOOLBAR_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_ |
6 #define CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "app/animation_delegate.h" | |
13 #include "app/gtk_signal.h" | 12 #include "app/gtk_signal.h" |
14 #include "app/gtk_signal_registrar.h" | 13 #include "app/gtk_signal_registrar.h" |
15 #include "app/menus/simple_menu_model.h" | 14 #include "app/menus/simple_menu_model.h" |
16 #include "app/slide_animation.h" | |
17 #include "base/linked_ptr.h" | 15 #include "base/linked_ptr.h" |
18 #include "base/task.h" | 16 #include "base/task.h" |
19 #include "chrome/browser/extensions/extension_toolbar_model.h" | 17 #include "chrome/browser/extensions/extension_toolbar_model.h" |
20 #include "chrome/browser/gtk/custom_button.h" | 18 #include "chrome/browser/gtk/custom_button.h" |
21 #include "chrome/browser/gtk/menu_gtk.h" | 19 #include "chrome/browser/gtk/menu_gtk.h" |
22 #include "chrome/browser/gtk/overflow_button.h" | 20 #include "chrome/browser/gtk/overflow_button.h" |
23 #include "chrome/browser/gtk/owned_widget_gtk.h" | 21 #include "chrome/browser/gtk/owned_widget_gtk.h" |
24 #include "chrome/common/notification_observer.h" | 22 #include "chrome/common/notification_observer.h" |
25 #include "chrome/common/notification_registrar.h" | 23 #include "chrome/common/notification_registrar.h" |
| 24 #include "ui/base/animation/animation_delegate.h" |
| 25 #include "ui/base/animation/slide_animation.h" |
26 | 26 |
27 class Browser; | 27 class Browser; |
28 class BrowserActionButton; | 28 class BrowserActionButton; |
29 class Extension; | 29 class Extension; |
30 class GtkThemeProvider; | 30 class GtkThemeProvider; |
31 class Profile; | 31 class Profile; |
32 | 32 |
33 typedef struct _GdkDragContext GdkDragContext; | 33 typedef struct _GdkDragContext GdkDragContext; |
34 typedef struct _GtkWidget GtkWidget; | 34 typedef struct _GtkWidget GtkWidget; |
35 | 35 |
36 class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer, | 36 class BrowserActionsToolbarGtk : public ExtensionToolbarModel::Observer, |
37 public AnimationDelegate, | 37 public ui::AnimationDelegate, |
38 public MenuGtk::Delegate, | 38 public MenuGtk::Delegate, |
39 public menus::SimpleMenuModel::Delegate, | 39 public menus::SimpleMenuModel::Delegate, |
40 public NotificationObserver { | 40 public NotificationObserver { |
41 public: | 41 public: |
42 explicit BrowserActionsToolbarGtk(Browser* browser); | 42 explicit BrowserActionsToolbarGtk(Browser* browser); |
43 virtual ~BrowserActionsToolbarGtk(); | 43 virtual ~BrowserActionsToolbarGtk(); |
44 | 44 |
45 GtkWidget* widget() { return hbox_.get(); } | 45 GtkWidget* widget() { return hbox_.get(); } |
46 GtkWidget* chevron() { return overflow_button_->widget(); } | 46 GtkWidget* chevron() { return overflow_button_->widget(); } |
47 | 47 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // return false if we are in an incognito window and the extension is disabled | 104 // return false if we are in an incognito window and the extension is disabled |
105 // for incognito. | 105 // for incognito. |
106 bool ShouldDisplayBrowserAction(const Extension* extension); | 106 bool ShouldDisplayBrowserAction(const Extension* extension); |
107 | 107 |
108 // ExtensionToolbarModel::Observer implementation. | 108 // ExtensionToolbarModel::Observer implementation. |
109 virtual void BrowserActionAdded(const Extension* extension, int index); | 109 virtual void BrowserActionAdded(const Extension* extension, int index); |
110 virtual void BrowserActionRemoved(const Extension* extension); | 110 virtual void BrowserActionRemoved(const Extension* extension); |
111 virtual void BrowserActionMoved(const Extension* extension, int index); | 111 virtual void BrowserActionMoved(const Extension* extension, int index); |
112 virtual void ModelLoaded(); | 112 virtual void ModelLoaded(); |
113 | 113 |
114 // AnimationDelegate implementation. | 114 // ui::AnimationDelegate implementation. |
115 virtual void AnimationProgressed(const Animation* animation); | 115 virtual void AnimationProgressed(const ui::Animation* animation); |
116 virtual void AnimationEnded(const Animation* animation); | 116 virtual void AnimationEnded(const ui::Animation* animation); |
117 | 117 |
118 // SimpleMenuModel::Delegate implementation. | 118 // SimpleMenuModel::Delegate implementation. |
119 // In our case, |command_id| is be the index into the model's extension list. | 119 // In our case, |command_id| is be the index into the model's extension list. |
120 virtual bool IsCommandIdChecked(int command_id) const; | 120 virtual bool IsCommandIdChecked(int command_id) const; |
121 virtual bool IsCommandIdEnabled(int command_id) const; | 121 virtual bool IsCommandIdEnabled(int command_id) const; |
122 virtual bool GetAcceleratorForCommandId( | 122 virtual bool GetAcceleratorForCommandId( |
123 int command_id, | 123 int command_id, |
124 menus::Accelerator* accelerator); | 124 menus::Accelerator* accelerator); |
125 virtual void ExecuteCommand(int command_id); | 125 virtual void ExecuteCommand(int command_id); |
126 | 126 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 int drop_index_; | 198 int drop_index_; |
199 | 199 |
200 // Map from extension ID to BrowserActionButton, which is a wrapper for | 200 // Map from extension ID to BrowserActionButton, which is a wrapper for |
201 // a chrome button and related functionality. There should be one entry | 201 // a chrome button and related functionality. There should be one entry |
202 // for every extension that has a browser action. | 202 // for every extension that has a browser action. |
203 typedef std::map<std::string, linked_ptr<BrowserActionButton> > | 203 typedef std::map<std::string, linked_ptr<BrowserActionButton> > |
204 ExtensionButtonMap; | 204 ExtensionButtonMap; |
205 ExtensionButtonMap extension_button_map_; | 205 ExtensionButtonMap extension_button_map_; |
206 | 206 |
207 // We use this animation for the smart resizing of the toolbar. | 207 // We use this animation for the smart resizing of the toolbar. |
208 SlideAnimation resize_animation_; | 208 ui::SlideAnimation resize_animation_; |
209 // This is the final width we are animating towards. | 209 // This is the final width we are animating towards. |
210 int desired_width_; | 210 int desired_width_; |
211 // This is the width we were at when we started animating. | 211 // This is the width we were at when we started animating. |
212 int start_width_; | 212 int start_width_; |
213 | 213 |
214 GtkSignalRegistrar signals_; | 214 GtkSignalRegistrar signals_; |
215 | 215 |
216 NotificationRegistrar registrar_; | 216 NotificationRegistrar registrar_; |
217 | 217 |
218 ScopedRunnableMethodFactory<BrowserActionsToolbarGtk> method_factory_; | 218 ScopedRunnableMethodFactory<BrowserActionsToolbarGtk> method_factory_; |
219 | 219 |
220 DISALLOW_COPY_AND_ASSIGN(BrowserActionsToolbarGtk); | 220 DISALLOW_COPY_AND_ASSIGN(BrowserActionsToolbarGtk); |
221 }; | 221 }; |
222 | 222 |
223 #endif // CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_ | 223 #endif // CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_ |
OLD | NEW |