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

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame.cc

Issue 2790773002: Cleanup MenuRunner API (Closed)
Patch Set: Rebase Created 3 years, 8 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
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/frame/browser_frame.h" 5 #include "chrome/browser/ui/views/frame/browser_frame.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // Only show context menu if point is in unobscured parts of browser, i.e. 243 // Only show context menu if point is in unobscured parts of browser, i.e.
244 // if NonClientHitTest returns : 244 // if NonClientHitTest returns :
245 // - HTCAPTION: in title bar or unobscured part of tabstrip 245 // - HTCAPTION: in title bar or unobscured part of tabstrip
246 // - HTNOWHERE: as the name implies. 246 // - HTNOWHERE: as the name implies.
247 gfx::Point point_in_view_coords(p); 247 gfx::Point point_in_view_coords(p);
248 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords); 248 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords);
249 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords); 249 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords);
250 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { 250 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) {
251 menu_runner_.reset(new views::MenuRunner( 251 menu_runner_.reset(new views::MenuRunner(
252 GetSystemMenuModel(), 252 GetSystemMenuModel(),
253 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU | 253 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU,
254 views::MenuRunner::ASYNC,
255 base::Bind(&BrowserFrame::OnMenuClosed, base::Unretained(this)))); 254 base::Bind(&BrowserFrame::OnMenuClosed, base::Unretained(this))));
256 menu_runner_->RunMenuAt(source->GetWidget(), nullptr, 255 menu_runner_->RunMenuAt(source->GetWidget(), nullptr,
257 gfx::Rect(p, gfx::Size(0, 0)), 256 gfx::Rect(p, gfx::Size(0, 0)),
258 views::MENU_ANCHOR_TOPLEFT, source_type); 257 views::MENU_ANCHOR_TOPLEFT, source_type);
259 } 258 }
260 } 259 }
261 260
262 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { 261 ui::MenuModel* BrowserFrame::GetSystemMenuModel() {
263 #if defined(OS_CHROMEOS) 262 #if defined(OS_CHROMEOS)
264 if (user_manager::UserManager::IsInitialized() && 263 if (user_manager::UserManager::IsInitialized() &&
(...skipping 13 matching lines...) Expand all
278 return menu_model_builder_->menu_model(); 277 return menu_model_builder_->menu_model();
279 } 278 }
280 279
281 views::View* BrowserFrame::GetNewAvatarMenuButton() { 280 views::View* BrowserFrame::GetNewAvatarMenuButton() {
282 return browser_frame_view_->GetProfileSwitcherView(); 281 return browser_frame_view_->GetProfileSwitcherView();
283 } 282 }
284 283
285 void BrowserFrame::OnMenuClosed() { 284 void BrowserFrame::OnMenuClosed() {
286 menu_runner_.reset(); 285 menu_runner_.reset();
287 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698