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

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

Issue 2394123002: Views: Expose an on_closed callback via the MenuRunner constructor. (Closed)
Patch Set: default arg Created 4 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame.h ('k') | ui/views/controls/combobox/combobox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
21 #include "chrome/browser/ui/views/frame/browser_view.h" 21 #include "chrome/browser/ui/views/frame/browser_view.h"
22 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 22 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
23 #include "chrome/browser/ui/views/frame/native_browser_frame.h" 23 #include "chrome/browser/ui/views/frame/native_browser_frame.h"
24 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h" 24 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"
25 #include "chrome/browser/ui/views/frame/system_menu_model_builder.h" 25 #include "chrome/browser/ui/views/frame/system_menu_model_builder.h"
26 #include "chrome/browser/ui/views/frame/top_container_view.h" 26 #include "chrome/browser/ui/views/frame/top_container_view.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "ui/base/hit_test.h" 28 #include "ui/base/hit_test.h"
29 #include "ui/events/event_handler.h" 29 #include "ui/events/event_handler.h"
30 #include "ui/gfx/font_list.h" 30 #include "ui/gfx/font_list.h"
31 #include "ui/views/controls/menu/menu_model_adapter.h"
32 #include "ui/views/controls/menu/menu_runner.h" 31 #include "ui/views/controls/menu/menu_runner.h"
33 #include "ui/views/widget/native_widget.h" 32 #include "ui/views/widget/native_widget.h"
34 33
35 #if defined(OS_CHROMEOS) 34 #if defined(OS_CHROMEOS)
36 #include "ash/common/session/session_state_delegate.h" // nogncheck 35 #include "ash/common/session/session_state_delegate.h" // nogncheck
37 #include "ash/common/wm_shell.h" // nogncheck 36 #include "ash/common/wm_shell.h" // nogncheck
38 #include "ui/native_theme/native_theme_dark_aura.h" // nogncheck 37 #include "ui/native_theme/native_theme_dark_aura.h" // nogncheck
39 #endif 38 #endif
40 39
41 #if defined(OS_LINUX) 40 #if defined(OS_LINUX)
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return; 252 return;
254 253
255 // Only show context menu if point is in unobscured parts of browser, i.e. 254 // Only show context menu if point is in unobscured parts of browser, i.e.
256 // if NonClientHitTest returns : 255 // if NonClientHitTest returns :
257 // - HTCAPTION: in title bar or unobscured part of tabstrip 256 // - HTCAPTION: in title bar or unobscured part of tabstrip
258 // - HTNOWHERE: as the name implies. 257 // - HTNOWHERE: as the name implies.
259 gfx::Point point_in_view_coords(p); 258 gfx::Point point_in_view_coords(p);
260 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords); 259 views::View::ConvertPointFromScreen(non_client_view(), &point_in_view_coords);
261 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords); 260 int hit_test = non_client_view()->NonClientHitTest(point_in_view_coords);
262 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { 261 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) {
263 menu_model_adapter_.reset(new views::MenuModelAdapter( 262 menu_runner_.reset(new views::MenuRunner(
264 GetSystemMenuModel(), 263 GetSystemMenuModel(),
264 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU |
265 views::MenuRunner::ASYNC,
265 base::Bind(&BrowserFrame::OnMenuClosed, base::Unretained(this)))); 266 base::Bind(&BrowserFrame::OnMenuClosed, base::Unretained(this))));
266 menu_runner_.reset(new views::MenuRunner(
267 menu_model_adapter_->CreateMenu(), views::MenuRunner::HAS_MNEMONICS |
268 views::MenuRunner::CONTEXT_MENU |
269 views::MenuRunner::ASYNC));
270 menu_runner_->RunMenuAt(source->GetWidget(), nullptr, 267 menu_runner_->RunMenuAt(source->GetWidget(), nullptr,
271 gfx::Rect(p, gfx::Size(0, 0)), 268 gfx::Rect(p, gfx::Size(0, 0)),
272 views::MENU_ANCHOR_TOPLEFT, source_type); 269 views::MENU_ANCHOR_TOPLEFT, source_type);
273 } 270 }
274 } 271 }
275 272
276 ui::MenuModel* BrowserFrame::GetSystemMenuModel() { 273 ui::MenuModel* BrowserFrame::GetSystemMenuModel() {
277 #if defined(OS_CHROMEOS) 274 #if defined(OS_CHROMEOS)
278 ash::SessionStateDelegate* delegate = 275 ash::SessionStateDelegate* delegate =
279 ash::WmShell::Get()->GetSessionStateDelegate(); 276 ash::WmShell::Get()->GetSessionStateDelegate();
(...skipping 11 matching lines...) Expand all
291 menu_model_builder_->Init(); 288 menu_model_builder_->Init();
292 } 289 }
293 return menu_model_builder_->menu_model(); 290 return menu_model_builder_->menu_model();
294 } 291 }
295 292
296 views::View* BrowserFrame::GetNewAvatarMenuButton() { 293 views::View* BrowserFrame::GetNewAvatarMenuButton() {
297 return browser_frame_view_->GetProfileSwitcherView(); 294 return browser_frame_view_->GetProfileSwitcherView();
298 } 295 }
299 296
300 void BrowserFrame::OnMenuClosed() { 297 void BrowserFrame::OnMenuClosed() {
301 menu_model_adapter_.reset();
302 menu_runner_.reset(); 298 menu_runner_.reset();
303 } 299 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame.h ('k') | ui/views/controls/combobox/combobox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698