Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/browser_actions_container.h |
| diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.h b/chrome/browser/ui/views/toolbar/browser_actions_container.h |
| index 9874e79cbcfb0aa5a3599f98271d2042593f4bd4..4d6d38c51e80bf56e146c7a29ccc91ba774f629f 100644 |
| --- a/chrome/browser/ui/views/toolbar/browser_actions_container.h |
| +++ b/chrome/browser/ui/views/toolbar/browser_actions_container.h |
| @@ -42,22 +42,40 @@ namespace views { |
| class ResizeArea; |
| } |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// |
| // The BrowserActionsContainer is a container view, responsible for drawing the |
| -// browser action icons (extensions that add icons to the toolbar). |
| +// browser action icons (extensions that add icons to the toolbar). It comes in |
| +// two flavors, a main container (when residing on the toolbar) and an overflow |
| +// container (that resides in the main application menu, known as the |
| +// hot dog/hamburger menu). |
|
Peter Kasting
2014/06/30 23:36:34
Nit: Again, do not use "hot dog" or "hamburger" to
Finnur
2014/07/02 16:59:56
Done.
|
| +// |
| +// When in 'main' mode, the container supports the full functionality of a |
| +// BrowserActionContainer but in 'overflow' mode the container is effectively |
|
Peter Kasting
2014/06/30 23:36:33
Nit: BrowserActionContainer but -> BrowserActionCo
Finnur
2014/07/02 16:59:56
Done.
|
| +// just an overflow for the 'main' toolbar (shows only the icons that the main |
| +// toolbar does not) and as such does not have an overflow itself. The overflow |
| +// container also does not support resizing. Since the main container only shows |
| +// icons in the Chrome toolbar, it is limited to a single row of icons. The |
| +// overflow container, however, is allowed to display icons in multiple rows. |
| // |
| -// The container is placed flush against the omnibox and wrench menu, and its |
| -// layout looks like: |
| +// The main container is placed flush against the omnibox and hot dog menu, |
| +// whereas the overflow container is placed within the hot dog menu. The |
| +// layout is similar to this: |
| // rI_I_IcCs |
| // Where the letters are as follows: |
| // r: An invisible resize area. This is ToolbarView::kStandardSpacing pixels |
| -// wide and directly adjacent to the omnibox. |
| +// wide and directly adjacent to the omnibox. Only shown for the main |
| +// container. |
| // I: An icon. This is as wide as the IDR_BROWSER_ACTION image. |
| // _: kItemSpacing pixels of empty space. |
| // c: kChevronSpacing pixels of empty space. Only present if C is present. |
| -// C: An optional chevron, visible for overflow. As wide as the |
| -// IDR_BROWSER_ACTIONS_OVERFLOW image. |
| +// C: An optional chevron, as wide as the IDR_BROWSER_ACTIONS_OVERFLOW image, |
| +// and visible only when all of the following statements are true: |
| +// - This is the main container. |
|
Peter Kasting
2014/06/30 23:36:34
Nit: This point is already clear from the fact tha
Finnur
2014/07/02 16:59:57
Done.
|
| +// - The container is set to a width smaller than needed to show all icons. |
| +// - There is no other container in 'overflow' mode to handle the |
| +// non-visible icons for this container. |
| +// NOTE: When the BrowserActionsContainer is in 'overflow mode', the icons |
| +// for the 'main' container overflow to a special overflow container |
| +// inside the wrench menu. |
|
Peter Kasting
2014/06/30 23:36:33
Nit: This NOTE seems like a rehash of comments abo
Finnur
2014/07/02 16:59:57
Done.
|
| // s: ToolbarView::kStandardSpacing pixels of empty space (before the wrench |
| // menu). |
| // The reason the container contains the trailing space "s", rather than having |
| @@ -66,7 +84,8 @@ class ResizeArea; |
| // ultimate drop indicator. (Otherwise, we'd be trying to draw it into the |
| // padding beyond our right edge, and it wouldn't appear.) |
| // |
| -// The BrowserActionsContainer follows a few rules, in terms of user experience: |
| +// The BrowserActionsContainer in 'main' mode follows a few rules, in terms of |
| +// user experience: |
| // |
| // 1) The container can never grow beyond the space needed to show all icons |
| // (hereby referred to as the max width). |
| @@ -81,7 +100,7 @@ class ResizeArea; |
| // 5) If the container is NOT at max width (has an overflow menu), we respect |
| // that size when adding and removing icons and DON'T grow/shrink the container. |
| // This means that new icons (which always appear at the far right) will show up |
| -// in the overflow menu. The install bubble for extensions points to the chevron |
| +// in the overflow. The install bubble for extensions points to the chevron |
| // menu in this case. |
| // |
| // Resizing the BrowserActionsContainer: |
| @@ -125,7 +144,12 @@ class BrowserActionsContainer |
| public BrowserActionView::Delegate, |
| public extensions::ExtensionKeybindingRegistry::Delegate { |
| public: |
| - BrowserActionsContainer(Browser* browser, views::View* owner_view); |
| + // Constructs a BrowserActionContainer for a particular |browser| object, and |
| + // specifies which view is the |owner_view|. For documentation of |
| + // |main_container_|, see class comments. |
|
Peter Kasting
2014/06/30 23:36:34
Nit: No trailing underscore
Finnur
2014/07/02 16:59:57
Done.
|
| + BrowserActionsContainer(Browser* browser, |
| + views::View* owner_view, |
| + BrowserActionsContainer* main_container); |
| virtual ~BrowserActionsContainer(); |
| void Init(); |
| @@ -225,6 +249,7 @@ class BrowserActionsContainer |
| virtual int GetCurrentTabId() const OVERRIDE; |
| virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; |
| virtual void OnBrowserActionVisibilityChanged() OVERRIDE; |
| + virtual bool ShownInsideMenu() const OVERRIDE; |
| // Overridden from extension::ExtensionKeybindingRegistry::Delegate: |
| virtual extensions::ActiveTabPermissionGranter* |
| @@ -346,6 +371,10 @@ class BrowserActionsContainer |
| ExtensionPopup::ShowAction show_action, |
| bool grant_tab_permissions); |
| + // Whether this container is overflow container (as opposed to in 'main' |
|
Peter Kasting
2014/06/30 23:36:34
Nit: overflow container -> in overflow mode (or sa
Peter Kasting
2014/07/02 20:54:00
You should still do this.
Finnur
2014/07/03 13:59:31
Indeed.
|
| + // mode). See class comments for details on the difference. |
| + bool handling_overflow() const { return main_container_ != NULL; } |
|
Peter Kasting
2014/06/30 23:36:34
Nit: handling_overflow() is a rather confusing nam
Finnur
2014/07/02 16:59:56
Changed it to in_overflow_mode. I think that is th
|
| + |
| // The vector of browser actions (icons/image buttons for each action). Note |
| // that not every BrowserAction in the ToolbarModel will necessarily be in |
| // this collection. Some extensions may be disabled in incognito windows. |
| @@ -359,6 +388,11 @@ class BrowserActionsContainer |
| // The view that owns us. |
| views::View* owner_view_; |
| + // The main container we are serving as overflow for, or NULL if this |
| + // class is the the main container. See class comments for details on |
| + // the difference between main and overflow. |
| + BrowserActionsContainer* main_container_; |
| + |
| // The current popup and the button it came from. NULL if no popup. |
| ExtensionPopup* popup_; |
| @@ -375,7 +409,8 @@ class BrowserActionsContainer |
| // The resize area for the container. |
| views::ResizeArea* resize_area_; |
| - // The chevron for accessing the overflow items. |
| + // The chevron for accessing the overflow items. Can be NULL if the toolbar |
| + // is permanently suppressing the chevron menu. |
|
Peter Kasting
2014/06/30 23:36:34
Nit: "NULL when in overflow mode or when the toolb
Finnur
2014/07/02 16:59:56
Done.
|
| views::MenuButton* chevron_; |
| // The painter used when we are highlighting a subset of extensions. |