OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 8 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
9 #include "chrome/browser/extensions/extension_toolbar_model.h" | 9 #include "chrome/browser/extensions/extension_toolbar_model.h" |
10 #include "chrome/browser/ui/views/browser_action_view.h" | 10 #include "chrome/browser/ui/views/browser_action_view.h" |
11 #include "chrome/browser/ui/views/chrome_views_export.h" | 11 #include "chrome/browser/ui/views/chrome_views_export.h" |
12 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro
ller.h" | 12 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro
ller.h" |
13 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 13 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
14 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 14 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
16 #include "ui/base/animation/animation_delegate.h" | 16 #include "ui/gfx/animation/animation_delegate.h" |
17 #include "ui/base/animation/tween.h" | 17 #include "ui/gfx/animation/tween.h" |
18 #include "ui/views/controls/button/menu_button.h" | 18 #include "ui/views/controls/button/menu_button.h" |
19 #include "ui/views/controls/button/menu_button_listener.h" | 19 #include "ui/views/controls/button/menu_button_listener.h" |
20 #include "ui/views/controls/resize_area_delegate.h" | 20 #include "ui/views/controls/resize_area_delegate.h" |
21 #include "ui/views/drag_controller.h" | 21 #include "ui/views/drag_controller.h" |
22 #include "ui/views/view.h" | 22 #include "ui/views/view.h" |
23 #include "ui/views/widget/widget_observer.h" | 23 #include "ui/views/widget/widget_observer.h" |
24 | 24 |
25 class BrowserActionButton; | 25 class BrowserActionButton; |
26 class ExtensionKeybindingRegistryViews; | 26 class ExtensionKeybindingRegistryViews; |
27 class ExtensionPopup; | 27 class ExtensionPopup; |
28 | 28 |
29 namespace extensions { | 29 namespace extensions { |
30 class ActiveTabPermissionGranter; | 30 class ActiveTabPermissionGranter; |
31 } | 31 } |
32 | 32 |
33 namespace ui { | 33 namespace gfx { |
34 class SlideAnimation; | 34 class SlideAnimation; |
35 } | 35 } |
36 | 36 |
37 namespace views { | 37 namespace views { |
38 class ResizeArea; | 38 class ResizeArea; |
39 } | 39 } |
40 | 40 |
41 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
42 // | 42 // |
43 // The BrowserActionsContainer is a container view, responsible for drawing the | 43 // The BrowserActionsContainer is a container view, responsible for drawing the |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // we make sure to suppress the chevron menu if it wasn't visible. This is | 107 // we make sure to suppress the chevron menu if it wasn't visible. This is |
108 // because we won't have enough space to show the new Browser Action until the | 108 // because we won't have enough space to show the new Browser Action until the |
109 // animation ends and we don't want the chevron to flash into view while we are | 109 // animation ends and we don't want the chevron to flash into view while we are |
110 // growing the container. | 110 // growing the container. |
111 // | 111 // |
112 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
113 class BrowserActionsContainer | 113 class BrowserActionsContainer |
114 : public views::View, | 114 : public views::View, |
115 public views::MenuButtonListener, | 115 public views::MenuButtonListener, |
116 public views::ResizeAreaDelegate, | 116 public views::ResizeAreaDelegate, |
117 public ui::AnimationDelegate, | 117 public gfx::AnimationDelegate, |
118 public ExtensionToolbarModel::Observer, | 118 public ExtensionToolbarModel::Observer, |
119 public BrowserActionOverflowMenuController::Observer, | 119 public BrowserActionOverflowMenuController::Observer, |
120 public views::WidgetObserver, | 120 public views::WidgetObserver, |
121 public BrowserActionView::Delegate, | 121 public BrowserActionView::Delegate, |
122 public extensions::ExtensionKeybindingRegistry::Delegate { | 122 public extensions::ExtensionKeybindingRegistry::Delegate { |
123 public: | 123 public: |
124 BrowserActionsContainer(Browser* browser, views::View* owner_view); | 124 BrowserActionsContainer(Browser* browser, views::View* owner_view); |
125 virtual ~BrowserActionsContainer(); | 125 virtual ~BrowserActionsContainer(); |
126 | 126 |
127 void Init(); | 127 void Init(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 ui::OSExchangeData* data) OVERRIDE; | 182 ui::OSExchangeData* data) OVERRIDE; |
183 virtual int GetDragOperationsForView(View* sender, | 183 virtual int GetDragOperationsForView(View* sender, |
184 const gfx::Point& p) OVERRIDE; | 184 const gfx::Point& p) OVERRIDE; |
185 virtual bool CanStartDragForView(View* sender, | 185 virtual bool CanStartDragForView(View* sender, |
186 const gfx::Point& press_pt, | 186 const gfx::Point& press_pt, |
187 const gfx::Point& p) OVERRIDE; | 187 const gfx::Point& p) OVERRIDE; |
188 | 188 |
189 // Overridden from views::ResizeAreaDelegate: | 189 // Overridden from views::ResizeAreaDelegate: |
190 virtual void OnResize(int resize_amount, bool done_resizing) OVERRIDE; | 190 virtual void OnResize(int resize_amount, bool done_resizing) OVERRIDE; |
191 | 191 |
192 // Overridden from ui::AnimationDelegate: | 192 // Overridden from gfx::AnimationDelegate: |
193 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 193 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
194 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 194 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
195 | 195 |
196 // Overridden from BrowserActionOverflowMenuController::Observer: | 196 // Overridden from BrowserActionOverflowMenuController::Observer: |
197 virtual void NotifyMenuDeleted( | 197 virtual void NotifyMenuDeleted( |
198 BrowserActionOverflowMenuController* controller) OVERRIDE; | 198 BrowserActionOverflowMenuController* controller) OVERRIDE; |
199 | 199 |
200 // Overridden from views::WidgetObserver: | 200 // Overridden from views::WidgetObserver: |
201 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 201 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
202 | 202 |
203 // Overridden from BrowserActionView::Delegate: | 203 // Overridden from BrowserActionView::Delegate: |
204 virtual void InspectPopup(ExtensionAction* action) OVERRIDE; | 204 virtual void InspectPopup(ExtensionAction* action) OVERRIDE; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 // Returns the absolute minimum size you can shrink the container down to and | 295 // Returns the absolute minimum size you can shrink the container down to and |
296 // still show it. This assumes a visible chevron because the only way we | 296 // still show it. This assumes a visible chevron because the only way we |
297 // would not have a chevron when shrinking down this far is if there were no | 297 // would not have a chevron when shrinking down this far is if there were no |
298 // icons, in which case the container wouldn't be shown at all. | 298 // icons, in which case the container wouldn't be shown at all. |
299 int ContainerMinSize() const; | 299 int ContainerMinSize() const; |
300 | 300 |
301 // Animate to the target size (unless testing, in which case we go straight to | 301 // Animate to the target size (unless testing, in which case we go straight to |
302 // the target size). This also saves the target number of visible icons in | 302 // the target size). This also saves the target number of visible icons in |
303 // the pref if we're not incognito. | 303 // the pref if we're not incognito. |
304 void SaveDesiredSizeAndAnimate(ui::Tween::Type type, | 304 void SaveDesiredSizeAndAnimate(gfx::Tween::Type type, |
305 size_t num_visible_icons); | 305 size_t num_visible_icons); |
306 | 306 |
307 // Returns true if this extension should be shown in this toolbar. This can | 307 // Returns true if this extension should be shown in this toolbar. This can |
308 // return false if we are in an incognito window and the extension is disabled | 308 // return false if we are in an incognito window and the extension is disabled |
309 // for incognito. | 309 // for incognito. |
310 bool ShouldDisplayBrowserAction(const extensions::Extension* extension); | 310 bool ShouldDisplayBrowserAction(const extensions::Extension* extension); |
311 | 311 |
312 // Show a popup. | 312 // Show a popup. |
313 void ShowPopup(BrowserActionButton* button, | 313 void ShowPopup(BrowserActionButton* button, |
314 ExtensionPopup::ShowAction show_action); | 314 ExtensionPopup::ShowAction show_action); |
(...skipping 28 matching lines...) Expand all Loading... |
343 views::ResizeArea* resize_area_; | 343 views::ResizeArea* resize_area_; |
344 | 344 |
345 // The chevron for accessing the overflow items. | 345 // The chevron for accessing the overflow items. |
346 views::MenuButton* chevron_; | 346 views::MenuButton* chevron_; |
347 | 347 |
348 // The menu to show for the overflow button (chevron). This class manages its | 348 // The menu to show for the overflow button (chevron). This class manages its |
349 // own lifetime so that it can stay alive during drag and drop operations. | 349 // own lifetime so that it can stay alive during drag and drop operations. |
350 BrowserActionOverflowMenuController* overflow_menu_; | 350 BrowserActionOverflowMenuController* overflow_menu_; |
351 | 351 |
352 // The animation that happens when the container snaps to place. | 352 // The animation that happens when the container snaps to place. |
353 scoped_ptr<ui::SlideAnimation> resize_animation_; | 353 scoped_ptr<gfx::SlideAnimation> resize_animation_; |
354 | 354 |
355 // Don't show the chevron while animating. | 355 // Don't show the chevron while animating. |
356 bool suppress_chevron_; | 356 bool suppress_chevron_; |
357 | 357 |
358 // This is used while the user is resizing (and when the animations are in | 358 // This is used while the user is resizing (and when the animations are in |
359 // progress) to know how wide the delta is between the current state and what | 359 // progress) to know how wide the delta is between the current state and what |
360 // we should draw. | 360 // we should draw. |
361 int resize_amount_; | 361 int resize_amount_; |
362 | 362 |
363 // Keeps track of the absolute pixel width the container should have when we | 363 // Keeps track of the absolute pixel width the container should have when we |
364 // are done animating. | 364 // are done animating. |
365 int animation_target_size_; | 365 int animation_target_size_; |
366 | 366 |
367 // The x position for where to draw the drop indicator. -1 if no indicator. | 367 // The x position for where to draw the drop indicator. -1 if no indicator. |
368 int drop_indicator_position_; | 368 int drop_indicator_position_; |
369 | 369 |
370 // The class that registers for keyboard shortcuts for extension commands. | 370 // The class that registers for keyboard shortcuts for extension commands. |
371 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | 371 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; |
372 | 372 |
373 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; | 373 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; |
374 | 374 |
375 // Handles delayed showing of the overflow menu when hovering. | 375 // Handles delayed showing of the overflow menu when hovering. |
376 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; | 376 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; |
377 | 377 |
378 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 378 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
379 }; | 379 }; |
380 | 380 |
381 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 381 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
OLD | NEW |