| 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_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "app/slide_animation.h" | 12 #include "app/slide_animation.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "chrome/browser/extensions/extension_action_context_menu_model.h" |
| 14 #include "chrome/browser/extensions/extension_toolbar_model.h" | 15 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 15 #include "chrome/browser/extensions/image_loading_tracker.h" | 16 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 16 #include "chrome/browser/views/browser_bubble.h" | 17 #include "chrome/browser/views/browser_bubble.h" |
| 17 #include "chrome/browser/views/extensions/browser_action_overflow_menu_controlle
r.h" | 18 #include "chrome/browser/views/extensions/browser_action_overflow_menu_controlle
r.h" |
| 18 #include "chrome/browser/views/extensions/extension_action_context_menu.h" | 19 #include "chrome/browser/views/extensions/extension_action_context_menu.h" |
| 20 #include "chrome/browser/views/extensions/extension_popup.h" |
| 19 #include "chrome/common/notification_observer.h" | 21 #include "chrome/common/notification_observer.h" |
| 20 #include "chrome/common/notification_registrar.h" | 22 #include "chrome/common/notification_registrar.h" |
| 21 #include "views/controls/button/menu_button.h" | 23 #include "views/controls/button/menu_button.h" |
| 22 #include "views/controls/menu/view_menu_delegate.h" | 24 #include "views/controls/menu/view_menu_delegate.h" |
| 23 #include "views/controls/resize_gripper.h" | 25 #include "views/controls/resize_gripper.h" |
| 24 #include "views/view.h" | 26 #include "views/view.h" |
| 25 | 27 |
| 26 class Browser; | 28 class Browser; |
| 27 class BrowserActionsContainer; | 29 class BrowserActionsContainer; |
| 28 class BrowserActionOverflowMenuController; | 30 class BrowserActionOverflowMenuController; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // | 220 // |
| 219 // NOTE: When adding Browser Actions to a maximum width container (no overflow) | 221 // NOTE: When adding Browser Actions to a maximum width container (no overflow) |
| 220 // we make sure to suppress the chevron menu if it wasn't visible. This is | 222 // we make sure to suppress the chevron menu if it wasn't visible. This is |
| 221 // because we won't have enough space to show the new Browser Action until the | 223 // because we won't have enough space to show the new Browser Action until the |
| 222 // animation ends and we don't want the chevron to flash into view while we are | 224 // animation ends and we don't want the chevron to flash into view while we are |
| 223 // growing the container. | 225 // growing the container. |
| 224 // | 226 // |
| 225 //////////////////////////////////////////////////////////////////////////////// | 227 //////////////////////////////////////////////////////////////////////////////// |
| 226 class BrowserActionsContainer | 228 class BrowserActionsContainer |
| 227 : public views::View, | 229 : public views::View, |
| 228 public NotificationObserver, | |
| 229 public BrowserBubble::Delegate, | |
| 230 public views::ViewMenuDelegate, | 230 public views::ViewMenuDelegate, |
| 231 public views::DragController, | 231 public views::DragController, |
| 232 public views::ResizeGripper::ResizeGripperDelegate, | 232 public views::ResizeGripper::ResizeGripperDelegate, |
| 233 public AnimationDelegate, | 233 public AnimationDelegate, |
| 234 public ExtensionToolbarModel::Observer, | 234 public ExtensionToolbarModel::Observer, |
| 235 public BrowserActionOverflowMenuController::Observer { | 235 public BrowserActionOverflowMenuController::Observer, |
| 236 public ExtensionActionContextMenuModel::MenuDelegate, |
| 237 public ExtensionPopup::Observer { |
| 238 |
| 236 friend class ShowFolderMenuTask; | 239 friend class ShowFolderMenuTask; |
| 237 public: | 240 public: |
| 238 BrowserActionsContainer(Browser* browser, views::View* owner_view); | 241 BrowserActionsContainer(Browser* browser, views::View* owner_view); |
| 239 virtual ~BrowserActionsContainer(); | 242 virtual ~BrowserActionsContainer(); |
| 240 | 243 |
| 241 static void RegisterUserPrefs(PrefService* prefs); | 244 static void RegisterUserPrefs(PrefService* prefs); |
| 242 | 245 |
| 243 // Get the number of browser actions being displayed. | 246 // Get the number of browser actions being displayed. |
| 244 int num_browser_actions() const { return browser_action_views_.size(); } | 247 int num_browser_actions() const { return browser_action_views_.size(); } |
| 245 | 248 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Delete all browser action views. | 280 // Delete all browser action views. |
| 278 void DeleteBrowserActionViews(); | 281 void DeleteBrowserActionViews(); |
| 279 | 282 |
| 280 // Called when a browser action becomes visible/hidden. | 283 // Called when a browser action becomes visible/hidden. |
| 281 void OnBrowserActionVisibilityChanged(); | 284 void OnBrowserActionVisibilityChanged(); |
| 282 | 285 |
| 283 // Returns how many browser actions are visible. | 286 // Returns how many browser actions are visible. |
| 284 size_t VisibleBrowserActions() const; | 287 size_t VisibleBrowserActions() const; |
| 285 | 288 |
| 286 // Called when the user clicks on the browser action icon. | 289 // Called when the user clicks on the browser action icon. |
| 287 void OnBrowserActionExecuted(BrowserActionButton* button); | 290 void OnBrowserActionExecuted(BrowserActionButton* button, |
| 291 bool inspect_with_devtools); |
| 288 | 292 |
| 289 // Overridden from views::View: | 293 // Overridden from views::View: |
| 290 virtual gfx::Size GetPreferredSize(); | 294 virtual gfx::Size GetPreferredSize(); |
| 291 virtual void Layout(); | 295 virtual void Layout(); |
| 292 virtual void Paint(gfx::Canvas* canvas); | 296 virtual void Paint(gfx::Canvas* canvas); |
| 293 virtual void ViewHierarchyChanged(bool is_add, | 297 virtual void ViewHierarchyChanged(bool is_add, |
| 294 views::View* parent, | 298 views::View* parent, |
| 295 views::View* child); | 299 views::View* child); |
| 296 virtual bool GetDropFormats( | 300 virtual bool GetDropFormats( |
| 297 int* formats, std::set<OSExchangeData::CustomFormat>* custom_formats); | 301 int* formats, std::set<OSExchangeData::CustomFormat>* custom_formats); |
| 298 virtual bool AreDropTypesRequired(); | 302 virtual bool AreDropTypesRequired(); |
| 299 virtual bool CanDrop(const OSExchangeData& data); | 303 virtual bool CanDrop(const OSExchangeData& data); |
| 300 virtual void OnDragEntered(const views::DropTargetEvent& event); | 304 virtual void OnDragEntered(const views::DropTargetEvent& event); |
| 301 virtual int OnDragUpdated(const views::DropTargetEvent& event); | 305 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
| 302 virtual void OnDragExited(); | 306 virtual void OnDragExited(); |
| 303 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 307 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
| 304 | 308 |
| 305 // Overridden from NotificationObserver: | |
| 306 virtual void Observe(NotificationType type, | |
| 307 const NotificationSource& source, | |
| 308 const NotificationDetails& details); | |
| 309 | |
| 310 // BrowserBubble::Delegate methods. | |
| 311 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); | |
| 312 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); | |
| 313 virtual void BubbleGotFocus(BrowserBubble* bubble); | |
| 314 virtual void BubbleLostFocus(BrowserBubble* bubble, bool lost_focus_to_child); | |
| 315 | |
| 316 // Overridden from views::ViewMenuDelegate: | 309 // Overridden from views::ViewMenuDelegate: |
| 317 virtual void RunMenu(View* source, const gfx::Point& pt); | 310 virtual void RunMenu(View* source, const gfx::Point& pt); |
| 318 | 311 |
| 319 // Overridden from views::DragController: | 312 // Overridden from views::DragController: |
| 320 virtual void WriteDragData(View* sender, | 313 virtual void WriteDragData(View* sender, |
| 321 const gfx::Point& press_pt, | 314 const gfx::Point& press_pt, |
| 322 OSExchangeData* data); | 315 OSExchangeData* data); |
| 323 virtual int GetDragOperations(View* sender, const gfx::Point& p); | 316 virtual int GetDragOperations(View* sender, const gfx::Point& p); |
| 324 virtual bool CanStartDrag(View* sender, | 317 virtual bool CanStartDrag(View* sender, |
| 325 const gfx::Point& press_pt, | 318 const gfx::Point& press_pt, |
| 326 const gfx::Point& p); | 319 const gfx::Point& p); |
| 327 | 320 |
| 328 // Overridden from ResizeGripper::ResizeGripperDelegate: | 321 // Overridden from ResizeGripper::ResizeGripperDelegate: |
| 329 virtual void OnResize(int resize_amount, bool done_resizing); | 322 virtual void OnResize(int resize_amount, bool done_resizing); |
| 330 | 323 |
| 331 // Overridden from AnimationDelegate: | 324 // Overridden from AnimationDelegate: |
| 332 virtual void AnimationProgressed(const Animation* animation); | 325 virtual void AnimationProgressed(const Animation* animation); |
| 333 virtual void AnimationEnded(const Animation* animation); | 326 virtual void AnimationEnded(const Animation* animation); |
| 334 | 327 |
| 335 // Overridden from BrowserActionOverflowMenuController::Observer: | 328 // Overridden from BrowserActionOverflowMenuController::Observer: |
| 336 virtual void NotifyMenuDeleted( | 329 virtual void NotifyMenuDeleted( |
| 337 BrowserActionOverflowMenuController* controller); | 330 BrowserActionOverflowMenuController* controller); |
| 338 | 331 |
| 332 // Overridden from ExtensionActionContextMenuModel::MenuDelegate |
| 333 virtual void ShowPopupForDevToolsWindow(Extension* extension, |
| 334 ExtensionAction* extension_action); |
| 335 |
| 336 // Overriden from ExtensionPopup::Delegate |
| 337 virtual void ExtensionPopupClosed(ExtensionPopup* popup); |
| 338 |
| 339 // Moves a browser action with |id| to |new_index|. | 339 // Moves a browser action with |id| to |new_index|. |
| 340 void MoveBrowserAction(const std::string& extension_id, size_t new_index); | 340 void MoveBrowserAction(const std::string& extension_id, size_t new_index); |
| 341 | 341 |
| 342 // Hide the current popup. | 342 // Hide the current popup. |
| 343 void HidePopup(); | 343 void HidePopup(); |
| 344 | 344 |
| 345 // Simulate a click on a browser action button. This should only be | 345 // Simulate a click on a browser action button. This should only be |
| 346 // used by unit tests. | 346 // used by unit tests. |
| 347 void TestExecuteBrowserAction(int index); | 347 void TestExecuteBrowserAction(int index); |
| 348 | 348 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // Returns true if this extension should be shown in this toolbar. This can | 411 // Returns true if this extension should be shown in this toolbar. This can |
| 412 // return false if we are in an incognito window and the extension is disabled | 412 // return false if we are in an incognito window and the extension is disabled |
| 413 // for incognito. | 413 // for incognito. |
| 414 bool ShouldDisplayBrowserAction(Extension* extension); | 414 bool ShouldDisplayBrowserAction(Extension* extension); |
| 415 | 415 |
| 416 // The vector of browser actions (icons/image buttons for each action). Note | 416 // The vector of browser actions (icons/image buttons for each action). Note |
| 417 // that not every BrowserAction in the ToolbarModel will necessarily be in | 417 // that not every BrowserAction in the ToolbarModel will necessarily be in |
| 418 // this collection. Some extensions may be disabled in incognito windows. | 418 // this collection. Some extensions may be disabled in incognito windows. |
| 419 BrowserActionViews browser_action_views_; | 419 BrowserActionViews browser_action_views_; |
| 420 | 420 |
| 421 NotificationRegistrar registrar_; | |
| 422 | |
| 423 Profile* profile_; | 421 Profile* profile_; |
| 424 | 422 |
| 425 // The Browser object the container is associated with. | 423 // The Browser object the container is associated with. |
| 426 Browser* browser_; | 424 Browser* browser_; |
| 427 | 425 |
| 428 // The view that owns us. | 426 // The view that owns us. |
| 429 views::View* owner_view_; | 427 views::View* owner_view_; |
| 430 | 428 |
| 431 // The current popup and the button it came from. NULL if no popup. | 429 // The current popup and the button it came from. NULL if no popup. |
| 432 ExtensionPopup* popup_; | 430 ExtensionPopup* popup_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 473 |
| 476 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; | 474 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; |
| 477 | 475 |
| 478 // Handles delayed showing of the overflow menu when hovering. | 476 // Handles delayed showing of the overflow menu when hovering. |
| 479 ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_; | 477 ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_; |
| 480 | 478 |
| 481 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 479 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 482 }; | 480 }; |
| 483 | 481 |
| 484 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 482 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| OLD | NEW |