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 "base/logging.h"
|
2020-07-04 20:21:34 +02:00
|
|
|
|
|
|
|
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
|
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(
|
2020-07-03 22:13:27 +02:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
bool owned) {
|
|
|
|
// We should not have a browser at this point.
|
|
|
|
DCHECK(!browser_);
|
|
|
|
|
|
|
|
DCHECK(!web_contents_);
|
|
|
|
web_contents_ = web_contents;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::AddNewContents(
|
|
|
|
content::WebContents* source,
|
|
|
|
std::unique_ptr<content::WebContents> new_contents,
|
|
|
|
const GURL& target_url,
|
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const gfx::Rect& initial_rect,
|
|
|
|
bool user_gesture,
|
|
|
|
bool* was_blocked) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTREACHED();
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
void CefBrowserPlatformDelegate::WebContentsDestroyed(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
DCHECK(web_contents_ && web_contents_ == web_contents);
|
|
|
|
web_contents_ = nullptr;
|
|
|
|
}
|
|
|
|
|
2020-07-03 22:13:27 +02:00
|
|
|
bool CefBrowserPlatformDelegate::ShouldTransferNavigation(
|
|
|
|
bool is_main_frame_navigation) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::RenderViewCreated(
|
2020-07-04 20:21:34 +02:00
|
|
|
content::RenderViewHost* render_view_host) {}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::RenderViewReady() {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) {
|
2020-07-03 22:13:27 +02:00
|
|
|
// We should have an associated WebContents at this point.
|
|
|
|
DCHECK(web_contents_);
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
DCHECK(!browser_);
|
2019-07-17 20:47:27 +02:00
|
|
|
DCHECK(browser);
|
2015-11-17 19:20:13 +01:00
|
|
|
browser_ = browser;
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::CreateExtensionHost(
|
|
|
|
const extensions::Extension* extension,
|
|
|
|
const GURL& url,
|
|
|
|
extensions::ViewType host_type) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
extensions::ExtensionHost* CefBrowserPlatformDelegate::GetExtensionHost()
|
|
|
|
const {
|
|
|
|
NOTREACHED();
|
|
|
|
return nullptr;
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
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) {
|
2020-07-04 04:51:17 +02:00
|
|
|
// WebContentsDestroyed should already be called.
|
|
|
|
DCHECK(!web_contents_);
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
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;
|
|
|
|
}
|
2019-07-17 20:47:27 +02:00
|
|
|
#endif
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
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() {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
|
2020-07-04 20:21:34 +02:00
|
|
|
void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
|
2015-11-17 19:20:13 +01:00
|
|
|
#endif
|
|
|
|
|
2020-07-03 22:13:27 +02:00
|
|
|
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
|
|
|
|
content::WebContents* source,
|
|
|
|
const blink::WebGestureEvent& event) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::IsNeverComposited(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<CefFileDialogRunner>
|
2017-05-17 11:29:28 +02:00
|
|
|
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
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() {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
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();
|
|
|
|
}
|
|
|
|
|
2018-07-03 02:46:03 +02:00
|
|
|
void CefBrowserPlatformDelegate::SendExternalBeginFrame() {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
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(
|
2018-06-08 18:53:10 +02:00
|
|
|
const content::AXEventNotificationDetails& eventData) {
|
2017-05-12 20:28:25 +02:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::AccessibilityLocationChangesReceived(
|
|
|
|
const std::vector<content::AXLocationChangeNotificationDetails>& locData) {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
|
|
|
|
2019-07-17 20:47:27 +02:00
|
|
|
gfx::Point CefBrowserPlatformDelegate::GetDialogPosition(
|
|
|
|
const gfx::Size& size) {
|
|
|
|
NOTREACHED();
|
|
|
|
return gfx::Point();
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
|
|
|
|
NOTREACHED();
|
|
|
|
return gfx::Size();
|
|
|
|
}
|
|
|
|
|
2020-07-03 22:13:27 +02:00
|
|
|
void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled,
|
|
|
|
const CefSize& min_size,
|
|
|
|
const CefSize& max_size) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SetAccessibilityState(
|
|
|
|
cef_state_t accessibility_state) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
|
2020-07-04 20:21:34 +02:00
|
|
|
return true;
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::Print() {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::PrintToPDF(
|
|
|
|
const CefString& path,
|
|
|
|
const CefPdfPrintSettings& settings,
|
|
|
|
CefRefPtr<CefPdfPrintCallback> callback) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::Find(int identifier,
|
|
|
|
const CefString& searchText,
|
|
|
|
bool forward,
|
|
|
|
bool matchCase,
|
|
|
|
bool findNext) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::StopFinding(bool clearSelection) {
|
2020-07-04 20:21:34 +02:00
|
|
|
NOTIMPLEMENTED();
|
2019-07-17 20:47:27 +02:00
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// static
|
2020-01-23 22:58:01 +01:00
|
|
|
int CefBrowserPlatformDelegate::TranslateWebEventModifiers(
|
|
|
|
uint32 cef_modifiers) {
|
|
|
|
int result = 0;
|
2015-11-17 19:20:13 +01:00
|
|
|
// Set modifiers based on key state.
|
|
|
|
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kShiftKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kControlKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kAltKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kMetaKey;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kLeftButtonDown;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kMiddleButtonDown;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kRightButtonDown;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kCapsLockOn;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kNumLockOn;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_IS_LEFT)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kIsLeft;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_IS_RIGHT)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kIsRight;
|
2015-11-17 19:20:13 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kIsKeyPad;
|
|
|
|
return result;
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|