mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Factor platform-specific code out of CefBrowserHostImpl (issue #1749).
- Introduce native/ and osr/ folders for native (non-platform-agnostic) and osr (windowless) code respectively. - Introduce CefBrowserPlatformDelegate for abstracting platform-specific implementations of browser host functionality. - Move dialog and menu code to separate manager and platform-specific runner implementations exposed via CefBrowserPlatformDelegate. - Standardize focus-handling behavior between windowed and windowless implementations. CefFocusHandler::OnSetFocus() will now also be called for osr focus changes. - Support multiple simultaneous popups (issue #1289).
This commit is contained in:
49
libcef/browser/native/menu_runner_linux.cc
Normal file
49
libcef/browser/native/menu_runner_linux.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2014 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_linux.h"
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerLinux::CefMenuRunnerLinux() {
|
||||
}
|
||||
|
||||
bool CefMenuRunnerLinux::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
ui::MenuModel* model,
|
||||
const content::ContextMenuParams& params) {
|
||||
menu_.reset(
|
||||
new views::MenuRunner(model, views::MenuRunner::CONTEXT_MENU));
|
||||
|
||||
const gfx::Point& screen_point =
|
||||
browser->GetScreenPoint(gfx::Point(params.x, params.y));
|
||||
|
||||
views::Widget* parent_widget = nullptr;
|
||||
if (!browser->IsWindowless())
|
||||
parent_widget = browser->GetWindowWidget();
|
||||
|
||||
views::MenuRunner::RunResult result =
|
||||
menu_->RunMenuAt(parent_widget,
|
||||
NULL, gfx::Rect(screen_point, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPRIGHT,
|
||||
ui::MENU_SOURCE_NONE);
|
||||
ALLOW_UNUSED_LOCAL(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefMenuRunnerLinux::CancelContextMenu() {
|
||||
if (menu_)
|
||||
menu_->Cancel();
|
||||
}
|
||||
|
||||
bool CefMenuRunnerLinux::FormatLabel(base::string16& label) {
|
||||
// Remove the accelerator indicator (&) from label strings.
|
||||
const char16 replace[] = {L'&', 0};
|
||||
return base::ReplaceChars(label, replace, base::string16(), &label);
|
||||
}
|
Reference in New Issue
Block a user