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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 class BrowserActionsContainer | 124 class BrowserActionsContainer |
125 : public views::View, | 125 : public views::View, |
126 public views::MenuButtonListener, | 126 public views::MenuButtonListener, |
127 public views::ResizeAreaDelegate, | 127 public views::ResizeAreaDelegate, |
128 public gfx::AnimationDelegate, | 128 public gfx::AnimationDelegate, |
129 public extensions::ExtensionToolbarModel::Observer, | 129 public extensions::ExtensionToolbarModel::Observer, |
130 public BrowserActionOverflowMenuController::Observer, | 130 public BrowserActionOverflowMenuController::Observer, |
131 public BrowserActionView::Delegate, | 131 public BrowserActionView::Delegate, |
132 public extensions::ExtensionKeybindingRegistry::Delegate { | 132 public extensions::ExtensionKeybindingRegistry::Delegate { |
133 public: | 133 public: |
| 134 // Horizontal spacing between most items in the container, as well as after |
| 135 // the last item or chevron (if visible). |
| 136 static const int kItemSpacing; |
| 137 |
134 // Constructs a BrowserActionContainer for a particular |browser| object, and | 138 // Constructs a BrowserActionContainer for a particular |browser| object, and |
135 // specifies which view is the |owner_view|. For documentation of | 139 // specifies which view is the |owner_view|. For documentation of |
136 // |main_container|, see class comments. | 140 // |main_container|, see class comments. |
137 BrowserActionsContainer(Browser* browser, | 141 BrowserActionsContainer(Browser* browser, |
138 views::View* owner_view, | 142 views::View* owner_view, |
139 BrowserActionsContainer* main_container); | 143 BrowserActionsContainer* main_container); |
140 virtual ~BrowserActionsContainer(); | 144 virtual ~BrowserActionsContainer(); |
141 | 145 |
142 void Init(); | 146 void Init(); |
143 | 147 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // Notify the browser action container that an extension has been moved to | 194 // Notify the browser action container that an extension has been moved to |
191 // the overflow container. | 195 // the overflow container. |
192 void NotifyActionMovedToOverflow(); | 196 void NotifyActionMovedToOverflow(); |
193 | 197 |
194 // Add or remove an observer. | 198 // Add or remove an observer. |
195 void AddObserver(BrowserActionsContainerObserver* observer); | 199 void AddObserver(BrowserActionsContainerObserver* observer); |
196 void RemoveObserver(BrowserActionsContainerObserver* observer); | 200 void RemoveObserver(BrowserActionsContainerObserver* observer); |
197 | 201 |
198 // Overridden from views::View: | 202 // Overridden from views::View: |
199 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 203 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 204 virtual int GetHeightForWidth(int width) const OVERRIDE; |
200 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 205 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
201 virtual void Layout() OVERRIDE; | 206 virtual void Layout() OVERRIDE; |
202 virtual bool GetDropFormats(int* formats, | 207 virtual bool GetDropFormats(int* formats, |
203 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | 208 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; |
204 virtual bool AreDropTypesRequired() OVERRIDE; | 209 virtual bool AreDropTypesRequired() OVERRIDE; |
205 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; | 210 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
206 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; | 211 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; |
207 virtual void OnDragExited() OVERRIDE; | 212 virtual void OnDragExited() OVERRIDE; |
208 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; | 213 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; |
209 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 214 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 virtual extensions::ActiveTabPermissionGranter* | 252 virtual extensions::ActiveTabPermissionGranter* |
248 GetActiveTabPermissionGranter() OVERRIDE; | 253 GetActiveTabPermissionGranter() OVERRIDE; |
249 | 254 |
250 // Retrieve the current popup. This should only be used by unit tests. | 255 // Retrieve the current popup. This should only be used by unit tests. |
251 ExtensionPopup* TestGetPopup(); | 256 ExtensionPopup* TestGetPopup(); |
252 | 257 |
253 // Set how many icons the container should show. This should only be used by | 258 // Set how many icons the container should show. This should only be used by |
254 // unit tests. | 259 // unit tests. |
255 void TestSetIconVisibilityCount(size_t icons); | 260 void TestSetIconVisibilityCount(size_t icons); |
256 | 261 |
| 262 // Returns the width of an icon, optionally with its padding. |
| 263 static int IconWidth(bool include_padding); |
| 264 |
| 265 // Returns the height of an icon. |
| 266 static int IconHeight(); |
| 267 |
257 // During testing we can disable animations by setting this flag to true, | 268 // During testing we can disable animations by setting this flag to true, |
258 // so that the bar resizes instantly, instead of having to poll it while it | 269 // so that the bar resizes instantly, instead of having to poll it while it |
259 // animates to open/closed status. | 270 // animates to open/closed status. |
260 static bool disable_animations_during_testing_; | 271 static bool disable_animations_during_testing_; |
261 | 272 |
262 protected: | 273 protected: |
263 // Overridden from views::View: | 274 // Overridden from views::View: |
264 virtual void ViewHierarchyChanged( | 275 virtual void ViewHierarchyChanged( |
265 const ViewHierarchyChangedDetails& details) OVERRIDE; | 276 const ViewHierarchyChangedDetails& details) OVERRIDE; |
266 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 277 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
267 virtual void OnThemeChanged() OVERRIDE; | 278 virtual void OnThemeChanged() OVERRIDE; |
268 | 279 |
269 private: | 280 private: |
270 friend class BrowserActionView; // So it can access IconWidth(). | |
271 | |
272 // A struct representing the position at which an action will be dropped. | 281 // A struct representing the position at which an action will be dropped. |
273 struct DropPosition; | 282 struct DropPosition; |
274 | 283 |
275 typedef std::vector<BrowserActionView*> BrowserActionViews; | 284 typedef std::vector<BrowserActionView*> BrowserActionViews; |
276 | 285 |
277 // Returns the width of an icon, optionally with its padding. | |
278 static int IconWidth(bool include_padding); | |
279 | |
280 // Returns the height of an icon. | |
281 static int IconHeight(); | |
282 | |
283 // extensions::ExtensionToolbarModel::Observer implementation. | 286 // extensions::ExtensionToolbarModel::Observer implementation. |
284 virtual void ToolbarExtensionAdded(const extensions::Extension* extension, | 287 virtual void ToolbarExtensionAdded(const extensions::Extension* extension, |
285 int index) OVERRIDE; | 288 int index) OVERRIDE; |
286 virtual void ToolbarExtensionRemoved( | 289 virtual void ToolbarExtensionRemoved( |
287 const extensions::Extension* extension) OVERRIDE; | 290 const extensions::Extension* extension) OVERRIDE; |
288 virtual void ToolbarExtensionMoved(const extensions::Extension* extension, | 291 virtual void ToolbarExtensionMoved(const extensions::Extension* extension, |
289 int index) OVERRIDE; | 292 int index) OVERRIDE; |
290 virtual void ToolbarExtensionUpdated( | 293 virtual void ToolbarExtensionUpdated( |
291 const extensions::Extension* extension) OVERRIDE; | 294 const extensions::Extension* extension) OVERRIDE; |
292 virtual bool ShowExtensionActionPopup( | 295 virtual bool ShowExtensionActionPopup( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 scoped_ptr<DropPosition> drop_position_; | 425 scoped_ptr<DropPosition> drop_position_; |
423 | 426 |
424 // The class that registers for keyboard shortcuts for extension commands. | 427 // The class that registers for keyboard shortcuts for extension commands. |
425 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | 428 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; |
426 | 429 |
427 // Handles delayed showing of the overflow menu when hovering. | 430 // Handles delayed showing of the overflow menu when hovering. |
428 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; | 431 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; |
429 | 432 |
430 ObserverList<BrowserActionsContainerObserver> observers_; | 433 ObserverList<BrowserActionsContainerObserver> observers_; |
431 | 434 |
| 435 // The maximum number of icons to show per row when in overflow mode (showing |
| 436 // icons in the application menu). |
| 437 static int icons_per_overflow_menu_row_; |
| 438 |
432 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 439 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
433 }; | 440 }; |
434 | 441 |
435 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 442 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
OLD | NEW |