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/frame_host/render_widget_host_view_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"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "content/public/browser/user_metrics.h"
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
CefWebContentsViewOSR::CefWebContentsViewOSR(bool transparent)
|
|
|
|
: transparent_(transparent),
|
2017-02-10 23:44:11 +01:00
|
|
|
web_contents_(NULL) {
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefWebContentsViewOSR::~CefWebContentsViewOSR() {
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
// Call this again for popup browsers now that the view should exist.
|
|
|
|
RenderViewCreated(web_contents_->GetRenderViewHost());
|
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();
|
|
|
|
}
|
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
void CefWebContentsViewOSR::GetScreenInfo(content::ScreenInfo* results) const {
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRenderWidgetHostViewOSR* view = GetView();
|
|
|
|
if (view)
|
|
|
|
view->GetScreenInfo(results);
|
2016-08-31 13:25:56 +02:00
|
|
|
else
|
|
|
|
WebContentsView::GetDefaultScreenInfo(results);
|
|
|
|
}
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect* out) const {
|
|
|
|
*out = GetViewBounds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::SizeContents(const gfx::Size& size) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::Focus() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::SetInitialFocus() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::StoreFocus() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::RestoreFocus() {
|
|
|
|
}
|
|
|
|
|
|
|
|
content::DropData* CefWebContentsViewOSR::GetDropData() const {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::CreateView(const gfx::Size& initial_size,
|
|
|
|
gfx::NativeView context) {
|
|
|
|
}
|
|
|
|
|
|
|
|
content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
|
2014-11-12 20:25:15 +01:00
|
|
|
content::RenderWidgetHost* render_widget_host,
|
2017-02-10 23:44:11 +01:00
|
|
|
content::RenderWidgetHost* embedder_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());
|
|
|
|
}
|
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRenderWidgetHostViewOSR* embedder_host_view = nullptr;
|
|
|
|
if (embedder_render_widget_host) {
|
|
|
|
embedder_host_view = static_cast<CefRenderWidgetHostViewOSR*>(
|
|
|
|
embedder_render_widget_host->GetView());
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
const bool is_guest_view_hack = !!embedder_render_widget_host;
|
2017-02-10 23:44:11 +01:00
|
|
|
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
|
2017-03-03 23:37:23 +01:00
|
|
|
embedder_host_view,
|
|
|
|
is_guest_view_hack);
|
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*
|
|
|
|
CefWebContentsViewOSR::CreateViewForPopupWidget(
|
|
|
|
content::RenderWidgetHost* render_widget_host) {
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRenderWidgetHostViewOSR* view = GetView();
|
|
|
|
CHECK(view);
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host, view,
|
|
|
|
false);
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
|
2017-02-15 22:03:00 +01:00
|
|
|
// |view| will be nullptr the first time this method is called for popup
|
|
|
|
// browsers.
|
2017-02-10 23:44:11 +01:00
|
|
|
CefRenderWidgetHostViewOSR* view = GetView();
|
|
|
|
if (view)
|
|
|
|
view->InstallTransparency();
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::RenderViewSwappedIn(
|
|
|
|
content::RenderViewHost* host) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) {
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
2014-09-04 19:53:40 +02:00
|
|
|
void CefWebContentsViewOSR::SetAllowOtherViews(bool allow) {
|
2014-07-01 00:30:29 +02:00
|
|
|
}
|
|
|
|
|
2014-09-04 19:53:40 +02:00
|
|
|
bool CefWebContentsViewOSR::GetAllowOtherViews() const {
|
2014-07-01 00:30:29 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefWebContentsViewOSR::IsEventTracking() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefWebContentsViewOSR::CloseTabAfterEventTracking() {
|
|
|
|
}
|
|
|
|
#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
|
|
|
}
|