Simplify OSR guest view implementation

This commit is contained in:
Marshall Greenblatt 2017-02-10 17:44:11 -05:00
parent 0a62a4dca8
commit 903da5e452
16 changed files with 570 additions and 778 deletions

View File

@ -2239,28 +2239,13 @@ bool CefBrowserHostImpl::CanDragEnter(
return true;
}
bool CefBrowserHostImpl::ShouldCreateWebContents(
void CefBrowserHostImpl::GetCustomWebContentsView(
content::WebContents* web_contents,
content::SiteInstance* source_site_instance,
int32_t route_id,
int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace,
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view) {
// In cases where the navigation will occur in a new render process the
// |route_id| value will be MSG_ROUTING_NONE here (because the existing
// renderer will not be able to communicate with the new renderer) and
// OpenURLFromTab will be called after WebContentsCreated.
CefBrowserInfoManager::GetInstance()->ShouldCreateWebContents(
CefBrowserInfoManager::GetInstance()->GetCustomWebContentsView(
web_contents, target_url, view, delegate_view);
return true;
}
void CefBrowserHostImpl::WebContentsCreated(

View File

@ -402,18 +402,9 @@ class CefBrowserHostImpl : public CefBrowserHost,
content::WebContents* source,
const content::DropData& data,
blink::WebDragOperationsMask operations_allowed) override;
bool ShouldCreateWebContents(
void GetCustomWebContentsView(
content::WebContents* web_contents,
content::SiteInstance* source_site_instance,
int32_t route_id,
int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace,
content::WebContentsView** view,
content::RenderViewHostDelegateView** delegate_view) override;
void WebContentsCreated(content::WebContents* source_contents,

View File

@ -255,7 +255,7 @@ bool CefBrowserInfoManager::CanCreateWindow(
return allow;
}
void CefBrowserInfoManager::ShouldCreateWebContents(
void CefBrowserInfoManager::GetCustomWebContentsView(
content::WebContents* web_contents,
const GURL& target_url,
content::WebContentsView** view,
@ -275,7 +275,7 @@ void CefBrowserInfoManager::ShouldCreateWebContents(
}
pending_popup->step =
CefBrowserInfoManager::PendingPopup::SHOULD_CREATE_WEB_CONTENTS;
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW;
PushPendingPopup(std::move(pending_popup));
}
@ -293,7 +293,7 @@ void CefBrowserInfoManager::WebContentsCreated(
source_contents->GetRenderViewHost()->GetMainFrame();
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
PopPendingPopup(
CefBrowserInfoManager::PendingPopup::SHOULD_CREATE_WEB_CONTENTS,
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
host->GetProcess()->GetID(), host->GetRoutingID(),
target_url);
DCHECK(pending_popup.get());

View File

@ -71,9 +71,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
int opener_render_frame_id,
bool* no_javascript_access);
// Called from CefBrowserHostImpl::ShouldCreateWebContents. See comments on
// Called from CefBrowserHostImpl::GetCustomWebContentsView. See comments on
// PendingPopup for more information.
void ShouldCreateWebContents(
void GetCustomWebContentsView(
content::WebContents* web_contents,
const GURL& target_url,
content::WebContentsView** view,
@ -137,7 +137,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// an extension guest view then the popup is canceled and
// CefBrowserHostImpl::OpenURLFromTab is called.
// And then the following calls may occur at the same time:
// - CefBrowserHostImpl::ShouldCreateWebContents (UIT)
// - CefBrowserHostImpl::GetCustomWebContentsView (UIT)
// Creates the OSR views for windowless popups.
// - CefBrowserHostImpl::WebContentsCreated (UIT)
// Creates the CefBrowserHostImpl representation for the popup.
@ -149,7 +149,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// to differentiate between them at different processing steps.
enum Step {
CAN_CREATE_WINDOW,
SHOULD_CREATE_WEB_CONTENTS
GET_CUSTOM_WEB_CONTENTS_VIEW,
} step;
// Initial state from ViewHostMsg_CreateWindow.
@ -168,11 +168,11 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
};
// Between the calls to CanCreateWindow and ShouldCreateWebContents
// Between the calls to CanCreateWindow and GetCustomWebContentsView
// RenderViewHostImpl::CreateNewWindow() will call
// RenderProcessHostImpl::FilterURL() which, in the case of "javascript:"
// URIs, rewrites the URL to "about:blank". We need to apply the same filter
// otherwise ShouldCreateWebContents will fail to retrieve the PopupInfo.
// otherwise GetCustomWebContentsView will fail to retrieve the PopupInfo.
static void FilterPendingPopupURL(
int opener_process_id,
std::unique_ptr<PendingPopup> pending_popup);

View File

@ -49,8 +49,7 @@ void CefMimeHandlerViewGuestDelegate::OverrideWebContentsCreateParams(
}
}
bool CefMimeHandlerViewGuestDelegate::OnGuestAttached(
content::WebContentsView* guest_view,
void CefMimeHandlerViewGuestDelegate::OnGuestAttached(
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
@ -68,24 +67,9 @@ bool CefMimeHandlerViewGuestDelegate::OnGuestAttached(
info->guest_render_id_manager()->add_render_frame_id(
main_frame_host->GetProcess()->GetID(),
main_frame_host->GetRoutingID());
if (owner_browser->IsWindowless()) {
// Use the OSR view instead of the default WebContentsViewGuest.
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents);
CefWebContentsViewOSR* view_osr =
static_cast<CefWebContentsViewOSR*>(
web_contents_impl->GetView());
view_osr->set_web_contents(web_contents);
view_osr->set_guest(web_contents_impl->GetBrowserPluginGuest());
return true;
}
return false;
}
bool CefMimeHandlerViewGuestDelegate::OnGuestDetached(
content::WebContentsView* guest_view,
void CefMimeHandlerViewGuestDelegate::OnGuestDetached(
content::WebContentsView* parent_view) {
content::WebContents* web_contents = guest_->web_contents();
DCHECK(web_contents);
@ -113,21 +97,6 @@ bool CefMimeHandlerViewGuestDelegate::OnGuestDetached(
context->OnRenderFrameDeleted(render_process_id, render_frame_id,
is_main_frame, true);
}
// Do nothing when the browser is windowless.
return owner_browser->IsWindowless();
}
bool CefMimeHandlerViewGuestDelegate::CreateViewForWidget(
content::WebContentsView* guest_view,
content::RenderWidgetHost* render_widget_host) {
CefRefPtr<CefBrowserHostImpl> owner_browser = GetOwnerBrowser(guest_);
if (owner_browser->IsWindowless()) {
static_cast<CefWebContentsViewOSR*>(guest_view)->CreateViewForWidget(
render_widget_host, true);
return true;
}
return false;
}
bool CefMimeHandlerViewGuestDelegate::HandleContextMenu(

View File

@ -22,13 +22,8 @@ class CefMimeHandlerViewGuestDelegate : public MimeHandlerViewGuestDelegate {
// MimeHandlerViewGuestDelegate methods.
void OverrideWebContentsCreateParams(
content::WebContents::CreateParams* params) override;
bool OnGuestAttached(content::WebContentsView* guest_view,
content::WebContentsView* parent_view) override;
bool OnGuestDetached(content::WebContentsView* guest_view,
content::WebContentsView* parent_view) override;
bool CreateViewForWidget(
content::WebContentsView* guest_view,
content::RenderWidgetHost* render_widget_host) override;
void OnGuestAttached(content::WebContentsView* parent_view) override;
void OnGuestDetached(content::WebContentsView* parent_view) override;
bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params) override;

View File

@ -473,8 +473,11 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
DCHECK(render_widget_host_);
DCHECK(!render_widget_host_->GetView());
// CefBrowserHostImpl might not be created at this time for popups.
if (content::RenderViewHost::From(render_widget_host_)) {
if (parent_host_view_) {
browser_impl_ = parent_host_view_->browser_impl();
DCHECK(browser_impl_);
} else if (content::RenderViewHost::From(render_widget_host_)) {
// CefBrowserHostImpl might not be created at this time for popups.
browser_impl_ = CefBrowserHostImpl::GetBrowserForHost(
content::RenderViewHost::From(render_widget_host_));
}
@ -542,8 +545,7 @@ CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
// Called for full-screen widgets.
void CefRenderWidgetHostViewOSR::InitAsChild(gfx::NativeView parent_view) {
DCHECK(parent_host_view_);
browser_impl_ = parent_host_view_->browser_impl();
DCHECK(browser_impl_.get());
DCHECK(browser_impl_);
if (parent_host_view_->child_host_view_) {
// Cancel the previous popup widget.
@ -747,8 +749,7 @@ void CefRenderWidgetHostViewOSR::InitAsPopup(
content::RenderWidgetHostView* parent_host_view,
const gfx::Rect& pos) {
DCHECK_EQ(parent_host_view_, parent_host_view);
browser_impl_ = parent_host_view_->browser_impl();
DCHECK(browser_impl_.get());
DCHECK(browser_impl_);
if (parent_host_view_->popup_host_view_) {
// Cancel the previous popup widget.
@ -777,6 +778,18 @@ void CefRenderWidgetHostViewOSR::InitAsFullscreen(
NOTREACHED() << "Fullscreen widgets are not supported in OSR";
}
// Called for the "platform view" created by WebContentsViewGuest and owned by
// RenderWidgetHostViewGuest.
void CefRenderWidgetHostViewOSR::InitAsGuest(
content::RenderWidgetHostView* parent_host_view,
content::RenderWidgetHostViewGuest* guest_view) {
DCHECK_EQ(parent_host_view_, parent_host_view);
DCHECK(browser_impl_);
parent_host_view_->AddGuestHostView(this);
parent_host_view_->RegisterGuestViewFrameSwappedCallback(guest_view);
}
void CefRenderWidgetHostViewOSR::UpdateCursor(
const content::WebCursor& cursor) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::UpdateCursor");
@ -1346,24 +1359,6 @@ void CefRenderWidgetHostViewOSR::OnPaint(
ReleaseResize();
}
void CefRenderWidgetHostViewOSR::AddGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.insert(guest_host);
}
void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.erase(guest_host);
}
void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view) {
guest_host_view->RegisterFrameSwappedCallback(base::MakeUnique<base::Closure>(
base::Bind(&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
weak_ptr_factory_.GetWeakPtr(),
base::Unretained(guest_host_view))));
}
#if !defined(OS_MACOSX)
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
@ -1553,6 +1548,24 @@ void CefRenderWidgetHostViewOSR::OnScrollOffsetChanged() {
is_scroll_offset_changed_pending_ = false;
}
void CefRenderWidgetHostViewOSR::AddGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.insert(guest_host);
}
void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
CefRenderWidgetHostViewOSR* guest_host) {
guest_host_views_.erase(guest_host);
}
void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view) {
guest_host_view->RegisterFrameSwappedCallback(base::MakeUnique<base::Closure>(
base::Bind(&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
weak_ptr_factory_.GetWeakPtr(),
base::Unretained(guest_host_view))));
}
void CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped(
content::RenderWidgetHostViewGuest* guest_host_view) {
InvalidateInternal(

View File

@ -131,6 +131,8 @@ class CefRenderWidgetHostViewOSR
const gfx::Rect& pos) override;
void InitAsFullscreen(
content::RenderWidgetHostView* reference_host_view) override;
void InitAsGuest(content::RenderWidgetHostView* parent_host_view,
content::RenderWidgetHostViewGuest* guest_view) override;
void UpdateCursor(const content::WebCursor& cursor) override;
void SetIsLoading(bool is_loading) override;
void RenderProcessGone(base::TerminationStatus status,
@ -230,14 +232,6 @@ class CefRenderWidgetHostViewOSR
void ImeFinishComposingText(bool keep_selection);
void ImeCancelComposition();
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
// Register a callback that will be executed when |guest_host_view| receives
// OnSwapCompositorFrame. The callback triggers repaint of the embedder view.
void RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view);
CefRefPtr<CefBrowserHostImpl> browser_impl() const { return browser_impl_; }
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser) {
browser_impl_ = browser;
@ -271,6 +265,14 @@ class CefRenderWidgetHostViewOSR
void OnScrollOffsetChanged();
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
// Register a callback that will be executed when |guest_host_view| receives
// OnSwapCompositorFrame. The callback triggers repaint of the embedder view.
void RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view);
void OnGuestViewFrameSwapped(
content::RenderWidgetHostViewGuest* guest_host_view);

View File

@ -18,9 +18,7 @@
CefWebContentsViewOSR::CefWebContentsViewOSR(bool transparent)
: transparent_(transparent),
web_contents_(NULL),
view_(NULL),
guest_(NULL) {
web_contents_(NULL) {
}
CefWebContentsViewOSR::~CefWebContentsViewOSR() {
@ -32,11 +30,6 @@ void CefWebContentsViewOSR::set_web_contents(
web_contents_ = web_contents;
}
void CefWebContentsViewOSR::set_guest(content::BrowserPluginGuest* guest) {
DCHECK(!guest_);
guest_ = guest;
}
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
return gfx::NativeView();
}
@ -50,39 +43,18 @@ gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const {
}
void CefWebContentsViewOSR::GetScreenInfo(content::ScreenInfo* results) const {
if (view_)
view_->GetScreenInfo(results);
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
view->GetScreenInfo(results);
else
WebContentsView::GetDefaultScreenInfo(results);
}
void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect* out) const {
if (guest_) {
// Based on WebContentsViewGuest::GetContainerBounds.
if (guest_->embedder_web_contents()) {
// We need embedder container's bounds to calculate our bounds.
guest_->embedder_web_contents()->GetView()->GetContainerBounds(out);
gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point());
out->Offset(guest_coordinates.x(), guest_coordinates.y());
} else {
out->set_origin(gfx::Point());
}
out->set_size(size_);
return;
}
*out = GetViewBounds();
}
void CefWebContentsViewOSR::SizeContents(const gfx::Size& size) {
if (guest_) {
// Based on WebContentsViewGuest::SizeContents.
size_ = size;
content::RenderWidgetHostView* rwhv =
web_contents_->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetSize(size);
}
}
void CefWebContentsViewOSR::Focus() {
@ -102,71 +74,49 @@ content::DropData* CefWebContentsViewOSR::GetDropData() const {
}
gfx::Rect CefWebContentsViewOSR::GetViewBounds() const {
if (guest_) {
// Based on WebContentsViewGuest::GetViewBounds.
return gfx::Rect(size_);
}
return view_ ? view_->GetViewBounds() : gfx::Rect();
CefRenderWidgetHostViewOSR* view = GetView();
return view ? view->GetViewBounds() : gfx::Rect();
}
void CefWebContentsViewOSR::CreateView(const gfx::Size& initial_size,
gfx::NativeView context) {
if (guest_) {
// Based on WebContentsViewGuest::CreateView.
size_ = initial_size;
}
}
content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) {
content::RenderWidgetHost* embedder_render_widget_host) {
if (render_widget_host->GetView()) {
return static_cast<content::RenderWidgetHostViewBase*>(
render_widget_host->GetView());
}
if (guest_) {
// Based on WebContentsViewGuest::CreateViewForWidget.
content::WebContents* embedder_web_contents =
guest_->embedder_web_contents();
CefRenderWidgetHostViewOSR* embedder_host_view =
static_cast<CefRenderWidgetHostViewOSR*>(
embedder_web_contents->GetRenderViewHost()->GetWidget()->GetView());
CefRenderWidgetHostViewOSR* platform_widget =
new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
embedder_host_view);
embedder_host_view->AddGuestHostView(platform_widget);
content::RenderWidgetHostViewGuest* guest_host_view =
content::RenderWidgetHostViewGuest::Create(
render_widget_host,
guest_,
platform_widget->GetWeakPtr());
embedder_host_view->RegisterGuestViewFrameSwappedCallback(guest_host_view);
return guest_host_view;
CefRenderWidgetHostViewOSR* embedder_host_view = nullptr;
if (embedder_render_widget_host) {
embedder_host_view = static_cast<CefRenderWidgetHostViewOSR*>(
embedder_render_widget_host->GetView());
}
view_ = new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
NULL);
return view_;
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
embedder_host_view);
}
// Called for popup and fullscreen widgets.
content::RenderWidgetHostViewBase*
CefWebContentsViewOSR::CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) {
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
view_);
CefRenderWidgetHostViewOSR* view = GetView();
CHECK(view);
return new CefRenderWidgetHostViewOSR(transparent_, render_widget_host, view);
}
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {
}
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
if (view_)
view_->InstallTransparency();
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
view->InstallTransparency();
}
void CefWebContentsViewOSR::RenderViewSwappedIn(
@ -199,33 +149,7 @@ void CefWebContentsViewOSR::StartDragging(
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
if (guest_) {
// Based on WebContentsViewGuest::StartDragging.
content::WebContentsImpl* embedder_web_contents =
guest_->embedder_web_contents();
embedder_web_contents->GetBrowserPluginEmbedder()->StartDrag(guest_);
content::RenderViewHostImpl* embedder_render_view_host =
static_cast<content::RenderViewHostImpl*>(
embedder_web_contents->GetRenderViewHost());
CHECK(embedder_render_view_host);
content::RenderViewHostDelegateView* view =
embedder_render_view_host->GetDelegate()->GetDelegateView();
if (view) {
content::RecordAction(
base::UserMetricsAction("BrowserPlugin.Guest.StartDrag"));
view->StartDragging(drop_data, allowed_ops, image, image_offset,
event_info, source_rwh);
} else {
embedder_web_contents->SystemDragEnded(source_rwh);
}
return;
}
CefRefPtr<CefBrowserHostImpl> browser;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(view_);
if (view)
browser = view->browser_impl();
CefRefPtr<CefBrowserHostImpl> browser = GetBrowser();
if (browser.get()) {
browser->StartDragging(drop_data, allowed_ops, image, image_offset,
event_info, source_rwh);
@ -236,24 +160,22 @@ void CefWebContentsViewOSR::StartDragging(
void CefWebContentsViewOSR::UpdateDragCursor(
blink::WebDragOperation operation) {
if (guest_) {
// Based on WebContentsViewGuest::UpdateDragCursor.
content::RenderViewHostImpl* embedder_render_view_host =
static_cast<content::RenderViewHostImpl*>(
guest_->embedder_web_contents()->GetRenderViewHost());
CHECK(embedder_render_view_host);
content::RenderViewHostDelegateView* view =
embedder_render_view_host->GetDelegate()->GetDelegateView();
if (view)
view->UpdateDragCursor(operation);
return;
}
CefRefPtr<CefBrowserHostImpl> browser;
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(view_);
if (view)
browser = view->browser_impl();
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());
}
return nullptr;
}
CefBrowserHostImpl* CefWebContentsViewOSR::GetBrowser() const {
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
return view->browser_impl().get();
return nullptr;
}

View File

@ -15,6 +15,7 @@ class WebContents;
class WebContentsViewDelegate;
}
class CefBrowserHostImpl;
class CefRenderWidgetHostViewOSR;
// An implementation of WebContentsView for off-screen rendering.
@ -26,7 +27,6 @@ class CefWebContentsViewOSR : public content::WebContentsView,
void set_web_contents(content::WebContents* web_contents);
content::WebContents* web_contents() const { return web_contents_; }
void set_guest(content::BrowserPluginGuest* guest);
// WebContentsView methods.
gfx::NativeView GetNativeView() const override;
@ -45,7 +45,7 @@ class CefWebContentsViewOSR : public content::WebContentsView,
gfx::NativeView context) override;
content::RenderWidgetHostViewBase* CreateViewForWidget(
content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) override;
content::RenderWidgetHost* embedder_render_widget_host) override;
content::RenderWidgetHostViewBase* CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
@ -71,13 +71,12 @@ class CefWebContentsViewOSR : public content::WebContentsView,
void UpdateDragCursor(blink::WebDragOperation operation) override;
private:
CefRenderWidgetHostViewOSR* GetView() const;
CefBrowserHostImpl* GetBrowser() const;
const bool transparent_;
content::WebContents* web_contents_;
CefRenderWidgetHostViewOSR* view_;
content::BrowserPluginGuest* guest_;
gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR);
};

View File

@ -58,6 +58,9 @@ patches = [
# Fix multiple handling of WM_MOUSEWHEEL messages on Windows.
# https://bitbucket.org/chromiumembedded/cef/issues/1481
#
# Support custom RenderWidgetHostViewOSR for BrowserPluginGuest.
# https://bitbucket.org/chromiumembedded/cef/issues/1565
#
# Fix focus/activation handling and keyboard input on Windows and Linux.
# https://bitbucket.org/chromiumembedded/cef/issues/1677
# https://bitbucket.org/chromiumembedded/cef/issues/1679
@ -65,7 +68,7 @@ patches = [
#
# Support creation of captionless windows with resizable borders.
# https://bitbucket.org/chromiumembedded/cef/issues/1749
'name': 'views_widget_180_1481_1677_1749',
'name': 'views_widget_180_1481_1565_1677_1749',
'path': '../',
},
{
@ -77,7 +80,10 @@ patches = [
{
# Allow specification of a custom WebContentsView.
# https://bitbucket.org/chromiumembedded/cef/issues/1257
'name': 'web_contents_1257',
#
# Support custom RenderWidgetHostViewOSR for BrowserPluginGuest.
# https://bitbucket.org/chromiumembedded/cef/issues/1565
'name': 'web_contents_1257_1565',
'path': '../',
},
{
@ -87,18 +93,10 @@ patches = [
'path': '../',
},
{
# Allow specification of a custom WebContentsViewGuest implementation for
# MimeHandlerView.
# https://bitbucket.org/chromiumembedded/cef/issues/1565
'name': 'mime_handler_view_1565',
'path': '../extensions/browser/guest_view/mime_handler_view/',
},
{
# Allow specification of a custom WebContentsViewGuest implementation for
# BrowserPluginGuest.
# Support custom RenderWidgetHostViewOSR for BrowserPluginGuest.
# https://bitbucket.org/chromiumembedded/cef/issues/1565
'name': 'browser_plugin_guest_1565',
'path': '../content/',
'path': '../',
},
{
# Allow customization of the WebView background color.

View File

@ -1,97 +1,244 @@
diff --git browser/browser_plugin/browser_plugin_guest.cc browser/browser_plugin/browser_plugin_guest.cc
index 97ea047..1efbcf9 100644
--- browser/browser_plugin/browser_plugin_guest.cc
+++ browser/browser_plugin/browser_plugin_guest.cc
@@ -29,7 +29,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
-#include "content/browser/web_contents/web_contents_view_guest.h"
+#include "content/browser/web_contents/web_contents_view.h"
#include "content/common/browser_plugin/browser_plugin_constants.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
#include "content/common/content_constants_internal.h"
@@ -310,20 +310,19 @@ void BrowserPluginGuest::InitInternal(
guest_window_rect_ = params.view_rect;
if (owner_web_contents_ != owner_web_contents) {
- WebContentsViewGuest* new_view = nullptr;
+ WebContentsView* new_view = nullptr;
if (!GuestMode::IsCrossProcessFrameGuest(GetWebContents())) {
- new_view =
- static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
+ new_view = GetWebContents()->GetView();
diff --git content/browser/browser_plugin/browser_plugin_guest.cc content/browser/browser_plugin/browser_plugin_guest.cc
index 97ea047..8a4e4d4 100644
--- content/browser/browser_plugin/browser_plugin_guest.cc
+++ content/browser/browser_plugin/browser_plugin_guest.cc
@@ -316,14 +316,20 @@ void BrowserPluginGuest::InitInternal(
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
}
if (owner_web_contents_ && new_view)
- new_view->OnGuestDetached(owner_web_contents_->GetView());
+ delegate_->OnGuestDetached(new_view, owner_web_contents_->GetView());
- if (owner_web_contents_ && new_view)
+ if (owner_web_contents_ && new_view) {
new_view->OnGuestDetached(owner_web_contents_->GetView());
+ if (delegate_)
+ delegate_->OnGuestDetached(owner_web_contents_->GetView());
+ }
// Once a BrowserPluginGuest has an embedder WebContents, it's considered to
// be attached.
owner_web_contents_ = owner_web_contents;
if (new_view)
- new_view->OnGuestAttached(owner_web_contents_->GetView());
+ delegate_->OnGuestAttached(new_view, owner_web_contents_->GetView());
- if (new_view)
+ if (new_view) {
new_view->OnGuestAttached(owner_web_contents_->GetView());
+ if (delegate_)
+ delegate_->OnGuestAttached(owner_web_contents_->GetView());
+ }
}
RendererPreferences* renderer_prefs =
@@ -787,11 +786,10 @@ void BrowserPluginGuest::OnWillAttachComplete(
->GetWidget()
->Init();
GetWebContents()->GetMainFrame()->Init();
- WebContentsViewGuest* web_contents_view =
- static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
@@ -791,7 +797,8 @@ void BrowserPluginGuest::OnWillAttachComplete(
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
if (!web_contents()->GetRenderViewHost()->GetWidget()->GetView()) {
- web_contents_view->CreateViewForWidget(
web_contents_view->CreateViewForWidget(
- web_contents()->GetRenderViewHost()->GetWidget(), true);
+ delegate_->CreateViewForWidget(
+ GetWebContents()->GetView(),
+ web_contents()->GetRenderViewHost()->GetWidget());
+ web_contents()->GetRenderViewHost()->GetWidget(),
+ embedder_web_contents->GetRenderViewHost()->GetWidget());
}
}
diff --git public/browser/browser_plugin_guest_delegate.cc public/browser/browser_plugin_guest_delegate.cc
index 8d691ef..eb13b5d 100644
--- public/browser/browser_plugin_guest_delegate.cc
+++ public/browser/browser_plugin_guest_delegate.cc
@@ -4,6 +4,8 @@
diff --git content/browser/frame_host/interstitial_page_impl.cc content/browser/frame_host/interstitial_page_impl.cc
index 66aab6f..1305f14 100644
--- content/browser/frame_host/interstitial_page_impl.cc
+++ content/browser/frame_host/interstitial_page_impl.cc
@@ -589,7 +589,7 @@ WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
WebContentsView* wcv =
static_cast<WebContentsImpl*>(web_contents())->GetView();
RenderWidgetHostViewBase* view =
- wcv->CreateViewForWidget(render_view_host_->GetWidget(), false);
+ wcv->CreateViewForWidget(render_view_host_->GetWidget(), nullptr);
RenderWidgetHostImpl::From(render_view_host_->GetWidget())->SetView(view);
render_view_host_->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION);
#include "content/public/browser/browser_plugin_guest_delegate.h"
diff --git content/browser/web_contents/web_contents_view.h content/browser/web_contents/web_contents_view.h
index e4401f8..f2fdb9b 100644
--- content/browser/web_contents/web_contents_view.h
+++ content/browser/web_contents/web_contents_view.h
@@ -86,13 +86,9 @@ class WebContentsView {
// Sets up the View that holds the rendered web page, receives messages for
// it and contains page plugins. The host view should be sized to the current
// size of the WebContents.
- //
- // |is_guest_view_hack| is temporary hack and will be removed once
- // RenderWidgetHostViewGuest is not dependent on platform view.
- // TODO(lazyboy): Remove |is_guest_view_hack| once http://crbug.com/330264 is
- // fixed.
virtual RenderWidgetHostViewBase* CreateViewForWidget(
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) = 0;
+ RenderWidgetHost* render_widget_host,
+ RenderWidgetHost* embedder_render_widget_host) = 0;
+#include "content/browser/web_contents/web_contents_view_guest.h"
+
namespace content {
bool BrowserPluginGuestDelegate::CanRunInDetachedState() const {
@@ -48,4 +50,23 @@ SiteInstance* BrowserPluginGuestDelegate::GetOwnerSiteInstance() {
return nullptr;
// Creates a new View that holds a popup and receives messages for it.
virtual RenderWidgetHostViewBase* CreateViewForPopupWidget(
diff --git content/browser/web_contents/web_contents_view_aura.cc content/browser/web_contents/web_contents_view_aura.cc
index ab62938..d1aeb67 100644
--- content/browser/web_contents/web_contents_view_aura.cc
+++ content/browser/web_contents/web_contents_view_aura.cc
@@ -823,7 +823,8 @@ void WebContentsViewAura::CreateView(
}
+void BrowserPluginGuestDelegate::OnGuestAttached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ static_cast<WebContentsViewGuest*>(guest_view)->OnGuestAttached(parent_view);
+}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
+ RenderWidgetHost* render_widget_host,
+ RenderWidgetHost* embedder_render_widget_host) {
if (render_widget_host->GetView()) {
// During testing, the view will already be set up in most cases to the
// test view, so we don't want to clobber it with a real one. To verify that
@@ -836,7 +837,8 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
}
RenderWidgetHostViewAura* view =
- new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack);
+ new RenderWidgetHostViewAura(render_widget_host,
+ !!embedder_render_widget_host);
view->InitAsChild(GetRenderWidgetHostViewParent());
RenderWidgetHostImpl* host_impl =
diff --git content/browser/web_contents/web_contents_view_aura.h content/browser/web_contents/web_contents_view_aura.h
index 2e7beab..a62b593 100644
--- content/browser/web_contents/web_contents_view_aura.h
+++ content/browser/web_contents/web_contents_view_aura.h
@@ -110,7 +110,7 @@ class CONTENT_EXPORT WebContentsViewAura
gfx::NativeView context) override;
RenderWidgetHostViewBase* CreateViewForWidget(
RenderWidgetHost* render_widget_host,
- bool is_guest_view_hack) override;
+ RenderWidgetHost* embedder_render_widget_host) override;
RenderWidgetHostViewBase* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
diff --git content/browser/web_contents/web_contents_view_child_frame.cc content/browser/web_contents/web_contents_view_child_frame.cc
index 17d39e9..f591959 100644
--- content/browser/web_contents/web_contents_view_child_frame.cc
+++ content/browser/web_contents/web_contents_view_child_frame.cc
@@ -93,7 +93,7 @@ void WebContentsViewChildFrame::CreateView(const gfx::Size& initial_size,
RenderWidgetHostViewBase* WebContentsViewChildFrame::CreateViewForWidget(
RenderWidgetHost* render_widget_host,
- bool is_guest_view_hack) {
+ RenderWidgetHost* embedder_render_widget_host) {
return RenderWidgetHostViewChildFrame::Create(render_widget_host);
}
diff --git content/browser/web_contents/web_contents_view_child_frame.h content/browser/web_contents/web_contents_view_child_frame.h
index 86ce68b..fd21e5a 100644
--- content/browser/web_contents/web_contents_view_child_frame.h
+++ content/browser/web_contents/web_contents_view_child_frame.h
@@ -39,7 +39,7 @@ class WebContentsViewChildFrame : public WebContentsView,
gfx::NativeView context) override;
RenderWidgetHostViewBase* CreateViewForWidget(
RenderWidgetHost* render_widget_host,
- bool is_guest_view_hack) override;
+ RenderWidgetHost* embedder_render_widget_host) override;
RenderWidgetHostViewBase* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
diff --git content/browser/web_contents/web_contents_view_guest.cc content/browser/web_contents/web_contents_view_guest.cc
index b2b86fa..00c9126 100644
--- content/browser/web_contents/web_contents_view_guest.cc
+++ content/browser/web_contents/web_contents_view_guest.cc
@@ -72,6 +72,8 @@ void WebContentsViewGuest::GetScreenInfo(ScreenInfo* screen_info) const {
void WebContentsViewGuest::OnGuestAttached(WebContentsView* parent_view) {
#if defined(USE_AURA)
+ if (!platform_view_->GetNativeView())
+ return;
// In aura, ScreenPositionClient doesn't work properly if we do
// not have the native view associated with this WebContentsViewGuest in the
// view hierarchy. We add this view as embedder's child here.
@@ -83,6 +85,8 @@ void WebContentsViewGuest::OnGuestAttached(WebContentsView* parent_view) {
void WebContentsViewGuest::OnGuestDetached(WebContentsView* old_parent_view) {
#if defined(USE_AURA)
+ if (!platform_view_->GetNativeView())
+ return;
old_parent_view->GetNativeView()->RemoveChild(
platform_view_->GetNativeView());
#endif // defined(USE_AURA)
@@ -133,7 +137,8 @@ void WebContentsViewGuest::CreateView(const gfx::Size& initial_size,
}
RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget(
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
+ RenderWidgetHost* render_widget_host,
+ RenderWidgetHost* embedder_render_widget_host) {
if (render_widget_host->GetView()) {
// During testing, the view will already be set up in most cases to the
// test view, so we don't want to clobber it with a real one. To verify that
@@ -145,11 +150,19 @@ RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget(
render_widget_host->GetView());
}
+ embedder_render_widget_host =
+ guest_->embedder_web_contents()->GetRenderViewHost()->GetWidget();
RenderWidgetHostViewBase* platform_widget =
- platform_view_->CreateViewForWidget(render_widget_host, true);
+ platform_view_->CreateViewForWidget(render_widget_host,
+ embedder_render_widget_host);
- return RenderWidgetHostViewGuest::Create(render_widget_host, guest_,
- platform_widget->GetWeakPtr());
+ RenderWidgetHostViewGuest* guest_view =
+ RenderWidgetHostViewGuest::Create(render_widget_host, guest_,
+ platform_widget->GetWeakPtr());
+ platform_widget->InitAsGuest(embedder_render_widget_host->GetView(),
+ guest_view);
+
+void BrowserPluginGuestDelegate::OnGuestDetached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ static_cast<WebContentsViewGuest*>(guest_view)->OnGuestAttached(parent_view);
+}
+
+void BrowserPluginGuestDelegate::CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host) {
+ static_cast<WebContentsViewGuest*>(guest_view)->CreateViewForWidget(
+ render_widget_host, true);
+}
+
} // namespace content
diff --git public/browser/browser_plugin_guest_delegate.h public/browser/browser_plugin_guest_delegate.h
index a32205c..1d93d7b 100644
--- public/browser/browser_plugin_guest_delegate.h
+++ public/browser/browser_plugin_guest_delegate.h
+ return guest_view;
}
RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForPopupWidget(
diff --git content/browser/web_contents/web_contents_view_guest.h content/browser/web_contents/web_contents_view_guest.h
index 0102d7e..b89d66c 100644
--- content/browser/web_contents/web_contents_view_guest.h
+++ content/browser/web_contents/web_contents_view_guest.h
@@ -58,7 +58,7 @@ class WebContentsViewGuest : public WebContentsView,
gfx::NativeView context) override;
RenderWidgetHostViewBase* CreateViewForWidget(
RenderWidgetHost* render_widget_host,
- bool is_guest_view_hack) override;
+ RenderWidgetHost* embedder_render_widget_host) override;
RenderWidgetHostViewBase* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
diff --git content/browser/web_contents/web_contents_view_mac.h content/browser/web_contents/web_contents_view_mac.h
index 3b34cbd..a22e22e 100644
--- content/browser/web_contents/web_contents_view_mac.h
+++ content/browser/web_contents/web_contents_view_mac.h
@@ -89,7 +89,7 @@ class WebContentsViewMac : public WebContentsView,
gfx::NativeView context) override;
RenderWidgetHostViewBase* CreateViewForWidget(
RenderWidgetHost* render_widget_host,
- bool is_guest_view_hack) override;
+ RenderWidgetHost* embedder_render_widget_host) override;
RenderWidgetHostViewBase* CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) override;
void SetPageTitle(const base::string16& title) override;
diff --git content/browser/web_contents/web_contents_view_mac.mm content/browser/web_contents/web_contents_view_mac.mm
index 1d01ac8..36f2dce 100644
--- content/browser/web_contents/web_contents_view_mac.mm
+++ content/browser/web_contents/web_contents_view_mac.mm
@@ -338,7 +338,8 @@ void WebContentsViewMac::CreateView(
}
RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget(
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
+ RenderWidgetHost* render_widget_host,
+ RenderWidgetHost* embedder_render_widget_host) {
if (render_widget_host->GetView()) {
// During testing, the view will already be set up in most cases to the
// test view, so we don't want to clobber it with a real one. To verify that
@@ -351,7 +352,7 @@ RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget(
}
RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(
- render_widget_host, is_guest_view_hack);
+ render_widget_host, !!embedder_render_widget_host);
if (delegate()) {
base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate> >
rw_delegate(
diff --git content/public/browser/browser_plugin_guest_delegate.h content/public/browser/browser_plugin_guest_delegate.h
index a32205c..49f3c35 100644
--- content/public/browser/browser_plugin_guest_delegate.h
+++ content/public/browser/browser_plugin_guest_delegate.h
@@ -19,6 +19,7 @@ namespace content {
class GuestHost;
class RenderWidgetHost;
@ -100,21 +247,91 @@ index a32205c..1d93d7b 100644
// Objects implement this interface to get notified about changes in the guest
// WebContents and to provide necessary functionality.
@@ -85,6 +86,17 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate {
@@ -85,6 +86,10 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate {
// content module.
virtual void SetGuestHost(GuestHost* guest_host) {}
+ // Called when a guest is attached or detached.
+ virtual void OnGuestAttached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view);
+ virtual void OnGuestDetached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view);
+
+ // Called to create the view for the widget.
+ virtual void CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host);
+ virtual void OnGuestAttached(content::WebContentsView* parent_view) {}
+ virtual void OnGuestDetached(content::WebContentsView* parent_view) {}
+
// Sets the position of the context menu for the guest contents. The value
// reported from the guest renderer should be ignored. The reported value
// from the guest renderer is incorrect in situations where BrowserPlugin is
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
index 6e59562..b517389 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
@@ -179,6 +179,8 @@ void MimeHandlerViewGuest::CreateWebContents(
WebContents::CreateParams params(browser_context(),
guest_site_instance.get());
params.guest_delegate = this;
+ if (delegate_)
+ delegate_->OverrideWebContentsCreateParams(&params);
callback.Run(WebContents::Create(params));
}
@@ -203,6 +205,18 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const {
return false;
}
+void MimeHandlerViewGuest::OnGuestAttached(
+ content::WebContentsView* parent_view) {
+ if (delegate_)
+ delegate_->OnGuestAttached(parent_view);
+}
+
+void MimeHandlerViewGuest::OnGuestDetached(
+ content::WebContentsView* parent_view) {
+ if (delegate_)
+ delegate_->OnGuestDetached(parent_view);
+}
+
WebContents* MimeHandlerViewGuest::OpenURLFromTab(
WebContents* source,
const content::OpenURLParams& params) {
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
index d237318..3701bd2 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
@@ -83,6 +83,10 @@ class MimeHandlerViewGuest :
bool ShouldHandleFindRequestsForEmbedder() const final;
bool ZoomPropagatesFromEmbedderToGuest() const final;
+ // content::BrowserPluginGuestDelegate implementation
+ void OnGuestAttached(content::WebContentsView* parent_view) override;
+ void OnGuestDetached(content::WebContentsView* parent_view) override;
+
// WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
index e065104d..ea3f547 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
@@ -6,9 +6,9 @@
#define EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_
#include "base/macros.h"
+#include "content/public/browser/web_contents.h"
namespace content {
-class WebContents;
struct ContextMenuParams;
} // namespace content
@@ -21,6 +21,14 @@ class MimeHandlerViewGuestDelegate {
public:
MimeHandlerViewGuestDelegate() {}
virtual ~MimeHandlerViewGuestDelegate() {}
+
+ // Provides an opportunity to supply a custom view implementation.
+ virtual void OverrideWebContentsCreateParams(
+ content::WebContents::CreateParams* params) {}
+
+ // Called when a guest is attached or detached.
+ virtual void OnGuestAttached(content::WebContentsView* parent_view) {}
+ virtual void OnGuestDetached(content::WebContentsView* parent_view) {}
// Handles context menu, or returns false if unhandled.
virtual bool HandleContextMenu(content::WebContents* web_contents,

View File

@ -1,132 +0,0 @@
diff --git mime_handler_view_guest.cc mime_handler_view_guest.cc
index 6e59562..69f9769 100644
--- mime_handler_view_guest.cc
+++ mime_handler_view_guest.cc
@@ -179,6 +179,8 @@ void MimeHandlerViewGuest::CreateWebContents(
WebContents::CreateParams params(browser_context(),
guest_site_instance.get());
params.guest_delegate = this;
+ if (delegate_)
+ delegate_->OverrideWebContentsCreateParams(&params);
callback.Run(WebContents::Create(params));
}
@@ -203,6 +205,30 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const {
return false;
}
+void MimeHandlerViewGuest::OnGuestAttached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ if (!delegate_ || !delegate_->OnGuestAttached(guest_view, parent_view))
+ BrowserPluginGuestDelegate::OnGuestAttached(guest_view, parent_view);
+}
+
+void MimeHandlerViewGuest::OnGuestDetached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ if (!delegate_ || !delegate_->OnGuestDetached(guest_view, parent_view))
+ BrowserPluginGuestDelegate::OnGuestDetached(guest_view, parent_view);
+}
+
+void MimeHandlerViewGuest::CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host) {
+ if (!delegate_ ||
+ !delegate_->CreateViewForWidget(guest_view, render_widget_host)) {
+ BrowserPluginGuestDelegate::CreateViewForWidget(guest_view,
+ render_widget_host);
+ }
+}
+
WebContents* MimeHandlerViewGuest::OpenURLFromTab(
WebContents* source,
const content::OpenURLParams& params) {
diff --git mime_handler_view_guest.h mime_handler_view_guest.h
index d237318..b9cd2ab 100644
--- mime_handler_view_guest.h
+++ mime_handler_view_guest.h
@@ -83,6 +83,15 @@ class MimeHandlerViewGuest :
bool ShouldHandleFindRequestsForEmbedder() const final;
bool ZoomPropagatesFromEmbedderToGuest() const final;
+ // content::BrowserPluginGuestDelegate implementation
+ void OnGuestAttached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) override;
+ void OnGuestDetached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) override;
+ void CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host) override;
+
// WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
diff --git mime_handler_view_guest_delegate.cc mime_handler_view_guest_delegate.cc
index 63b81b8..0f63f48 100644
--- mime_handler_view_guest_delegate.cc
+++ mime_handler_view_guest_delegate.cc
@@ -6,6 +6,24 @@
namespace extensions {
+bool MimeHandlerViewGuestDelegate::OnGuestAttached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ return false;
+}
+
+bool MimeHandlerViewGuestDelegate::OnGuestDetached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ return false;
+}
+
+bool MimeHandlerViewGuestDelegate::CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host) {
+ return false;
+}
+
bool MimeHandlerViewGuestDelegate::HandleContextMenu(
content::WebContents* web_contents,
const content::ContextMenuParams& params) {
diff --git mime_handler_view_guest_delegate.h mime_handler_view_guest_delegate.h
index e065104d..f68b66c 100644
--- mime_handler_view_guest_delegate.h
+++ mime_handler_view_guest_delegate.h
@@ -6,10 +6,11 @@
#define EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_
#include "base/macros.h"
+#include "content/public/browser/web_contents.h"
namespace content {
-class WebContents;
struct ContextMenuParams;
+class RenderWidgetHost;
} // namespace content
namespace extensions {
@@ -21,6 +22,21 @@ class MimeHandlerViewGuestDelegate {
public:
MimeHandlerViewGuestDelegate() {}
virtual ~MimeHandlerViewGuestDelegate() {}
+
+ // Provides an opportunity to supply a custom view implementation.
+ virtual void OverrideWebContentsCreateParams(
+ content::WebContents::CreateParams* params) {}
+
+ // Called when a guest is attached or detached.
+ virtual bool OnGuestAttached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view);
+ virtual bool OnGuestDetached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view);
+
+ // Called to create the view for the widget.
+ virtual bool CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host);
// Handles context menu, or returns false if unhandled.
virtual bool HandleContextMenu(content::WebContents* web_contents,

View File

@ -26,10 +26,18 @@ index 11482ff..57e8b58 100644
return renderer_frame_number_;
}
diff --git content/browser/renderer_host/render_widget_host_view_base.h content/browser/renderer_host/render_widget_host_view_base.h
index 08aad92..c18da2d 100644
index 08aad92..d6fa32c0 100644
--- content/browser/renderer_host/render_widget_host_view_base.h
+++ content/browser/renderer_host/render_widget_host_view_base.h
@@ -107,6 +107,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
@@ -67,6 +67,7 @@ class BrowserAccessibilityDelegate;
class BrowserAccessibilityManager;
class RenderWidgetHostImpl;
class RenderWidgetHostViewBaseObserver;
+class RenderWidgetHostViewGuest;
class SyntheticGestureTarget;
class TextInputManager;
class WebCursor;
@@ -107,6 +108,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
void EndFrameSubscription() override;
void FocusedNodeTouched(const gfx::Point& location_dips_screen,
bool editable) override;
@ -38,7 +46,20 @@ index 08aad92..c18da2d 100644
// This only needs to be overridden by RenderWidgetHostViewBase subclasses
// that handle content embedded within other RenderWidgetHostViews.
@@ -491,6 +493,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
@@ -330,6 +333,12 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// helps to position the full screen widget on the correct monitor.
virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0;
+ // Perform all the initialization steps necessary for this object to represent
+ // the platform widget owned by |guest_view| and embedded in
+ // |parent_host_view|.
+ virtual void InitAsGuest(RenderWidgetHostView* parent_host_view,
+ RenderWidgetHostViewGuest* guest_view) {}
+
// Sets the cursor to the one associated with the specified cursor_type
virtual void UpdateCursor(const WebCursor& cursor) = 0;
@@ -491,6 +500,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// destroyed before the RWHV is destroyed.
TextInputManager* text_input_manager_;

View File

@ -1,317 +0,0 @@
diff --git chrome/browser/extensions/api/tab_capture/offscreen_tab.cc chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
index 776dd0a..1a86478 100644
--- chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
+++ chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
@@ -225,7 +225,9 @@ bool OffscreenTab::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
DCHECK_EQ(offscreen_tab_web_contents_.get(), web_contents);
// Disallow creating separate WebContentses. The WebContents implementation
// uses this to spawn new windows/tabs, which is also not allowed for
diff --git chrome/browser/extensions/api/tab_capture/offscreen_tab.h chrome/browser/extensions/api/tab_capture/offscreen_tab.h
index 992160d..b5dcc72 100644
--- chrome/browser/extensions/api/tab_capture/offscreen_tab.h
+++ chrome/browser/extensions/api/tab_capture/offscreen_tab.h
@@ -150,7 +150,9 @@ class OffscreenTab : protected content::WebContentsDelegate,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) final;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) final;
bool EmbedsFullscreenWidget() const final;
void EnterFullscreenModeForTab(content::WebContents* contents,
const GURL& origin) final;
diff --git chrome/browser/prerender/prerender_contents.cc chrome/browser/prerender/prerender_contents.cc
index aea147d..cac0c15 100644
--- chrome/browser/prerender/prerender_contents.cc
+++ chrome/browser/prerender/prerender_contents.cc
@@ -142,7 +142,9 @@ class PrerenderContents::WebContentsDelegateImpl
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace) override {
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override {
// Since we don't want to permit child windows that would have a
// window.opener property, terminate prerendering.
prerender_contents_->Destroy(FINAL_STATUS_CREATE_NEW_WINDOW);
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
index ffcba10..514c431 100644
--- chrome/browser/ui/browser.cc
+++ chrome/browser/ui/browser.cc
@@ -1600,7 +1600,9 @@ bool Browser::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
// If a BackgroundContents is created, suppress the normal WebContents.
return !MaybeCreateBackgroundContents(
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
index 0860714..a011ad7 100644
--- chrome/browser/ui/browser.h
+++ chrome/browser/ui/browser.h
@@ -626,7 +626,9 @@ class Browser : public TabStripModelObserver,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
diff --git components/offline_pages/content/background_loader/background_loader_contents.cc components/offline_pages/content/background_loader/background_loader_contents.cc
index 5998fc7..a98eea6 100644
--- components/offline_pages/content/background_loader/background_loader_contents.cc
+++ components/offline_pages/content/background_loader/background_loader_contents.cc
@@ -71,7 +71,9 @@ bool BackgroundLoaderContents::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
// Background pages should not create other webcontents/tabs.
return false;
}
diff --git components/offline_pages/content/background_loader/background_loader_contents.h components/offline_pages/content/background_loader/background_loader_contents.h
index 43b6cea..29b6ae2 100644
--- components/offline_pages/content/background_loader/background_loader_contents.h
+++ components/offline_pages/content/background_loader/background_loader_contents.h
@@ -54,7 +54,9 @@ class BackgroundLoaderContents : public content::WebContentsDelegate {
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
diff --git content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc
index 35b6f47..d444e66 100644
--- content/browser/web_contents/web_contents_impl.cc
+++ content/browser/web_contents/web_contents_impl.cc
@@ -1560,6 +1560,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::string unique_name;
frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name);
+ if (params.view && params.delegate_view) {
+ view_.reset(params.view);
+ render_view_host_delegate_view_ = params.delegate_view;
+ }
+
+ if (!view_) {
WebContentsViewDelegate* delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
@@ -1576,6 +1582,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::move(view_),
&render_view_host_delegate_view_));
}
+ }
CHECK(render_view_host_delegate_view_);
CHECK(view_.get());
@@ -2040,12 +2047,15 @@ void WebContentsImpl::CreateNewWindow(
static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace);
CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context));
+ content::WebContentsView* view = NULL;
+ content::RenderViewHostDelegateView* delegate_view = NULL;
+
if (delegate_ &&
!delegate_->ShouldCreateWebContents(
this, source_site_instance, render_view_route_id, main_frame_route_id,
main_frame_widget_route_id, params.window_container_type,
params.opener_url, params.frame_name, params.target_url, partition_id,
- session_storage_namespace)) {
+ session_storage_namespace, &view, &delegate_view)) {
// Note: even though we're not creating a WebContents here, it could have
// been created by the embedder so ensure that the RenderFrameHost is
// properly initialized.
@@ -2070,6 +2080,8 @@ void WebContentsImpl::CreateNewWindow(
create_params.opener_render_process_id = render_process_id;
create_params.opener_render_frame_id = params.opener_render_frame_id;
create_params.opener_suppressed = params.opener_suppressed;
+ create_params.view = view;
+ create_params.delegate_view = delegate_view;
if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB)
create_params.initially_hidden = true;
create_params.renderer_initiated_creation =
diff --git content/public/browser/web_contents.cc content/public/browser/web_contents.cc
index fa0afb5..d677b31 100644
--- content/public/browser/web_contents.cc
+++ content/public/browser/web_contents.cc
@@ -29,7 +29,9 @@ WebContents::CreateParams::CreateParams(BrowserContext* context,
guest_delegate(nullptr),
context(nullptr),
renderer_initiated_creation(false),
- initialize_renderer(false) {
+ initialize_renderer(false),
+ view(nullptr),
+ delegate_view(nullptr) {
}
WebContents::CreateParams::CreateParams(const CreateParams& other) = default;
diff --git content/public/browser/web_contents.h content/public/browser/web_contents.h
index a5e2535..704c137 100644
--- content/public/browser/web_contents.h
+++ content/public/browser/web_contents.h
@@ -59,9 +59,11 @@ class PageState;
class RenderFrameHost;
class RenderProcessHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHost;
class RenderWidgetHostView;
class WebContentsDelegate;
+class WebContentsView;
struct CustomContextMenuContext;
struct DropData;
struct Manifest;
@@ -162,6 +164,10 @@ class WebContents : public PageNavigator,
// Note that the pre-created renderer process may not be used if the first
// navigation requires a dedicated or privileged process, such as a WebUI.
bool initialize_renderer;
+
+ // Optionally specify the view and delegate view.
+ content::WebContentsView* view;
+ content::RenderViewHostDelegateView* delegate_view;
};
// Creates a new WebContents.
diff --git content/public/browser/web_contents_delegate.cc content/public/browser/web_contents_delegate.cc
index 01c9c08..704459d 100644
--- content/public/browser/web_contents_delegate.cc
+++ content/public/browser/web_contents_delegate.cc
@@ -146,7 +146,9 @@ bool WebContentsDelegate::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace) {
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
return true;
}
diff --git content/public/browser/web_contents_delegate.h content/public/browser/web_contents_delegate.h
index 6456878..21afa0b 100644
--- content/public/browser/web_contents_delegate.h
+++ content/public/browser/web_contents_delegate.h
@@ -42,11 +42,13 @@ class ColorChooser;
class JavaScriptDialogManager;
class PageState;
class RenderFrameHost;
+class RenderViewHostDelegateView;
class RenderWidgetHost;
class SessionStorageNamespace;
class SiteInstance;
class WebContents;
class WebContentsImpl;
+class WebContentsView;
struct ColorSuggestion;
struct ContextMenuParams;
struct DropData;
@@ -323,7 +325,9 @@ class CONTENT_EXPORT WebContentsDelegate {
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- SessionStorageNamespace* session_storage_namespace);
+ SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view);
// Notifies the delegate about the creation of a new WebContents. This
// typically happens when popups are created.
diff --git extensions/browser/guest_view/extension_options/extension_options_guest.cc extensions/browser/guest_view/extension_options/extension_options_guest.cc
index 12dd8f3..c358a52 100644
--- extensions/browser/guest_view/extension_options/extension_options_guest.cc
+++ extensions/browser/guest_view/extension_options/extension_options_guest.cc
@@ -203,7 +203,9 @@ bool ExtensionOptionsGuest::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
// This method handles opening links from within the guest. Since this guest
// view is used for displaying embedded extension options, we want any
// external links to be opened in a new tab, not in a new guest view.
diff --git extensions/browser/guest_view/extension_options/extension_options_guest.h extensions/browser/guest_view/extension_options/extension_options_guest.h
index 5b0505c..63bf100 100644
--- extensions/browser/guest_view/extension_options/extension_options_guest.h
+++ extensions/browser/guest_view/extension_options/extension_options_guest.h
@@ -54,7 +54,9 @@ class ExtensionOptionsGuest
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) final;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) final;
// content::WebContentsObserver implementation.
void DidNavigateMainFrame(const content::LoadCommittedDetails& details,
diff --git ui/keyboard/content/keyboard_ui_content.cc ui/keyboard/content/keyboard_ui_content.cc
index 1dba63e..0268ea3 100644
--- ui/keyboard/content/keyboard_ui_content.cc
+++ ui/keyboard/content/keyboard_ui_content.cc
@@ -67,7 +67,9 @@ class KeyboardContentsDelegate : public content::WebContentsDelegate,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override {
return false;
}
diff --git ui/views/controls/webview/web_dialog_view.cc ui/views/controls/webview/web_dialog_view.cc
index cd4f8ec..9b9c9a3 100644
--- ui/views/controls/webview/web_dialog_view.cc
+++ ui/views/controls/webview/web_dialog_view.cc
@@ -343,7 +343,9 @@ bool WebDialogView::ShouldCreateWebContents(
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) {
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {
if (delegate_)
return delegate_->HandleShouldCreateWebContents();
return true;
diff --git ui/views/controls/webview/web_dialog_view.h ui/views/controls/webview/web_dialog_view.h
index c5d6791..bc1eb5d 100644
--- ui/views/controls/webview/web_dialog_view.h
+++ ui/views/controls/webview/web_dialog_view.h
@@ -125,7 +125,9 @@ class WEBVIEW_EXPORT WebDialogView : public views::ClientView,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) override;
private:
FRIEND_TEST_ALL_PREFIXES(WebDialogBrowserTest, WebContentRendered);

View File

@ -0,0 +1,129 @@
diff --git content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc
index 35b6f47..932fe44 100644
--- content/browser/web_contents/web_contents_impl.cc
+++ content/browser/web_contents/web_contents_impl.cc
@@ -1560,6 +1560,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
std::string unique_name;
frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name);
+ if (params.view && params.delegate_view) {
+ view_.reset(params.view);
+ render_view_host_delegate_view_ = params.delegate_view;
+ }
+
+ if (!view_) {
WebContentsViewDelegate* delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
@@ -1570,6 +1576,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
view_.reset(CreateWebContentsView(this, delegate,
&render_view_host_delegate_view_));
}
+ }
if (browser_plugin_guest_ && !GuestMode::IsCrossProcessFrameGuest(this)) {
view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(),
@@ -2075,6 +2082,12 @@ void WebContentsImpl::CreateNewWindow(
create_params.renderer_initiated_creation =
main_frame_route_id != MSG_ROUTING_NONE;
+ if (delegate_) {
+ delegate_->GetCustomWebContentsView(this, params.target_url,
+ &create_params.view,
+ &create_params.delegate_view);
+ }
+
WebContentsImpl* new_contents = NULL;
if (!is_guest) {
create_params.context = view_->GetNativeView();
@@ -2104,7 +2117,7 @@ void WebContentsImpl::CreateNewWindow(
// TODO(brettw): It seems bogus that we have to call this function on the
// newly created object and give it one of its own member variables.
new_view->CreateViewForWidget(
- new_contents->GetRenderViewHost()->GetWidget(), false);
+ new_contents->GetRenderViewHost()->GetWidget(), nullptr);
}
// Save the created window associated with the route so we can show it
// later.
@@ -4989,7 +5002,7 @@ NavigationEntry*
void WebContentsImpl::CreateRenderWidgetHostViewForRenderManager(
RenderViewHost* render_view_host) {
RenderWidgetHostViewBase* rwh_view =
- view_->CreateViewForWidget(render_view_host->GetWidget(), false);
+ view_->CreateViewForWidget(render_view_host->GetWidget(), nullptr);
// Now that the RenderView has been created, we need to tell it its size.
if (rwh_view)
diff --git content/public/browser/web_contents.cc content/public/browser/web_contents.cc
index fa0afb5..d677b31 100644
--- content/public/browser/web_contents.cc
+++ content/public/browser/web_contents.cc
@@ -29,7 +29,9 @@ WebContents::CreateParams::CreateParams(BrowserContext* context,
guest_delegate(nullptr),
context(nullptr),
renderer_initiated_creation(false),
- initialize_renderer(false) {
+ initialize_renderer(false),
+ view(nullptr),
+ delegate_view(nullptr) {
}
WebContents::CreateParams::CreateParams(const CreateParams& other) = default;
diff --git content/public/browser/web_contents.h content/public/browser/web_contents.h
index a5e2535..704c137 100644
--- content/public/browser/web_contents.h
+++ content/public/browser/web_contents.h
@@ -59,9 +59,11 @@ class PageState;
class RenderFrameHost;
class RenderProcessHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHost;
class RenderWidgetHostView;
class WebContentsDelegate;
+class WebContentsView;
struct CustomContextMenuContext;
struct DropData;
struct Manifest;
@@ -162,6 +164,10 @@ class WebContents : public PageNavigator,
// Note that the pre-created renderer process may not be used if the first
// navigation requires a dedicated or privileged process, such as a WebUI.
bool initialize_renderer;
+
+ // Optionally specify the view and delegate view.
+ content::WebContentsView* view;
+ content::RenderViewHostDelegateView* delegate_view;
};
// Creates a new WebContents.
diff --git content/public/browser/web_contents_delegate.h content/public/browser/web_contents_delegate.h
index 6456878..339f9b8 100644
--- content/public/browser/web_contents_delegate.h
+++ content/public/browser/web_contents_delegate.h
@@ -42,11 +42,13 @@ class ColorChooser;
class JavaScriptDialogManager;
class PageState;
class RenderFrameHost;
+class RenderViewHostDelegateView;
class RenderWidgetHost;
class SessionStorageNamespace;
class SiteInstance;
class WebContents;
class WebContentsImpl;
+class WebContentsView;
struct ColorSuggestion;
struct ContextMenuParams;
struct DropData;
@@ -325,6 +327,12 @@ class CONTENT_EXPORT WebContentsDelegate {
const std::string& partition_id,
SessionStorageNamespace* session_storage_namespace);
+ virtual void GetCustomWebContentsView(
+ WebContents* web_contents,
+ const GURL& target_url,
+ content::WebContentsView** view,
+ content::RenderViewHostDelegateView** delegate_view) {}
+
// Notifies the delegate about the creation of a new WebContents. This
// typically happens when popups are created.
virtual void WebContentsCreated(WebContents* source_contents,