Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3515)

Unified Diff: chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc

Issue 1419603004: [Extensions Toolbar] Fix action pop out bug and views animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
diff --git a/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc b/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
index ef63f3d1a1d7a4754af2cfe0742b419d9133faf4..20e3fabded214b51906d5161d50baadd0b971d4b 100644
--- a/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
+++ b/chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc
@@ -30,7 +30,7 @@ ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser,
app_menu_(app_menu),
container_(nullptr),
max_height_(0),
- browser_actions_container_observer_(this),
+ toolbar_actions_bar_observer_(this),
weak_factory_(this) {
BrowserActionsContainer* main =
BrowserView::GetBrowserViewForBrowser(browser_)
@@ -43,8 +43,7 @@ ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser,
container_->Layout();
// Listen for the drop to finish so we can close the app menu, if necessary.
- browser_actions_container_observer_.Add(container_);
- browser_actions_container_observer_.Add(main);
+ toolbar_actions_bar_observer_.Add(main->toolbar_actions_bar());
// In *very* extreme cases, it's possible that there are so many overflowed
// actions, we won't be able to show them all. Cap the height so that the
@@ -94,18 +93,14 @@ void ExtensionToolbarMenuView::set_close_menu_delay_for_testing(int delay) {
g_close_menu_delay = delay;
}
-void ExtensionToolbarMenuView::OnBrowserActionsContainerDestroyed(
- BrowserActionsContainer* browser_actions_container) {
- browser_actions_container_observer_.Remove(browser_actions_container);
+void ExtensionToolbarMenuView::OnToolbarActionsBarDestroyed() {
+ toolbar_actions_bar_observer_.RemoveAll();
}
-void ExtensionToolbarMenuView::OnBrowserActionDragDone() {
+void ExtensionToolbarMenuView::OnToolbarActionDragDone() {
// In the case of a drag-and-drop, the bounds of the container may have
- // changed (in the case of removing an icon that was the last in a row). We
- // need to re-layout the menu in order to shrink down the view (calling
- // Layout() on this is insufficient because other items may need to shift
- // upwards).
- parent()->parent()->Layout();
+ // changed (in the case of removing an icon that was the last in a row).
+ Redraw();
// We need to close the app menu if it was just opened for the drag and drop,
// or if there are no more extensions in the overflow menu after a drag and
@@ -119,10 +114,25 @@ void ExtensionToolbarMenuView::OnBrowserActionDragDone() {
}
}
+void ExtensionToolbarMenuView::OnToolbarActionsBarDidStartResize() {
+ Redraw();
+}
+
void ExtensionToolbarMenuView::CloseAppMenu() {
app_menu_->CloseMenu();
}
+void ExtensionToolbarMenuView::Redraw() {
+ // In a case where the size of the container may have changed (e.g., by a row
+ // being added or removed), we need to re-layout the menu in order to resize
+ // the view (calling Layout() on this is insufficient because other items may
+ // need to shift up or down).
+ parent()->parent()->Layout();
+ // The Menus layout code doesn't recursively call layout on its children like
+ // the default View code. Explicitly layout this view.
+ Layout();
+}
+
int ExtensionToolbarMenuView::start_padding() const {
// We pad enough on the left so that the first icon starts at the same point
// as the labels. We subtract kItemSpacing because there needs to be padding
« no previous file with comments | « chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698