OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
7 | 7 |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
10 #include "chrome/browser/extensions/extension_toolbar_model.h" | 10 #include "chrome/browser/extensions/extension_toolbar_model.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 public extensions::ExtensionKeybindingRegistry::Delegate { | 130 public extensions::ExtensionKeybindingRegistry::Delegate { |
131 public: | 131 public: |
132 // Horizontal spacing between most items in the container, as well as after | 132 // Horizontal spacing between most items in the container, as well as after |
133 // the last item or chevron (if visible). | 133 // the last item or chevron (if visible). |
134 static const int kItemSpacing; | 134 static const int kItemSpacing; |
135 | 135 |
136 // Constructs a BrowserActionContainer for a particular |browser| object. For | 136 // Constructs a BrowserActionContainer for a particular |browser| object. For |
137 // documentation of |main_container|, see class comments. | 137 // documentation of |main_container|, see class comments. |
138 BrowserActionsContainer(Browser* browser, | 138 BrowserActionsContainer(Browser* browser, |
139 BrowserActionsContainer* main_container); | 139 BrowserActionsContainer* main_container); |
140 virtual ~BrowserActionsContainer(); | 140 ~BrowserActionsContainer() override; |
141 | 141 |
142 void Init(); | 142 void Init(); |
143 | 143 |
144 // Get the number of browser actions being displayed. | 144 // Get the number of browser actions being displayed. |
145 size_t num_browser_actions() const { return browser_action_views_.size(); } | 145 size_t num_browser_actions() const { return browser_action_views_.size(); } |
146 | 146 |
147 // Whether we are performing resize animation on the container. | 147 // Whether we are performing resize animation on the container. |
148 bool animating() const { return animation_target_size_ > 0; } | 148 bool animating() const { return animation_target_size_ > 0; } |
149 | 149 |
150 // Returns the chevron, if any. | 150 // Returns the chevron, if any. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 // Notify the browser action container that an extension has been moved to | 198 // Notify the browser action container that an extension has been moved to |
199 // the overflow container. | 199 // the overflow container. |
200 void NotifyActionMovedToOverflow(); | 200 void NotifyActionMovedToOverflow(); |
201 | 201 |
202 // Add or remove an observer. | 202 // Add or remove an observer. |
203 void AddObserver(BrowserActionsContainerObserver* observer); | 203 void AddObserver(BrowserActionsContainerObserver* observer); |
204 void RemoveObserver(BrowserActionsContainerObserver* observer); | 204 void RemoveObserver(BrowserActionsContainerObserver* observer); |
205 | 205 |
206 // Overridden from views::View: | 206 // Overridden from views::View: |
207 virtual gfx::Size GetPreferredSize() const override; | 207 gfx::Size GetPreferredSize() const override; |
208 virtual int GetHeightForWidth(int width) const override; | 208 int GetHeightForWidth(int width) const override; |
209 virtual gfx::Size GetMinimumSize() const override; | 209 gfx::Size GetMinimumSize() const override; |
210 virtual void Layout() override; | 210 void Layout() override; |
211 virtual bool GetDropFormats(int* formats, | 211 bool GetDropFormats( |
| 212 int* formats, |
212 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; | 213 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; |
213 virtual bool AreDropTypesRequired() override; | 214 bool AreDropTypesRequired() override; |
214 virtual bool CanDrop(const ui::OSExchangeData& data) override; | 215 bool CanDrop(const ui::OSExchangeData& data) override; |
215 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override; | 216 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
216 virtual void OnDragExited() override; | 217 void OnDragExited() override; |
217 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override; | 218 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
218 virtual void GetAccessibleState(ui::AXViewState* state) override; | 219 void GetAccessibleState(ui::AXViewState* state) override; |
219 | 220 |
220 // Overridden from views::DragController: | 221 // Overridden from views::DragController: |
221 virtual void WriteDragDataForView(View* sender, | 222 void WriteDragDataForView(View* sender, |
222 const gfx::Point& press_pt, | 223 const gfx::Point& press_pt, |
223 ui::OSExchangeData* data) override; | 224 ui::OSExchangeData* data) override; |
224 virtual int GetDragOperationsForView(View* sender, | 225 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; |
225 const gfx::Point& p) override; | 226 bool CanStartDragForView(View* sender, |
226 virtual bool CanStartDragForView(View* sender, | 227 const gfx::Point& press_pt, |
227 const gfx::Point& press_pt, | 228 const gfx::Point& p) override; |
228 const gfx::Point& p) override; | |
229 | 229 |
230 // Overridden from views::ResizeAreaDelegate: | 230 // Overridden from views::ResizeAreaDelegate: |
231 virtual void OnResize(int resize_amount, bool done_resizing) override; | 231 void OnResize(int resize_amount, bool done_resizing) override; |
232 | 232 |
233 // Overridden from gfx::AnimationDelegate: | 233 // Overridden from gfx::AnimationDelegate: |
234 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 234 void AnimationProgressed(const gfx::Animation* animation) override; |
235 virtual void AnimationEnded(const gfx::Animation* animation) override; | 235 void AnimationEnded(const gfx::Animation* animation) override; |
236 | 236 |
237 // Overridden from BrowserActionView::Delegate: | 237 // Overridden from BrowserActionView::Delegate: |
238 virtual content::WebContents* GetCurrentWebContents() override; | 238 content::WebContents* GetCurrentWebContents() override; |
239 virtual bool ShownInsideMenu() const override; | 239 bool ShownInsideMenu() const override; |
240 virtual void OnBrowserActionViewDragDone() override; | 240 void OnBrowserActionViewDragDone() override; |
241 virtual views::MenuButton* GetOverflowReferenceView() override; | 241 views::MenuButton* GetOverflowReferenceView() override; |
242 virtual void SetPopupOwner(BrowserActionView* popup_owner) override; | 242 void SetPopupOwner(BrowserActionView* popup_owner) override; |
243 virtual void HideActivePopup() override; | 243 void HideActivePopup() override; |
244 virtual BrowserActionView* GetMainViewForAction( | 244 BrowserActionView* GetMainViewForAction(BrowserActionView* view) override; |
245 BrowserActionView* view) override; | |
246 | 245 |
247 // Overridden from extension::ExtensionKeybindingRegistry::Delegate: | 246 // Overridden from extension::ExtensionKeybindingRegistry::Delegate: |
248 virtual extensions::ActiveTabPermissionGranter* | 247 extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter() |
249 GetActiveTabPermissionGranter() override; | 248 override; |
250 | 249 |
251 // Retrieve the current popup. This should only be used by unit tests. | 250 // Retrieve the current popup. This should only be used by unit tests. |
252 gfx::NativeView TestGetPopup(); | 251 gfx::NativeView TestGetPopup(); |
253 | 252 |
254 // Returns the width of an icon, optionally with its padding. | 253 // Returns the width of an icon, optionally with its padding. |
255 static int IconWidth(bool include_padding); | 254 static int IconWidth(bool include_padding); |
256 | 255 |
257 // Returns the height of an icon. | 256 // Returns the height of an icon. |
258 static int IconHeight(); | 257 static int IconHeight(); |
259 | 258 |
260 // During testing we can disable animations by setting this flag to true, | 259 // During testing we can disable animations by setting this flag to true, |
261 // so that the bar resizes instantly, instead of having to poll it while it | 260 // so that the bar resizes instantly, instead of having to poll it while it |
262 // animates to open/closed status. | 261 // animates to open/closed status. |
263 static bool disable_animations_during_testing_; | 262 static bool disable_animations_during_testing_; |
264 | 263 |
265 protected: | 264 protected: |
266 // Overridden from views::View: | 265 // Overridden from views::View: |
267 virtual void ViewHierarchyChanged( | 266 void ViewHierarchyChanged( |
268 const ViewHierarchyChangedDetails& details) override; | 267 const ViewHierarchyChangedDetails& details) override; |
269 virtual void OnPaint(gfx::Canvas* canvas) override; | 268 void OnPaint(gfx::Canvas* canvas) override; |
270 virtual void OnThemeChanged() override; | 269 void OnThemeChanged() override; |
271 | 270 |
272 private: | 271 private: |
273 // A struct representing the position at which an action will be dropped. | 272 // A struct representing the position at which an action will be dropped. |
274 struct DropPosition; | 273 struct DropPosition; |
275 | 274 |
276 typedef std::vector<BrowserActionView*> BrowserActionViews; | 275 typedef std::vector<BrowserActionView*> BrowserActionViews; |
277 | 276 |
278 // extensions::ExtensionToolbarModel::Observer implementation. | 277 // extensions::ExtensionToolbarModel::Observer implementation. |
279 virtual void ToolbarExtensionAdded(const extensions::Extension* extension, | 278 void ToolbarExtensionAdded(const extensions::Extension* extension, |
280 int index) override; | 279 int index) override; |
281 virtual void ToolbarExtensionRemoved( | 280 void ToolbarExtensionRemoved(const extensions::Extension* extension) override; |
282 const extensions::Extension* extension) override; | 281 void ToolbarExtensionMoved(const extensions::Extension* extension, |
283 virtual void ToolbarExtensionMoved(const extensions::Extension* extension, | 282 int index) override; |
284 int index) override; | 283 void ToolbarExtensionUpdated(const extensions::Extension* extension) override; |
285 virtual void ToolbarExtensionUpdated( | 284 bool ShowExtensionActionPopup(const extensions::Extension* extension, |
286 const extensions::Extension* extension) override; | 285 bool grant_active_tab) override; |
287 virtual bool ShowExtensionActionPopup( | 286 void ToolbarVisibleCountChanged() override; |
288 const extensions::Extension* extension, | 287 void ToolbarHighlightModeChanged(bool is_highlighting) override; |
289 bool grant_active_tab) override; | 288 Browser* GetBrowser() override; |
290 virtual void ToolbarVisibleCountChanged() override; | |
291 virtual void ToolbarHighlightModeChanged(bool is_highlighting) override; | |
292 virtual Browser* GetBrowser() override; | |
293 | 289 |
294 void LoadImages(); | 290 void LoadImages(); |
295 | 291 |
296 // Called when a browser action's visibility may have changed. | 292 // Called when a browser action's visibility may have changed. |
297 void OnBrowserActionVisibilityChanged(); | 293 void OnBrowserActionVisibilityChanged(); |
298 | 294 |
299 // Returns the preferred width of the container in order to show all icons | 295 // Returns the preferred width of the container in order to show all icons |
300 // that should be visible and, optionally, the chevron. | 296 // that should be visible and, optionally, the chevron. |
301 int GetPreferredWidth(); | 297 int GetPreferredWidth(); |
302 | 298 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 ObserverList<BrowserActionsContainerObserver> observers_; | 394 ObserverList<BrowserActionsContainerObserver> observers_; |
399 | 395 |
400 // The maximum number of icons to show per row when in overflow mode (showing | 396 // The maximum number of icons to show per row when in overflow mode (showing |
401 // icons in the application menu). | 397 // icons in the application menu). |
402 static int icons_per_overflow_menu_row_; | 398 static int icons_per_overflow_menu_row_; |
403 | 399 |
404 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 400 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
405 }; | 401 }; |
406 | 402 |
407 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 403 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
OLD | NEW |