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

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

Issue 1766023002: [Extensions UI Views] Adjust the wrench menu actions for items added/removed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: 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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 12 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
13 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/browser/ui/views/toolbar/app_menu.h" 14 #include "chrome/browser/ui/views/toolbar/app_menu.h"
15 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 15 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
17 #include "ui/views/controls/menu/menu_item_view.h" 17 #include "ui/views/controls/menu/menu_item_view.h"
18 #include "ui/views/controls/menu/submenu_view.h" 18 #include "ui/views/controls/menu/submenu_view.h"
19 19
20 namespace { 20 namespace {
21 // The delay before we close the app menu if this was opened for a drop so that 21 // The delay before we close the app menu if this was opened for a drop so that
22 // the user can see a browser action if one was moved. 22 // the user can see a browser action if one was moved.
23 // This can be changed for tests. 23 // This can be changed for tests.
24 int g_close_menu_delay = 300; 24 int g_close_menu_delay = 300;
25 } 25 }
26 26
27 ExtensionToolbarMenuView::ExtensionToolbarMenuView(Browser* browser, 27 ExtensionToolbarMenuView::ExtensionToolbarMenuView(
28 AppMenu* app_menu) 28 Browser* browser,
29 AppMenu* app_menu,
30 views::MenuItemView* menu_item)
29 : browser_(browser), 31 : browser_(browser),
30 app_menu_(app_menu), 32 app_menu_(app_menu),
33 menu_item_(menu_item),
31 container_(nullptr), 34 container_(nullptr),
32 max_height_(0), 35 max_height_(0),
33 toolbar_actions_bar_observer_(this), 36 toolbar_actions_bar_observer_(this),
34 weak_factory_(this) { 37 weak_factory_(this) {
35 BrowserActionsContainer* main = 38 BrowserActionsContainer* main =
36 BrowserView::GetBrowserViewForBrowser(browser_) 39 BrowserView::GetBrowserViewForBrowser(browser_)
37 ->toolbar()->browser_actions(); 40 ->toolbar()->browser_actions();
38 container_ = new BrowserActionsContainer(browser_, main); 41 container_ = new BrowserActionsContainer(browser_, main);
39 container_->Init(); 42 container_->Init();
40 SetContents(container_); 43 SetContents(container_);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Redraw(); 120 Redraw();
118 } 121 }
119 122
120 void ExtensionToolbarMenuView::CloseAppMenu() { 123 void ExtensionToolbarMenuView::CloseAppMenu() {
121 app_menu_->CloseMenu(); 124 app_menu_->CloseMenu();
122 } 125 }
123 126
124 void ExtensionToolbarMenuView::Redraw() { 127 void ExtensionToolbarMenuView::Redraw() {
125 // In a case where the size of the container may have changed (e.g., by a row 128 // In a case where the size of the container may have changed (e.g., by a row
126 // being added or removed), we need to re-layout the menu in order to resize 129 // being added or removed), we need to re-layout the menu in order to resize
127 // the view (calling Layout() on this is insufficient because other items may 130 // the view. This may result in redrawing the window. Luckily, this happens
128 // need to shift up or down). 131 // only in the case of a row being aded or removed (very rare), and
129 parent()->parent()->Layout(); 132 // typically happens near menu initialization (rather than once the menu is
130 // The Menus layout code doesn't recursively call layout on its children like 133 // fully open).
131 // the default View code. Explicitly layout this view.
132 Layout(); 134 Layout();
135 menu_item_->GetParentMenuItem()->ChildrenChanged();
133 } 136 }
134 137
135 int ExtensionToolbarMenuView::start_padding() const { 138 int ExtensionToolbarMenuView::start_padding() const {
136 // We pad enough on the left so that the first icon starts at the same point 139 // We pad enough on the left so that the first icon starts at the same point
137 // as the labels. We subtract kItemSpacing because there needs to be padding 140 // as the labels. We subtract kItemSpacing because there needs to be padding
138 // so we can see the drop indicator. 141 // so we can see the drop indicator.
139 return views::MenuItemView::label_start() - 142 return views::MenuItemView::label_start() -
140 container_->toolbar_actions_bar()->platform_settings().item_spacing; 143 container_->toolbar_actions_bar()->platform_settings().item_spacing;
141 } 144 }
142 145
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