2015-11-17 19:20:13 +01:00
|
|
|
// Copyright 2015 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/browser_platform_delegate.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/browser_host_impl.h"
|
|
|
|
#include "libcef/browser/osr/browser_platform_delegate_osr.h"
|
|
|
|
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
|
|
|
#include "content/public/browser/render_view_host.h"
|
|
|
|
#include "content/public/browser/render_widget_host.h"
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() : browser_(nullptr) {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
|
|
|
|
DCHECK(!browser_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::CreateViewForWebContents(
|
|
|
|
content::WebContentsView** view,
|
|
|
|
content::RenderViewHostDelegateView** delegate_view) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::WebContentsCreated(
|
2017-05-17 11:29:28 +02:00
|
|
|
content::WebContents* web_contents) {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::RenderViewCreated(
|
|
|
|
content::RenderViewHost* render_view_host) {
|
|
|
|
// Indicate that the view has an external parent (namely us). This changes the
|
|
|
|
// default view behavior in some cases (e.g. focus handling on Linux).
|
2016-01-19 21:09:01 +01:00
|
|
|
if (!IsViewsHosted() && render_view_host->GetWidget()->GetView())
|
2015-11-17 19:20:13 +01:00
|
|
|
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) {
|
|
|
|
DCHECK(!browser_);
|
|
|
|
browser_ = browser;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) {
|
|
|
|
DCHECK(browser_ && browser_ == browser);
|
|
|
|
browser_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::CreateHostWindow() {
|
|
|
|
NOTREACHED();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::CloseHostWindow() {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(USE_AURA)
|
|
|
|
views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
|
|
|
|
NOTREACHED();
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
|
|
|
|
NOTREACHED();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
#endif // defined(USE_AURA)
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::PopupWebContentsCreated(
|
|
|
|
const CefBrowserSettings& settings,
|
|
|
|
CefRefPtr<CefClient> client,
|
|
|
|
content::WebContents* new_web_contents,
|
|
|
|
CefBrowserPlatformDelegate* new_platform_delegate,
|
2017-05-17 11:29:28 +02:00
|
|
|
bool is_devtools) {}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
|
|
|
CefBrowserHostImpl* new_browser,
|
2017-05-17 11:29:28 +02:00
|
|
|
bool is_devtools) {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
|
2017-05-17 11:29:28 +02:00
|
|
|
content::RenderWidgetHostImpl* widget = content::RenderWidgetHostImpl::From(
|
|
|
|
browser_->web_contents()->GetRenderViewHost()->GetWidget());
|
2015-11-17 19:20:13 +01:00
|
|
|
if (widget)
|
|
|
|
widget->LostCapture();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
|
|
|
|
void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {
|
|
|
|
// Dismiss any existing popups.
|
|
|
|
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
|
|
|
|
if (host)
|
|
|
|
host->NotifyMoveOrResizeStarted();
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
|
2015-11-17 19:20:13 +01:00
|
|
|
#endif
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<CefFileDialogRunner>
|
2017-05-17 11:29:28 +02:00
|
|
|
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
2015-11-17 19:20:13 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<CefJavaScriptDialogRunner>
|
2017-05-17 11:29:28 +02:00
|
|
|
CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
|
2015-11-17 19:20:13 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::Invalidate(cef_paint_element_type_t type) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SetWindowlessFrameRate(int frame_rate) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefBrowserPlatformDelegate::ImeSetComposition(
|
|
|
|
const CefString& text,
|
2016-10-28 18:11:24 +02:00
|
|
|
const std::vector<CefCompositionUnderline>& underlines,
|
|
|
|
const CefRange& replacement_range,
|
|
|
|
const CefRange& selection_range) {
|
2015-11-17 19:20:13 +01:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2016-10-28 18:11:24 +02:00
|
|
|
void CefBrowserPlatformDelegate::ImeCommitText(
|
|
|
|
const CefString& text,
|
|
|
|
const CefRange& replacement_range,
|
|
|
|
int relative_cursor_pos) {
|
2015-11-17 19:20:13 +01:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2016-10-28 18:11:24 +02:00
|
|
|
void CefBrowserPlatformDelegate::ImeFinishComposingText(bool keep_selection) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::ImeCancelComposition() {
|
2015-11-17 19:20:13 +01:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDragEnter(
|
|
|
|
CefRefPtr<CefDragData> drag_data,
|
|
|
|
const CefMouseEvent& event,
|
|
|
|
cef_drag_operations_mask_t allowed_ops) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDragOver(
|
|
|
|
const CefMouseEvent& event,
|
|
|
|
cef_drag_operations_mask_t allowed_ops) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDragLeave() {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDrop(const CefMouseEvent& event) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
void CefBrowserPlatformDelegate::StartDragging(
|
|
|
|
const content::DropData& drop_data,
|
|
|
|
blink::WebDragOperationsMask allowed_ops,
|
|
|
|
const gfx::ImageSkia& image,
|
|
|
|
const gfx::Vector2d& image_offset,
|
|
|
|
const content::DragEventSourceInfo& event_info,
|
|
|
|
content::RenderWidgetHostImpl* source_rwh) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::UpdateDragCursor(
|
|
|
|
blink::WebDragOperation operation) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::DragSourceEndedAt(
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
|
|
|
int y,
|
2015-11-17 19:20:13 +01:00
|
|
|
cef_drag_operations_mask_t op) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragSourceSystemDragEnded() {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2017-05-12 20:28:25 +02:00
|
|
|
void CefBrowserPlatformDelegate::AccessibilityEventReceived(
|
|
|
|
const std::vector<content::AXEventNotificationDetails>& eventData) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::AccessibilityLocationChangesReceived(
|
|
|
|
const std::vector<content::AXLocationChangeNotificationDetails>& locData) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// static
|
|
|
|
int CefBrowserPlatformDelegate::TranslateModifiers(uint32 cef_modifiers) {
|
|
|
|
int webkit_modifiers = 0;
|
|
|
|
// Set modifiers based on key state.
|
|
|
|
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kShiftKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kControlKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kAltKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kMetaKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kLeftButtonDown;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kMiddleButtonDown;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kRightButtonDown;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kCapsLockOn;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kNumLockOn;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_IS_LEFT)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kIsLeft;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_IS_RIGHT)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kIsRight;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
|
2017-04-20 21:28:17 +02:00
|
|
|
webkit_modifiers |= blink::WebInputEvent::kIsKeyPad;
|
2015-11-17 19:20:13 +01:00
|
|
|
return webkit_modifiers;
|
|
|
|
}
|