2014-07-01 00:30:29 +02:00
|
|
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "libcef/browser/osr/web_contents_view_osr.h"
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
#include "libcef/browser/browser_host_impl.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "libcef/browser/osr/render_widget_host_view_osr.h"
|
2014-07-01 00:30:29 +02:00
|
|
|
#include "libcef/common/drag_data_impl.h"
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "content/browser/browser_plugin/browser_plugin_embedder.h"
|
|
|
|
#include "content/browser/browser_plugin/browser_plugin_guest.h"
|
|
|
|
#include "content/browser/web_contents/web_contents_impl.h"
|
2014-07-01 00:30:29 +02:00
|
|
|
#include "content/public/browser/render_widget_host.h"
|
|
|
|
|
2018-07-03 02:46:03 +02:00
|
|
|
CefWebContentsViewOSR::CefWebContentsViewOSR(SkColor background_color,
|
|
|
|
bool use_shared_texture,
|
|
|
|
bool use_external_begin_frame)
|
|
|
|
: background_color_(background_color),
|
|
|
|
use_shared_texture_(use_shared_texture),
|
|
|
|
use_external_begin_frame_(use_external_begin_frame),
|
2020-01-15 14:36:24 +01:00
|
|
|
web_contents_(nullptr) {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefWebContentsViewOSR::~CefWebContentsViewOSR() {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-02-15 22:03:00 +01:00
|
|
|
void CefWebContentsViewOSR::WebContentsCreated(
|
2014-09-30 20:52:26 +02:00
|
|
|
content::WebContents* web_contents) {
|
|
|
|
DCHECK(!web_contents_);
|
|
|
|
web_contents_ = web_contents;
|
2017-02-15 22:03:00 +01:00
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
auto host = web_contents_->GetRenderViewHost();
|
|
|
|
CefRenderWidgetHostViewOSR* view =
|
|
|
|
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
|
|
|
|
if (view)
|
|
|
|
view->InstallTransparency();
|
2014-09-30 20:52:26 +02:00
|
|
|
}
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
|
|
|
|
return gfx::NativeView();
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::NativeView CefWebContentsViewOSR::GetContentNativeView() const {
|
|
|
|
return gfx::NativeView();
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const {
|
|
|
|
return gfx::NativeWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect* out) const {
|
|
|
|
*out = GetViewBounds();
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefWebContentsViewOSR::Focus() {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefWebContentsViewOSR::SetInitialFocus() {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefWebContentsViewOSR::StoreFocus() {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefWebContentsViewOSR::RestoreFocus() {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
void CefWebContentsViewOSR::FocusThroughTabTraversal(bool reverse) {}
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
void CefWebContentsViewOSR::GotFocus(
|
|
|
|
content::RenderWidgetHostImpl* render_widget_host) {
|
2017-05-12 20:28:25 +02:00
|
|
|
if (web_contents_) {
|
|
|
|
content::WebContentsImpl* web_contents_impl =
|
|
|
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
|
|
|
if (web_contents_impl)
|
2017-07-27 01:19:27 +02:00
|
|
|
web_contents_impl->NotifyWebContentsFocused(render_widget_host);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::LostFocus(
|
|
|
|
content::RenderWidgetHostImpl* render_widget_host) {
|
|
|
|
if (web_contents_) {
|
|
|
|
content::WebContentsImpl* web_contents_impl =
|
|
|
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
|
|
|
if (web_contents_impl)
|
|
|
|
web_contents_impl->NotifyWebContentsLostFocus(render_widget_host);
|
2017-05-12 20:28:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::TakeFocus(bool reverse) {
|
|
|
|
if (web_contents_->GetDelegate())
|
|
|
|
web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse);
|
|
|
|
}
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
content::DropData* CefWebContentsViewOSR::GetDropData() const {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Rect CefWebContentsViewOSR::GetViewBounds() const {
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRenderWidgetHostViewOSR* view = GetView();
|
|
|
|
return view ? view->GetViewBounds() : gfx::Rect();
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2019-11-12 17:11:44 +01:00
|
|
|
void CefWebContentsViewOSR::CreateView(gfx::NativeView context) {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
|
2020-02-10 18:10:17 +01:00
|
|
|
content::RenderWidgetHost* render_widget_host) {
|
2014-07-01 00:30:29 +02:00
|
|
|
if (render_widget_host->GetView()) {
|
|
|
|
return static_cast<content::RenderWidgetHostViewBase*>(
|
|
|
|
render_widget_host->GetView());
|
|
|
|
}
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
return new CefRenderWidgetHostViewOSR(background_color_, use_shared_texture_,
|
|
|
|
use_external_begin_frame_,
|
|
|
|
render_widget_host, nullptr);
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 17:00:05 +02:00
|
|
|
// Called for popup and fullscreen widgets.
|
2014-07-01 00:30:29 +02:00
|
|
|
content::RenderWidgetHostViewBase*
|
2018-10-02 14:14:11 +02:00
|
|
|
CefWebContentsViewOSR::CreateViewForChildWidget(
|
2014-07-01 00:30:29 +02:00
|
|
|
content::RenderWidgetHost* render_widget_host) {
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRenderWidgetHostViewOSR* view = GetView();
|
|
|
|
CHECK(view);
|
|
|
|
|
2018-07-03 02:46:03 +02:00
|
|
|
return new CefRenderWidgetHostViewOSR(background_color_, use_shared_texture_,
|
|
|
|
use_external_begin_frame_,
|
2020-02-10 18:10:17 +01:00
|
|
|
render_widget_host, view);
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2018-07-06 19:11:55 +02:00
|
|
|
void CefWebContentsViewOSR::RenderViewReady() {}
|
|
|
|
|
2018-07-13 21:29:20 +02:00
|
|
|
void CefWebContentsViewOSR::RenderViewHostChanged(
|
|
|
|
content::RenderViewHost* old_host,
|
|
|
|
content::RenderViewHost* new_host) {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
2019-03-13 22:27:37 +01:00
|
|
|
bool CefWebContentsViewOSR::CloseTabAfterEventTrackingIfNeeded() {
|
2014-07-01 00:30:29 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::StartDragging(
|
|
|
|
const content::DropData& drop_data,
|
|
|
|
blink::WebDragOperationsMask allowed_ops,
|
|
|
|
const gfx::ImageSkia& image,
|
|
|
|
const gfx::Vector2d& image_offset,
|
2016-11-23 21:54:29 +01:00
|
|
|
const content::DragEventSourceInfo& event_info,
|
|
|
|
content::RenderWidgetHostImpl* source_rwh) {
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser();
|
2016-11-23 21:54:29 +01:00
|
|
|
if (browser.get()) {
|
|
|
|
browser->StartDragging(drop_data, allowed_ops, image, image_offset,
|
|
|
|
event_info, source_rwh);
|
|
|
|
} else if (web_contents_) {
|
|
|
|
web_contents_->SystemDragEnded(source_rwh);
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::UpdateDragCursor(
|
|
|
|
blink::WebDragOperation operation) {
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser();
|
|
|
|
if (browser.get())
|
|
|
|
browser->UpdateDragCursor(operation);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRenderWidgetHostViewOSR* CefWebContentsViewOSR::GetView() const {
|
|
|
|
if (web_contents_) {
|
|
|
|
return static_cast<CefRenderWidgetHostViewOSR*>(
|
|
|
|
web_contents_->GetRenderViewHost()->GetWidget()->GetView());
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
2017-02-10 23:44:11 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
CefBrowserHostImpl* CefWebContentsViewOSR::GetBrowser() const {
|
|
|
|
CefRenderWidgetHostViewOSR* view = GetView();
|
2014-07-01 00:30:29 +02:00
|
|
|
if (view)
|
2017-02-10 23:44:11 +01:00
|
|
|
return view->browser_impl().get();
|
|
|
|
return nullptr;
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|