1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that can 3 // be found in the LICENSE file. 4 5 #include "libcef/browser/native/menu_runner_win.h" 6 7 #include "libcef/browser/alloy/alloy_browser_host_impl.h" 8 #include "libcef/browser/native/menu_2.h" 9 10 #include "base/task/current_thread.h" 11 #include "ui/gfx/geometry/point.h" 12 CefMenuRunnerWin()13CefMenuRunnerWin::CefMenuRunnerWin() {} 14 RunContextMenu(AlloyBrowserHostImpl * browser,CefMenuModelImpl * model,const content::ContextMenuParams & params)15bool CefMenuRunnerWin::RunContextMenu( 16 AlloyBrowserHostImpl* browser, 17 CefMenuModelImpl* model, 18 const content::ContextMenuParams& params) { 19 // Create a menu based on the model. 20 menu_.reset(new views::CefNativeMenuWin(model->model(), nullptr)); 21 menu_->Rebuild(nullptr); 22 23 // Make sure events can be pumped while the menu is up. 24 base::CurrentThread::ScopedNestableTaskAllower allow; 25 26 const gfx::Point& screen_point = 27 browser->GetScreenPoint(gfx::Point(params.x, params.y)); 28 29 // Show the menu. Blocks until the menu is dismissed. 30 menu_->RunMenuAt(screen_point, views::Menu2::ALIGN_TOPLEFT); 31 32 return true; 33 } 34