Chromium Code Reviews| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 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/extensions/browser_action_overflow_menu_contro ller.h" | 11 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro ller.h" |
| 11 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" | 12 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" |
| 12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 13 #include "ui/base/animation/animation_delegate.h" | 14 #include "ui/base/animation/animation_delegate.h" |
| 14 #include "ui/base/animation/tween.h" | 15 #include "ui/base/animation/tween.h" |
| 15 #include "ui/views/controls/button/menu_button.h" | 16 #include "ui/views/controls/button/menu_button.h" |
| 16 #include "ui/views/controls/button/menu_button_listener.h" | 17 #include "ui/views/controls/button/menu_button_listener.h" |
| 17 #include "ui/views/controls/resize_area_delegate.h" | 18 #include "ui/views/controls/resize_area_delegate.h" |
| 18 #include "ui/views/drag_controller.h" | 19 #include "ui/views/drag_controller.h" |
| 19 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 // NOTE: When adding Browser Actions to a maximum width container (no overflow) | 99 // NOTE: When adding Browser Actions to a maximum width container (no overflow) |
| 99 // we make sure to suppress the chevron menu if it wasn't visible. This is | 100 // we make sure to suppress the chevron menu if it wasn't visible. This is |
| 100 // because we won't have enough space to show the new Browser Action until the | 101 // because we won't have enough space to show the new Browser Action until the |
| 101 // animation ends and we don't want the chevron to flash into view while we are | 102 // animation ends and we don't want the chevron to flash into view while we are |
| 102 // growing the container. | 103 // growing the container. |
| 103 // | 104 // |
| 104 //////////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////////// |
| 105 class BrowserActionsContainer | 106 class BrowserActionsContainer |
| 106 : public views::View, | 107 : public views::View, |
| 107 public views::MenuButtonListener, | 108 public views::MenuButtonListener, |
| 108 public views::DragController, | |
| 109 public views::ResizeAreaDelegate, | 109 public views::ResizeAreaDelegate, |
| 110 public ui::AnimationDelegate, | 110 public ui::AnimationDelegate, |
| 111 public ExtensionToolbarModel::Observer, | 111 public ExtensionToolbarModel::Observer, |
| 112 public BrowserActionOverflowMenuController::Observer, | 112 public BrowserActionOverflowMenuController::Observer, |
| 113 public views::Widget::Observer { | 113 public views::Widget::Observer, |
| 114 public BrowserActionView::Delegate { | |
| 114 public: | 115 public: |
| 115 BrowserActionsContainer(Browser* browser, views::View* owner_view); | 116 BrowserActionsContainer(Browser* browser, views::View* owner_view); |
| 116 virtual ~BrowserActionsContainer(); | 117 virtual ~BrowserActionsContainer(); |
| 117 | 118 |
| 118 void Init(); | 119 void Init(); |
| 119 | 120 |
| 120 // Get the number of browser actions being displayed. | 121 // Get the number of browser actions being displayed. |
| 121 int num_browser_actions() const { return browser_action_views_.size(); } | 122 int num_browser_actions() const { return browser_action_views_.size(); } |
| 122 | 123 |
| 123 // Whether we are performing resize animation on the container. | 124 // Whether we are performing resize animation on the container. |
| 124 bool animating() const { return animation_target_size_ > 0; } | 125 bool animating() const { return animation_target_size_ > 0; } |
| 125 | 126 |
| 126 // Returns the chevron, if any. | 127 // Returns the chevron, if any. |
| 127 views::View* chevron() { return chevron_; } | 128 views::View* chevron() { return chevron_; } |
| 128 const views::View* chevron() const { return chevron_; } | 129 const views::View* chevron() const { return chevron_; } |
| 129 | 130 |
| 130 // Returns the profile this container is associated with. | 131 // Returns the profile this container is associated with. |
| 131 Profile* profile() const { return profile_; } | 132 Profile* profile() const { return profile_; } |
| 132 | 133 |
| 133 // Returns the browser this container is associated with. | 134 // Returns the browser this container is associated with. |
| 134 Browser* browser() const { return browser_; } | 135 virtual Browser* GetBrowser() const; |
| 135 | 136 |
| 136 // Returns the current tab's ID, or -1 if there is no current tab. | 137 // Returns the current tab's ID, or -1 if there is no current tab. |
| 137 int GetCurrentTabId() const; | 138 virtual int GetCurrentTabId() const OVERRIDE; |
| 138 | 139 |
| 139 // Get a particular browser action view. | 140 // Get a particular browser action view. |
| 140 BrowserActionView* GetBrowserActionViewAt(int index) { | 141 BrowserActionView* GetBrowserActionViewAt(int index) { |
| 141 return browser_action_views_[index]; | 142 return browser_action_views_[index]; |
| 142 } | 143 } |
| 143 | 144 |
| 144 // Retrieve the BrowserActionView for |extension|. | 145 // Retrieve the BrowserActionView for |extension|. |
| 145 BrowserActionView* GetBrowserActionView(ExtensionAction* action); | 146 BrowserActionView* GetBrowserActionView(ExtensionAction* action); |
| 146 | 147 |
| 147 // Update the views to reflect the state of the browser action icons. | 148 // Update the views to reflect the state of the browser action icons. |
| 148 void RefreshBrowserActionViews(); | 149 void RefreshBrowserActionViews(); |
| 149 | 150 |
| 150 // Sets up the browser action view vector. | 151 // Sets up the browser action view vector. |
| 151 void CreateBrowserActionViews(); | 152 void CreateBrowserActionViews(); |
| 152 | 153 |
| 153 // Delete all browser action views. | 154 // Delete all browser action views. |
| 154 void DeleteBrowserActionViews(); | 155 void DeleteBrowserActionViews(); |
| 155 | 156 |
| 156 // Called when a browser action becomes visible/hidden. | 157 // Called when a browser action becomes visible/hidden. |
| 157 void OnBrowserActionVisibilityChanged(); | 158 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; |
| 159 | |
| 160 virtual gfx::Size GetViewContentOffset() const OVERRIDE; | |
|
Aaron Boodman
2012/07/02 22:41:34
Put these into a // Overrridden from BrowserAction
yefimt
2012/07/11 22:34:34
At least one function from BrowserActionView::Dele
| |
| 158 | 161 |
| 159 // Returns how many browser actions are visible. | 162 // Returns how many browser actions are visible. |
| 160 size_t VisibleBrowserActions() const; | 163 size_t VisibleBrowserActions() const; |
| 161 | 164 |
| 162 // Called when the user clicks on the browser action icon. | 165 // Called when the user clicks on the browser action icon. |
| 163 void OnBrowserActionExecuted(BrowserActionButton* button); | 166 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; |
| 164 | 167 |
| 165 // Overridden from views::View: | 168 // Overridden from views::View: |
| 166 virtual gfx::Size GetPreferredSize() OVERRIDE; | 169 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 167 virtual void Layout() OVERRIDE; | 170 virtual void Layout() OVERRIDE; |
| 168 virtual bool GetDropFormats(int* formats, | 171 virtual bool GetDropFormats(int* formats, |
| 169 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | 172 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; |
| 170 virtual bool AreDropTypesRequired() OVERRIDE; | 173 virtual bool AreDropTypesRequired() OVERRIDE; |
| 171 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; | 174 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
| 172 virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE; | 175 virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE; |
| 173 virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE; | 176 virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 | 367 |
| 365 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; | 368 base::WeakPtrFactory<BrowserActionsContainer> task_factory_; |
| 366 | 369 |
| 367 // Handles delayed showing of the overflow menu when hovering. | 370 // Handles delayed showing of the overflow menu when hovering. |
| 368 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; | 371 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; |
| 369 | 372 |
| 370 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 373 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 371 }; | 374 }; |
| 372 | 375 |
| 373 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 376 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| OLD | NEW |