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"
|
|
|
|
|
|
|
|
#include "libcef/browser/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
|
|
|
|
|
|
|
#include "base/message_loop/message_loop.h"
|
2018-05-18 12:45:18 +02:00
|
|
|
#include "base/message_loop/message_loop_current.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(
|
|
|
|
CefBrowserHostImpl* 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.
|
2018-05-18 12:45:18 +02:00
|
|
|
base::MessageLoopCurrent::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;
|
|
|
|
}
|