Commit 9bdf4531 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

Allow the user to drag an extension to the overflow menu, even when its empty

We need to show an empty bar for the user to drag extension actions into for
overflow when there are none currently overflowed. Obviously, this empty bar
should only be displayed when the user is dragging an extension action.

BUG=414386

Review URL: https://codereview.chromium.org/556293003

Cr-Commit-Position: refs/heads/master@{#295179}
parent fedbb0d1
......@@ -349,9 +349,6 @@ class BrowserActionsContainer
// for incognito.
bool ShouldDisplayBrowserAction(const extensions::Extension* extension) const;
// Return the index of the first visible icon.
size_t GetFirstVisibleIconIndex() const;
// Returns the number of icons that this container should draw. This differs
// from the model's GetVisibleIconCount if this container is for the overflow.
size_t GetIconCount() const;
......
......@@ -44,6 +44,9 @@ ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser,
main);
container_->Init();
AddChildView(container_);
// We Layout() the container here so that we know the number of actions
// that will be visible in ShouldShow().
container_->Layout();
// If we were opened for a drop command, we have to wait for the drop to
// finish so we can close the wrench menu.
......@@ -56,6 +59,11 @@ ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser,
ExtensionToolbarMenuView::~ExtensionToolbarMenuView() {
}
bool ExtensionToolbarMenuView::ShouldShow() {
return wrench_menu_->for_drop() ||
container_->VisibleBrowserActionsAfterAnimation();
}
gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const {
return container_->GetPreferredSize();
}
......
......@@ -25,6 +25,11 @@ class ExtensionToolbarMenuView : public views::View,
ExtensionToolbarMenuView(Browser* browser, WrenchMenu* wrench_menu);
virtual ~ExtensionToolbarMenuView();
// Returns whether the wrench menu should show this view. This is true when
// either |container_| has icons to display or the menu was opened for a drag-
// and-drop operation.
bool ShouldShow();
// views::View:
virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual int GetHeightForWidth(int width) const OVERRIDE;
......
......@@ -1137,7 +1137,7 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent,
case IDC_EXTENSIONS_OVERFLOW_MENU: {
scoped_ptr<ExtensionToolbarMenuView> extension_toolbar(
new ExtensionToolbarMenuView(browser_, this));
if (extension_toolbar->GetPreferredSize().height() > 0)
if (extension_toolbar->ShouldShow())
item->AddChildView(extension_toolbar.release());
else
item->SetVisible(false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment