2015-11-17 19:20:13 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/native/menu_runner_win.h"
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
2016-01-06 20:20:54 +01:00
|
|
|
#include "libcef/browser/native/menu_2.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
#include "base/task/current_thread.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "ui/gfx/geometry/point.h"
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefMenuRunnerWin::CefMenuRunnerWin() {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
bool CefMenuRunnerWin::RunContextMenu(
|
2020-09-22 21:54:02 +02:00
|
|
|
AlloyBrowserHostImpl* browser,
|
2016-01-19 21:09:01 +01:00
|
|
|
CefMenuModelImpl* model,
|
2015-11-17 19:20:13 +01:00
|
|
|
const content::ContextMenuParams& params) {
|
|
|
|
// Create a menu based on the model.
|
2020-01-15 14:36:24 +01:00
|
|
|
menu_.reset(new views::CefNativeMenuWin(model->model(), nullptr));
|
|
|
|
menu_->Rebuild(nullptr);
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
// Make sure events can be pumped while the menu is up.
|
2020-08-29 00:39:23 +02:00
|
|
|
base::CurrentThread::ScopedNestableTaskAllower allow;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
const gfx::Point& screen_point =
|
|
|
|
browser->GetScreenPoint(gfx::Point(params.x, params.y));
|
|
|
|
|
|
|
|
// Show the menu. Blocks until the menu is dismissed.
|
|
|
|
menu_->RunMenuAt(screen_point, views::Menu2::ALIGN_TOPLEFT);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|