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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 // Executes |command| registered by |extension|. | 190 // Executes |command| registered by |extension|. |
187 void ExecuteExtensionCommand(const extensions::Extension* extension, | 191 void ExecuteExtensionCommand(const extensions::Extension* extension, |
188 const extensions::Command& command); | 192 const extensions::Command& command); |
189 | 193 |
190 // Add or remove an observer. | 194 // Add or remove an observer. |
191 void AddObserver(BrowserActionsContainerObserver* observer); | 195 void AddObserver(BrowserActionsContainerObserver* observer); |
192 void RemoveObserver(BrowserActionsContainerObserver* observer); | 196 void RemoveObserver(BrowserActionsContainerObserver* observer); |
193 | 197 |
194 // Overridden from views::View: | 198 // Overridden from views::View: |
195 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 199 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
200 virtual int GetHeightForWidth(int width) const OVERRIDE; | |
196 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 201 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
197 virtual void Layout() OVERRIDE; | 202 virtual void Layout() OVERRIDE; |
198 virtual bool GetDropFormats(int* formats, | 203 virtual bool GetDropFormats(int* formats, |
199 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | 204 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; |
200 virtual bool AreDropTypesRequired() OVERRIDE; | 205 virtual bool AreDropTypesRequired() OVERRIDE; |
201 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; | 206 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
202 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; | 207 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; |
203 virtual void OnDragExited() OVERRIDE; | 208 virtual void OnDragExited() OVERRIDE; |
204 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; | 209 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; |
205 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 210 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 virtual extensions::ActiveTabPermissionGranter* | 248 virtual extensions::ActiveTabPermissionGranter* |
244 GetActiveTabPermissionGranter() OVERRIDE; | 249 GetActiveTabPermissionGranter() OVERRIDE; |
245 | 250 |
246 // Retrieve the current popup. This should only be used by unit tests. | 251 // Retrieve the current popup. This should only be used by unit tests. |
247 ExtensionPopup* TestGetPopup(); | 252 ExtensionPopup* TestGetPopup(); |
248 | 253 |
249 // Set how many icons the container should show. This should only be used by | 254 // Set how many icons the container should show. This should only be used by |
250 // unit tests. | 255 // unit tests. |
251 void TestSetIconVisibilityCount(size_t icons); | 256 void TestSetIconVisibilityCount(size_t icons); |
252 | 257 |
258 // Returns the width of an icon, optionally with its padding. | |
259 static int IconWidth(bool include_padding); | |
260 | |
261 // Returns the height of an icon. | |
262 static int IconHeight(); | |
263 | |
253 // During testing we can disable animations by setting this flag to true, | 264 // During testing we can disable animations by setting this flag to true, |
254 // so that the bar resizes instantly, instead of having to poll it while it | 265 // so that the bar resizes instantly, instead of having to poll it while it |
255 // animates to open/closed status. | 266 // animates to open/closed status. |
256 static bool disable_animations_during_testing_; | 267 static bool disable_animations_during_testing_; |
257 | 268 |
258 protected: | 269 protected: |
259 // Overridden from views::View: | 270 // Overridden from views::View: |
260 virtual void ViewHierarchyChanged( | 271 virtual void ViewHierarchyChanged( |
261 const ViewHierarchyChangedDetails& details) OVERRIDE; | 272 const ViewHierarchyChangedDetails& details) OVERRIDE; |
262 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 273 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
263 virtual void OnThemeChanged() OVERRIDE; | 274 virtual void OnThemeChanged() OVERRIDE; |
264 | 275 |
265 private: | 276 private: |
266 friend class BrowserActionView; // So it can access IconWidth(). | |
267 | |
268 // A struct representing the position at which an action will be dropped. | 277 // A struct representing the position at which an action will be dropped. |
269 struct DropPosition; | 278 struct DropPosition; |
270 | 279 |
271 typedef std::vector<BrowserActionView*> BrowserActionViews; | 280 typedef std::vector<BrowserActionView*> BrowserActionViews; |
272 | 281 |
273 // Returns the width of an icon, optionally with its padding. | |
274 static int IconWidth(bool include_padding); | |
275 | |
276 // Returns the height of an icon. | |
277 static int IconHeight(); | |
278 | |
279 // extensions::ExtensionToolbarModel::Observer implementation. | 282 // extensions::ExtensionToolbarModel::Observer implementation. |
280 virtual void ToolbarExtensionAdded(const extensions::Extension* extension, | 283 virtual void ToolbarExtensionAdded(const extensions::Extension* extension, |
281 int index) OVERRIDE; | 284 int index) OVERRIDE; |
282 virtual void ToolbarExtensionRemoved( | 285 virtual void ToolbarExtensionRemoved( |
283 const extensions::Extension* extension) OVERRIDE; | 286 const extensions::Extension* extension) OVERRIDE; |
284 virtual void ToolbarExtensionMoved(const extensions::Extension* extension, | 287 virtual void ToolbarExtensionMoved(const extensions::Extension* extension, |
285 int index) OVERRIDE; | 288 int index) OVERRIDE; |
286 virtual void ToolbarExtensionUpdated( | 289 virtual void ToolbarExtensionUpdated( |
287 const extensions::Extension* extension) OVERRIDE; | 290 const extensions::Extension* extension) OVERRIDE; |
288 virtual bool ShowExtensionActionPopup( | 291 virtual bool ShowExtensionActionPopup( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 scoped_ptr<DropPosition> drop_position_; | 418 scoped_ptr<DropPosition> drop_position_; |
416 | 419 |
417 // The class that registers for keyboard shortcuts for extension commands. | 420 // The class that registers for keyboard shortcuts for extension commands. |
418 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | 421 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; |
419 | 422 |
420 // Handles delayed showing of the overflow menu when hovering. | 423 // Handles delayed showing of the overflow menu when hovering. |
421 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; | 424 base::WeakPtrFactory<BrowserActionsContainer> show_menu_task_factory_; |
422 | 425 |
423 ObserverList<BrowserActionsContainerObserver> observers_; | 426 ObserverList<BrowserActionsContainerObserver> observers_; |
424 | 427 |
428 // The maximum number of icons to show per row when in overflow mode (showing | |
429 // icons in the application menu). | |
430 static int icons_per_overflow_menu_row_; | |
sky
2014/09/12 20:09:37
Why does this need to be static?
Devlin
2014/09/12 22:41:37
It doesn't really, but there should only be one me
| |
431 | |
425 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 432 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
426 }; | 433 }; |
427 | 434 |
428 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 435 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
OLD | NEW |