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

Side by Side Diff: chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc

Issue 250943008: Move enum MenuAnchorPosition to reduce deps on menu_item_view.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another rebase for r267046 conflict Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/browser_action_overflow_menu_contro ller.h" 5 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro ller.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_action.h" 9 #include "chrome/browser/extensions/extension_action.h"
10 #include "chrome/browser/extensions/extension_action_manager.h" 10 #include "chrome/browser/extensions/extension_action_manager.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 bool BrowserActionOverflowMenuController::RunMenu(views::Widget* window, 105 bool BrowserActionOverflowMenuController::RunMenu(views::Widget* window,
106 bool for_drop) { 106 bool for_drop) {
107 for_drop_ = for_drop; 107 for_drop_ = for_drop;
108 108
109 gfx::Rect bounds = menu_button_->bounds(); 109 gfx::Rect bounds = menu_button_->bounds();
110 gfx::Point screen_loc; 110 gfx::Point screen_loc;
111 views::View::ConvertPointToScreen(menu_button_, &screen_loc); 111 views::View::ConvertPointToScreen(menu_button_, &screen_loc);
112 bounds.set_x(screen_loc.x()); 112 bounds.set_x(screen_loc.x());
113 bounds.set_y(screen_loc.y()); 113 bounds.set_y(screen_loc.y());
114 114
115 views::MenuItemView::AnchorPosition anchor = views::MenuItemView::TOPRIGHT; 115 views::MenuAnchorPosition anchor = views::MENU_ANCHOR_TOPRIGHT;
116 // As we maintain our own lifetime we can safely ignore the result. 116 // As we maintain our own lifetime we can safely ignore the result.
117 ignore_result(menu_runner_->RunMenuAt(window, menu_button_, bounds, anchor, 117 ignore_result(menu_runner_->RunMenuAt(window, menu_button_, bounds, anchor,
118 ui::MENU_SOURCE_NONE, for_drop_ ? views::MenuRunner::FOR_DROP : 0)); 118 ui::MENU_SOURCE_NONE, for_drop_ ? views::MenuRunner::FOR_DROP : 0));
119 if (!for_drop_) { 119 if (!for_drop_) {
120 // Give the context menu (if any) a chance to execute the user-selected 120 // Give the context menu (if any) a chance to execute the user-selected
121 // command. 121 // command.
122 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 122 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
123 } 123 }
124 return true; 124 return true;
125 } 125 }
(...skipping 21 matching lines...) Expand all
147 (*views_)[start_index_ + id - 1]->button()->extension(); 147 (*views_)[start_index_ + id - 1]->button()->extension();
148 if (!extension->ShowConfigureContextMenus()) 148 if (!extension->ShowConfigureContextMenus())
149 return false; 149 return false;
150 150
151 scoped_refptr<ExtensionContextMenuModel> context_menu_contents = 151 scoped_refptr<ExtensionContextMenuModel> context_menu_contents =
152 new ExtensionContextMenuModel(extension, browser_, owner_); 152 new ExtensionContextMenuModel(extension, browser_, owner_);
153 views::MenuRunner context_menu_runner(context_menu_contents.get()); 153 views::MenuRunner context_menu_runner(context_menu_contents.get());
154 154
155 // We can ignore the result as we delete ourself. 155 // We can ignore the result as we delete ourself.
156 // This blocks until the user choses something or dismisses the menu. 156 // This blocks until the user choses something or dismisses the menu.
157 ignore_result(context_menu_runner.RunMenuAt(menu_button_->GetWidget(), 157 ignore_result(context_menu_runner.RunMenuAt(
158 NULL, gfx::Rect(p, gfx::Size()), views::MenuItemView::TOPLEFT, 158 menu_button_->GetWidget(),
159 NULL,
160 gfx::Rect(p, gfx::Size()),
161 views::MENU_ANCHOR_TOPLEFT,
159 source_type, 162 source_type,
160 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::IS_NESTED | 163 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::IS_NESTED |
161 views::MenuRunner::CONTEXT_MENU)); 164 views::MenuRunner::CONTEXT_MENU));
162 165
163 // The user is done with the context menu, so we can close the underlying 166 // The user is done with the context menu, so we can close the underlying
164 // menu. 167 // menu.
165 menu_->Cancel(); 168 menu_->Cancel();
166 169
167 return true; 170 return true;
168 } 171 }
169 172
170 void BrowserActionOverflowMenuController::DropMenuClosed( 173 void BrowserActionOverflowMenuController::DropMenuClosed(
171 views::MenuItemView* menu) { 174 views::MenuItemView* menu) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 261
259 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( 262 BrowserActionView* BrowserActionOverflowMenuController::ViewForId(
260 int id, size_t* index) { 263 int id, size_t* index) {
261 // The index of the view being dragged (GetCommand gives a 1-based index into 264 // The index of the view being dragged (GetCommand gives a 1-based index into
262 // the overflow menu). 265 // the overflow menu).
263 size_t view_index = owner_->VisibleBrowserActions() + id - 1; 266 size_t view_index = owner_->VisibleBrowserActions() + id - 1;
264 if (index) 267 if (index)
265 *index = view_index; 268 *index = view_index;
266 return owner_->GetBrowserActionViewAt(view_index); 269 return owner_->GetBrowserActionViewAt(view_index);
267 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698