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.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/browser_platform_delegate.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
#include "base/command_line.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "base/logging.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/views/cef_window.h"
|
|
|
|
#include "cef/include/views/cef_window_delegate.h"
|
|
|
|
#include "cef/libcef/browser/browser_host_base.h"
|
|
|
|
#include "cef/libcef/browser/thread_util.h"
|
|
|
|
#include "cef/libcef/browser/views/browser_view_impl.h"
|
|
|
|
#include "cef/libcef/common/cef_switches.h"
|
2023-06-26 12:08:04 +02:00
|
|
|
#include "chrome/browser/platform_util.h"
|
2024-04-17 18:01:26 +02:00
|
|
|
#include "chrome/browser/profiles/profile.h"
|
2023-06-26 12:08:04 +02:00
|
|
|
#include "chrome/browser/shell_integration.h"
|
2024-04-17 18:01:26 +02:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
|
|
|
#include "chrome/common/pref_names.h"
|
|
|
|
#include "components/prefs/pref_service.h"
|
2024-02-20 17:27:48 +01:00
|
|
|
#include "content/browser/web_contents/web_contents_impl.h"
|
2022-04-11 23:29:53 +02:00
|
|
|
#include "content/public/browser/render_view_host.h"
|
|
|
|
#include "content/public/browser/render_widget_host.h"
|
|
|
|
#include "content/public/browser/render_widget_host_view.h"
|
2020-07-04 20:21:34 +02:00
|
|
|
|
2023-06-26 12:08:04 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void ExecuteExternalProtocol(const GURL& url) {
|
|
|
|
CEF_REQUIRE_BLOCKING();
|
|
|
|
|
|
|
|
// Check that an application is associated with the scheme.
|
|
|
|
if (shell_integration::GetApplicationNameForScheme(url).empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CEF_POST_TASK(TID_UI, base::BindOnce(&platform_util::OpenExternal, url));
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
// Default popup window delegate implementation.
|
|
|
|
class PopupWindowDelegate : public CefWindowDelegate {
|
|
|
|
public:
|
|
|
|
explicit PopupWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
|
|
|
|
: browser_view_(browser_view) {}
|
|
|
|
|
|
|
|
PopupWindowDelegate(const PopupWindowDelegate&) = delete;
|
|
|
|
PopupWindowDelegate& operator=(const PopupWindowDelegate&) = delete;
|
|
|
|
|
|
|
|
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
|
|
|
|
window->AddChildView(browser_view_);
|
|
|
|
window->Show();
|
|
|
|
browser_view_->RequestFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
|
|
|
|
browser_view_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CanClose(CefRefPtr<CefWindow> window) override {
|
|
|
|
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
|
|
|
|
if (browser) {
|
|
|
|
return browser->GetHost()->TryCloseBrowser();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CefRefPtr<CefBrowserView> browser_view_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(PopupWindowDelegate);
|
|
|
|
};
|
|
|
|
|
2023-06-26 12:08:04 +02:00
|
|
|
} // namespace
|
|
|
|
|
2020-07-04 20:21:34 +02:00
|
|
|
CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
|
|
|
|
DCHECK(!browser_);
|
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
content::WebContents* CefBrowserPlatformDelegate::CreateWebContents(
|
|
|
|
CefBrowserCreateParams& create_params,
|
|
|
|
bool& own_web_contents) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::CreateViewForWebContents(
|
2024-06-21 17:26:59 +02:00
|
|
|
raw_ptr<content::WebContentsView>* view,
|
|
|
|
raw_ptr<content::RenderViewHostDelegateView>* delegate_view) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2022-09-26 21:30:45 +02:00
|
|
|
const blink::mojom::WindowFeatures& window_features,
|
2020-07-03 22:13:27 +02:00
|
|
|
bool user_gesture,
|
|
|
|
bool* was_blocked) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
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;
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::RenderViewCreated(
|
2022-04-11 23:29:53 +02:00
|
|
|
content::RenderViewHost* render_view_host) {
|
|
|
|
// Indicate that the view has an external parent (namely us). This setting is
|
|
|
|
// required for proper focus handling on Windows and Linux.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (HasExternalParent() && render_view_host->GetWidget()->GetView()) {
|
2022-04-11 23:29:53 +02:00
|
|
|
render_view_host->GetWidget()->GetView()->SetHasExternalParent(true);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2022-04-11 23:29:53 +02:00
|
|
|
}
|
2020-07-04 20:21:34 +02:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::RenderViewReady() {}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostBase* 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() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::CloseHostWindow() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
CefWindowHandle CefBrowserPlatformDelegate::GetHostWindowHandle() const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
return kNullWindowHandle;
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
CefRefPtr<CefBrowserView> CefBrowserPlatformDelegate::GetBrowserView() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
void CefBrowserPlatformDelegate::SetBrowserView(
|
|
|
|
CefRefPtr<CefBrowserView> browser_view) {
|
|
|
|
DCHECK(false);
|
|
|
|
}
|
|
|
|
|
2022-06-02 11:49:50 +02:00
|
|
|
web_modal::WebContentsModalDialogHost*
|
|
|
|
CefBrowserPlatformDelegate::GetWebContentsModalDialogHost() const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2022-06-02 11:49:50 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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,
|
2024-04-17 18:01:26 +02:00
|
|
|
bool is_devtools) {
|
|
|
|
// Default popup handling may not be Views-hosted.
|
|
|
|
if (!new_platform_delegate->IsViewsHosted()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserViewDelegate> new_delegate;
|
|
|
|
CefRefPtr<CefBrowserViewDelegate> opener_delegate;
|
2024-10-08 20:17:18 +02:00
|
|
|
cef_runtime_style_t opener_runtime_style = CEF_RUNTIME_STYLE_DEFAULT;
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
auto browser_view = GetBrowserView();
|
|
|
|
if (browser_view) {
|
|
|
|
// When |this| (the popup opener) is Views-hosted use the current delegate.
|
|
|
|
opener_delegate =
|
|
|
|
static_cast<CefBrowserViewImpl*>(browser_view.get())->delegate();
|
|
|
|
}
|
|
|
|
if (!opener_delegate) {
|
|
|
|
opener_delegate =
|
|
|
|
new_platform_delegate->GetDefaultBrowserViewDelegateForPopupOpener();
|
|
|
|
}
|
|
|
|
if (opener_delegate) {
|
|
|
|
new_delegate = opener_delegate->GetDelegateForPopupBrowserView(
|
|
|
|
browser_view, settings, client, is_devtools);
|
|
|
|
}
|
|
|
|
|
2024-10-08 20:17:18 +02:00
|
|
|
if (browser_view) {
|
|
|
|
opener_runtime_style = browser_view->GetRuntimeStyle();
|
|
|
|
} else if (opener_delegate) {
|
|
|
|
opener_runtime_style = opener_delegate->GetBrowserRuntimeStyle();
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
// Create a new BrowserView for the popup.
|
|
|
|
CefRefPtr<CefBrowserViewImpl> new_browser_view =
|
2024-10-08 20:17:18 +02:00
|
|
|
CefBrowserViewImpl::CreateForPopup(settings, new_delegate, is_devtools,
|
|
|
|
opener_runtime_style);
|
2024-04-17 18:01:26 +02:00
|
|
|
|
|
|
|
// Associate the PlatformDelegate with the new BrowserView.
|
|
|
|
new_platform_delegate->SetBrowserView(new_browser_view);
|
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
2024-04-17 18:01:26 +02:00
|
|
|
CefBrowserPlatformDelegate* new_platform_delegate,
|
2020-09-25 03:40:47 +02:00
|
|
|
CefBrowserHostBase* new_browser,
|
2024-04-17 18:01:26 +02:00
|
|
|
bool is_devtools) {
|
|
|
|
// Default popup handling may not be Views-hosted.
|
|
|
|
if (!new_platform_delegate->IsViewsHosted()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserView> new_browser_view =
|
|
|
|
CefBrowserView::GetForBrowser(new_browser);
|
|
|
|
CHECK(new_browser_view);
|
|
|
|
|
|
|
|
bool popup_handled = false;
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserViewDelegate> opener_delegate;
|
|
|
|
auto browser_view = GetBrowserView();
|
|
|
|
if (browser_view) {
|
|
|
|
// When |this| (the popup opener) is Views-hosted use the current delegate.
|
|
|
|
opener_delegate =
|
|
|
|
static_cast<CefBrowserViewImpl*>(browser_view.get())->delegate();
|
|
|
|
}
|
|
|
|
if (!opener_delegate) {
|
|
|
|
opener_delegate =
|
|
|
|
new_platform_delegate->GetDefaultBrowserViewDelegateForPopupOpener();
|
|
|
|
}
|
|
|
|
if (opener_delegate) {
|
|
|
|
popup_handled = opener_delegate->OnPopupBrowserViewCreated(
|
|
|
|
browser_view, new_browser_view.get(), is_devtools);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!popup_handled) {
|
|
|
|
CefWindow::CreateTopLevelWindow(
|
|
|
|
new PopupWindowDelegate(new_browser_view.get()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserViewDelegate>
|
|
|
|
CefBrowserPlatformDelegate::GetDefaultBrowserViewDelegateForPopupOpener() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
SkColor CefBrowserPlatformDelegate::GetBackgroundColor() const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
return SkColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::WasResized() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SendKeyEvent(const CefKeyEvent& event) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SendMouseClickEvent(
|
|
|
|
const CefMouseEvent& event,
|
|
|
|
CefBrowserHost::MouseButtonType type,
|
|
|
|
bool mouseUp,
|
|
|
|
int clickCount) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SendMouseMoveEvent(const CefMouseEvent& event,
|
|
|
|
bool mouseLeave) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SendMouseWheelEvent(const CefMouseEvent& event,
|
|
|
|
int deltaX,
|
|
|
|
int deltaY) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::SendTouchEvent(const CefTouchEvent& event) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
2022-04-08 22:48:56 +02:00
|
|
|
void CefBrowserPlatformDelegate::SetFocus(bool setFocus) {}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC))
|
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-09-25 03:40:47 +02:00
|
|
|
gfx::Point CefBrowserPlatformDelegate::GetScreenPoint(
|
2022-05-13 13:38:41 +02:00
|
|
|
const gfx::Point& view,
|
|
|
|
bool want_dip_coords) const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
return gfx::Point();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::ViewText(const std::string& text) {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::HandleKeyboardEvent(
|
2024-06-14 19:01:45 +02:00
|
|
|
const input::NativeWebKeyboardEvent& event) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-06-26 12:08:04 +02:00
|
|
|
// static
|
|
|
|
void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {
|
|
|
|
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(ExecuteExternalProtocol, url));
|
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
CefEventHandle CefBrowserPlatformDelegate::GetEventHandle(
|
2024-06-14 19:01:45 +02:00
|
|
|
const input::NativeWebKeyboardEvent& event) const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-09-25 03:40:47 +02:00
|
|
|
return kNullEventHandle;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
std::unique_ptr<CefMenuRunner> CefBrowserPlatformDelegate::CreateMenuRunner() {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::IsWindowless() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::IsViewsHosted() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-11 23:29:53 +02:00
|
|
|
bool CefBrowserPlatformDelegate::HasExternalParent() const {
|
|
|
|
// In the majority of cases a Views-hosted browser will not have an external
|
|
|
|
// parent, and visa-versa.
|
|
|
|
return !IsViewsHosted();
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2022-06-02 11:49:50 +02:00
|
|
|
bool CefBrowserPlatformDelegate::IsHidden() const {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2022-06-02 11:49:50 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::NotifyScreenInfoChanged() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::Invalidate(cef_paint_element_type_t type) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2018-07-03 02:46:03 +02:00
|
|
|
void CefBrowserPlatformDelegate::SendExternalBeginFrame() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2018-07-03 02:46:03 +02:00
|
|
|
}
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
void CefBrowserPlatformDelegate::SetWindowlessFrameRate(int frame_rate) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
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) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2016-10-28 18:11:24 +02:00
|
|
|
void CefBrowserPlatformDelegate::ImeCommitText(
|
|
|
|
const CefString& text,
|
|
|
|
const CefRange& replacement_range,
|
|
|
|
int relative_cursor_pos) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2016-10-28 18:11:24 +02:00
|
|
|
void CefBrowserPlatformDelegate::ImeFinishComposingText(bool keep_selection) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2016-10-28 18:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::ImeCancelComposition() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDragEnter(
|
|
|
|
CefRefPtr<CefDragData> drag_data,
|
|
|
|
const CefMouseEvent& event,
|
|
|
|
cef_drag_operations_mask_t allowed_ops) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDragOver(
|
|
|
|
const CefMouseEvent& event,
|
|
|
|
cef_drag_operations_mask_t allowed_ops) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDragLeave() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragTargetDrop(const CefMouseEvent& event) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
void CefBrowserPlatformDelegate::StartDragging(
|
|
|
|
const content::DropData& drop_data,
|
2020-10-08 21:54:42 +02:00
|
|
|
blink::DragOperationsMask allowed_ops,
|
2016-11-23 21:54:29 +01:00
|
|
|
const gfx::ImageSkia& image,
|
|
|
|
const gfx::Vector2d& image_offset,
|
2020-10-08 21:54:42 +02:00
|
|
|
const blink::mojom::DragEventSourceInfo& event_info,
|
2016-11-23 21:54:29 +01:00
|
|
|
content::RenderWidgetHostImpl* source_rwh) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2016-11-23 21:54:29 +01:00
|
|
|
}
|
|
|
|
|
2023-10-19 20:08:48 +02:00
|
|
|
void CefBrowserPlatformDelegate::UpdateDragOperation(
|
|
|
|
ui::mojom::DragOperation operation,
|
|
|
|
bool document_is_handling_drag) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2016-11-23 21:54:29 +01:00
|
|
|
}
|
|
|
|
|
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) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::DragSourceSystemDragEnded() {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:28:25 +02:00
|
|
|
void CefBrowserPlatformDelegate::AccessibilityEventReceived(
|
2024-05-23 03:52:35 +02:00
|
|
|
const ui::AXUpdatesAndEvents& details) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefBrowserPlatformDelegate::AccessibilityLocationChangesReceived(
|
2024-05-23 03:52:35 +02:00
|
|
|
const std::vector<ui::AXLocationChanges>& details) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
|
2019-07-17 20:47:27 +02:00
|
|
|
gfx::Point CefBrowserPlatformDelegate::GetDialogPosition(
|
|
|
|
const gfx::Size& size) {
|
2022-06-02 11:49:50 +02:00
|
|
|
const gfx::Size& max_size = GetMaximumDialogSize();
|
|
|
|
return gfx::Point((max_size.width() - size.width()) / 2,
|
|
|
|
(max_size.height() - size.height()) / 2);
|
2019-07-17 20:47:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!web_contents_) {
|
2022-06-02 11:49:50 +02:00
|
|
|
return gfx::Size();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2022-06-02 11:49:50 +02:00
|
|
|
|
|
|
|
// The dialog should try to fit within the overlay for the web contents.
|
|
|
|
// Note that, for things like print preview, this is just a suggested maximum.
|
|
|
|
return web_contents_->GetContainerBounds().size();
|
2019-07-17 20:47:27 +02:00
|
|
|
}
|
|
|
|
|
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) {
|
2024-02-20 17:27:48 +01:00
|
|
|
// Do nothing if state is set to default. It'll be disabled by default and
|
|
|
|
// controlled by the command-line flags "force-renderer-accessibility" and
|
|
|
|
// "disable-renderer-accessibility".
|
|
|
|
if (accessibility_state == STATE_DEFAULT) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
content::WebContentsImpl* web_contents_impl =
|
|
|
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
|
|
|
|
|
|
|
if (!web_contents_impl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui::AXMode accMode;
|
|
|
|
// In windowless mode set accessibility to TreeOnly mode. Else native
|
|
|
|
// accessibility APIs, specific to each platform, are also created.
|
|
|
|
if (accessibility_state == STATE_ENABLED) {
|
|
|
|
accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete;
|
|
|
|
}
|
|
|
|
web_contents_impl->SetAccessibilityMode(accMode);
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const {
|
2024-04-17 18:01:26 +02:00
|
|
|
if (IsWindowless()) {
|
|
|
|
// Not supported with windowless rendering.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (web_contents_) {
|
|
|
|
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
|
|
|
|
web_contents_->GetBrowserContext());
|
|
|
|
if (cef_browser_context->AsProfile()->GetPrefs()->GetBoolean(
|
|
|
|
prefs::kPrintPreviewDisabled)) {
|
|
|
|
// Disabled on the Profile.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
|
if (command_line->HasSwitch(switches::kDisablePrintPreview)) {
|
|
|
|
// Disabled explicitly via the command-line.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool default_disabled = IsAlloyStyle();
|
|
|
|
if (default_disabled &&
|
|
|
|
!command_line->HasSwitch(switches::kEnablePrintPreview)) {
|
|
|
|
// Default disabled and not enabled explicitly via the command-line.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-04 20:21:34 +02:00
|
|
|
return true;
|
2020-07-03 22:13:27 +02:00
|
|
|
}
|
|
|
|
|
2022-02-17 19:17:29 +01:00
|
|
|
void CefBrowserPlatformDelegate::Find(const CefString& searchText,
|
2020-07-03 22:13:27 +02:00
|
|
|
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(
|
2023-06-01 16:06:15 +02:00
|
|
|
uint32_t cef_modifiers) {
|
2020-01-23 22:58:01 +01:00
|
|
|
int result = 0;
|
2015-11-17 19:20:13 +01:00
|
|
|
// Set modifiers based on key state.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) {
|
2021-07-23 18:40:13 +02:00
|
|
|
result |= blink::WebInputEvent::kCapsLockOn;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kShiftKey;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kControlKey;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_ALT_DOWN) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kAltKey;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kLeftButtonDown;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kMiddleButtonDown;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kRightButtonDown;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) {
|
2021-07-23 18:40:13 +02:00
|
|
|
result |= blink::WebInputEvent::kMetaKey;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kNumLockOn;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) {
|
2021-07-19 17:52:36 +02:00
|
|
|
result |= blink::WebInputEvent::kIsKeyPad;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_IS_LEFT) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kIsLeft;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_IS_RIGHT) {
|
2020-01-23 22:58:01 +01:00
|
|
|
result |= blink::WebInputEvent::kIsRight;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_ALTGR_DOWN) {
|
2021-07-19 17:52:36 +02:00
|
|
|
result |= blink::WebInputEvent::kAltGrKey;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (cef_modifiers & EVENTFLAG_IS_REPEAT) {
|
2021-07-19 17:52:36 +02:00
|
|
|
result |= blink::WebInputEvent::kIsAutoRepeat;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-01-23 22:58:01 +01:00
|
|
|
return result;
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|