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

Side by Side Diff: chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.cc

Issue 1782223002: [Extensions UI] Update ToolbarActionsBar::NeedsOverflow() for popped out actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnur's Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" 5 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 23 matching lines...) Expand all
34 container_(nullptr), 34 container_(nullptr),
35 max_height_(0), 35 max_height_(0),
36 toolbar_actions_bar_observer_(this), 36 toolbar_actions_bar_observer_(this),
37 weak_factory_(this) { 37 weak_factory_(this) {
38 BrowserActionsContainer* main = 38 BrowserActionsContainer* main =
39 BrowserView::GetBrowserViewForBrowser(browser_) 39 BrowserView::GetBrowserViewForBrowser(browser_)
40 ->toolbar()->browser_actions(); 40 ->toolbar()->browser_actions();
41 container_ = new BrowserActionsContainer(browser_, main); 41 container_ = new BrowserActionsContainer(browser_, main);
42 container_->Init(); 42 container_->Init();
43 SetContents(container_); 43 SetContents(container_);
44 // We Layout() the container here so that we know the number of actions
45 // that will be visible in ShouldShow().
46 container_->Layout();
47 44
48 // Listen for the drop to finish so we can close the app menu, if necessary. 45 // Listen for the drop to finish so we can close the app menu, if necessary.
49 toolbar_actions_bar_observer_.Add(main->toolbar_actions_bar()); 46 toolbar_actions_bar_observer_.Add(main->toolbar_actions_bar());
50 47
51 // In *very* extreme cases, it's possible that there are so many overflowed 48 // In *very* extreme cases, it's possible that there are so many overflowed
52 // actions, we won't be able to show them all. Cap the height so that the 49 // actions, we won't be able to show them all. Cap the height so that the
53 // overflow won't be excessively tall (at 8 icons per row, this allows for 50 // overflow won't be excessively tall (at 8 icons per row, this allows for
54 // 104 total extensions). 51 // 104 total extensions).
55 const int kMaxOverflowRows = 13; 52 const int kMaxOverflowRows = 13;
56 max_height_ = ToolbarActionsBar::IconHeight() * kMaxOverflowRows; 53 max_height_ = ToolbarActionsBar::IconHeight() * kMaxOverflowRows;
57 ClipHeightTo(0, max_height_); 54 ClipHeightTo(0, max_height_);
58 } 55 }
59 56
60 ExtensionToolbarMenuView::~ExtensionToolbarMenuView() { 57 ExtensionToolbarMenuView::~ExtensionToolbarMenuView() {
61 } 58 }
62 59
63 bool ExtensionToolbarMenuView::ShouldShow() {
64 return app_menu_->for_drop() ||
65 container_->VisibleBrowserActionsAfterAnimation();
66 }
67
68 gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const { 60 gfx::Size ExtensionToolbarMenuView::GetPreferredSize() const {
69 gfx::Size s = views::ScrollView::GetPreferredSize(); 61 gfx::Size s = views::ScrollView::GetPreferredSize();
70 // views::ScrollView::GetPreferredSize() includes the contents' size, but 62 // views::ScrollView::GetPreferredSize() includes the contents' size, but
71 // not the scrollbar width. Add it in if necessary. 63 // not the scrollbar width. Add it in if necessary.
72 if (container_->GetPreferredSize().height() > max_height_) 64 if (container_->GetPreferredSize().height() > max_height_)
73 s.Enlarge(GetScrollBarWidth(), 0); 65 s.Enlarge(GetScrollBarWidth(), 0);
74 return s; 66 return s;
75 } 67 }
76 68
77 int ExtensionToolbarMenuView::GetHeightForWidth(int width) const { 69 int ExtensionToolbarMenuView::GetHeightForWidth(int width) const {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 128 }
137 129
138 int ExtensionToolbarMenuView::start_padding() const { 130 int ExtensionToolbarMenuView::start_padding() const {
139 // We pad enough on the left so that the first icon starts at the same point 131 // We pad enough on the left so that the first icon starts at the same point
140 // as the labels. We subtract kItemSpacing because there needs to be padding 132 // as the labels. We subtract kItemSpacing because there needs to be padding
141 // so we can see the drop indicator. 133 // so we can see the drop indicator.
142 return views::MenuItemView::label_start() - 134 return views::MenuItemView::label_start() -
143 container_->toolbar_actions_bar()->platform_settings().item_spacing; 135 container_->toolbar_actions_bar()->platform_settings().item_spacing;
144 } 136 }
145 137
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698