cef/patch/patches/web_contents_1257.patch

284 lines
14 KiB
Diff

diff --git chrome/browser/extensions/api/tab_capture/offscreen_tab.cc chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
index f50fdf9..9e59835 100644
--- chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
+++ chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
@@ -214,7 +214,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(), 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 e639319..5f75a9a 100644
--- chrome/browser/extensions/api/tab_capture/offscreen_tab.h
+++ chrome/browser/extensions/api/tab_capture/offscreen_tab.h
@@ -148,7 +148,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 4ded1cb..ce3306b 100644
--- chrome/browser/prerender/prerender_contents.cc
+++ chrome/browser/prerender/prerender_contents.cc
@@ -141,7 +141,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 869fbec..7ca4f52 100644
--- chrome/browser/ui/browser.cc
+++ chrome/browser/ui/browser.cc
@@ -1588,7 +1588,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 5410f5a..a6aaef1 100644
--- chrome/browser/ui/browser.h
+++ chrome/browser/ui/browser.h
@@ -619,7 +619,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 content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc
index e199004..4630d34 100644
--- content/browser/web_contents/web_contents_impl.cc
+++ content/browser/web_contents/web_contents_impl.cc
@@ -1572,6 +1572,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);
@@ -1602,6 +1608,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());
@@ -2055,11 +2062,14 @@ 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, route_id, main_frame_route_id, main_frame_widget_route_id,
params.window_container_type, params.frame_name, params.target_url,
- partition_id, session_storage_namespace)) {
+ partition_id, session_storage_namespace, &view, &delegate_view)) {
if (route_id != MSG_ROUTING_NONE &&
!RenderViewHost::FromID(render_process_id, route_id)) {
// If the embedder didn't create a WebContents for this route, we need to
@@ -2083,6 +2093,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 1eb4d7c..1564230 100644
--- content/public/browser/web_contents.h
+++ content/public/browser/web_contents.h
@@ -59,8 +59,10 @@ class PageState;
class RenderFrameHost;
class RenderProcessHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHostView;
class WebContentsDelegate;
+class WebContentsView;
struct CustomContextMenuContext;
struct DropData;
struct Manifest;
@@ -161,6 +163,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 d107135..2d290e1 100644
--- content/public/browser/web_contents_delegate.cc
+++ content/public/browser/web_contents_delegate.cc
@@ -148,7 +148,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 62ef1de..824b0e1 100644
--- content/public/browser/web_contents_delegate.h
+++ content/public/browser/web_contents_delegate.h
@@ -45,9 +45,11 @@ class JavaScriptDialogManager;
class PageState;
class RenderFrameHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class SessionStorageNamespace;
class WebContents;
class WebContentsImpl;
+class WebContentsView;
struct ColorSuggestion;
struct ContextMenuParams;
struct DropData;
@@ -314,7 +316,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 c02aace..67b9bd8 100644
--- extensions/browser/guest_view/extension_options/extension_options_guest.cc
+++ extensions/browser/guest_view/extension_options/extension_options_guest.cc
@@ -201,7 +201,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 e0309f7..f6a3878 100644
--- extensions/browser/guest_view/extension_options/extension_options_guest.h
+++ extensions/browser/guest_view/extension_options/extension_options_guest.h
@@ -56,7 +56,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 d08fd23..3ec515c 100644
--- ui/keyboard/content/keyboard_ui_content.cc
+++ ui/keyboard/content/keyboard_ui_content.cc
@@ -64,7 +64,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 d8afe6e..59259b7 100644
--- ui/views/controls/webview/web_dialog_view.cc
+++ ui/views/controls/webview/web_dialog_view.cc
@@ -341,7 +341,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 65be6d54..7802d6d 100644
--- ui/views/controls/webview/web_dialog_view.h
+++ ui/views/controls/webview/web_dialog_view.h
@@ -123,7 +123,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);