2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
|
|
Date: Thu, 20 Sep 2018 17:45:32 -0700
|
|
|
|
Subject: can_create_window.patch
|
|
|
|
|
2019-12-13 17:18:45 +00:00
|
|
|
This adds a hook to the window creation flow so that Electron can intercede and
|
|
|
|
potentially prevent a window from being created.
|
|
|
|
|
|
|
|
TODO(loc): this patch is currently broken.
|
2018-09-21 00:30:26 +00:00
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
index 612d83aaa8ec820e5640effab5b96aa37b3205ea..83dbc5037810469e76895e01cc1c3ff0399b0420 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/frame_host/render_frame_host_impl.cc
|
|
|
|
+++ b/content/browser/frame_host/render_frame_host_impl.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -4411,6 +4411,7 @@ void RenderFrameHostImpl::CreateNewWindow(
|
2019-01-16 18:07:52 +00:00
|
|
|
last_committed_origin_, params->window_container_type,
|
2019-01-08 23:59:47 +00:00
|
|
|
params->target_url, params->referrer.To<Referrer>(),
|
|
|
|
params->frame_name, params->disposition, *params->features,
|
2019-01-24 14:52:14 +00:00
|
|
|
+ params->additional_features, params->body,
|
2018-09-21 00:30:26 +00:00
|
|
|
effective_transient_activation_state, params->opener_suppressed,
|
|
|
|
&no_javascript_access);
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
diff --git a/content/common/frame.mojom b/content/common/frame.mojom
|
2020-01-21 17:39:37 +00:00
|
|
|
index dce2284977bf3d8fba00e6488d51fd6bfa1cb3b0..afeebca6b6fd01294acbf62aa6a7eaf43151b9e6 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/common/frame.mojom
|
|
|
|
+++ b/content/common/frame.mojom
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -305,6 +305,10 @@ struct CreateNewWindowParams {
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
// The window features to use for the new window.
|
|
|
|
blink.mojom.WindowFeatures features;
|
|
|
|
+
|
|
|
|
+ // Extra fields added by Electron.
|
|
|
|
+ array<string> additional_features;
|
2019-01-24 14:52:14 +00:00
|
|
|
+ network.mojom.URLRequestBody? body;
|
2018-09-14 05:02:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Operation result when the renderer asks the browser to create a new window.
|
|
|
|
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
index a6042e5b21c77b27a3df77db3da321943f4c190d..38409b9d1ce06c2a73ce2feb98a6be35325ca472 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/public/browser/content_browser_client.cc
|
|
|
|
+++ b/content/public/browser/content_browser_client.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -505,6 +505,8 @@ bool ContentBrowserClient::CanCreateWindow(
|
2018-09-14 05:02:16 +00:00
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const blink::mojom::WindowFeatures& features,
|
|
|
|
+ const std::vector<std::string>& additional_features,
|
|
|
|
+ const scoped_refptr<network::ResourceRequestBody>& body,
|
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
|
|
|
bool* no_javascript_access) {
|
|
|
|
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
2020-01-21 17:39:37 +00:00
|
|
|
index 8256cd888b4c2af893fb98c3f5c77641eaa6c70b..af7c11bfbb26894ba4eb97b3fcbb026af288c084 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/public/browser/content_browser_client.h
|
|
|
|
+++ b/content/public/browser/content_browser_client.h
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -145,6 +145,7 @@ class NetworkService;
|
2019-10-28 22:12:35 +00:00
|
|
|
class TrustedURLLoaderHeaderClient;
|
|
|
|
} // namespace mojom
|
|
|
|
struct ResourceRequest;
|
2018-09-14 05:02:16 +00:00
|
|
|
+class ResourceRequestBody;
|
2019-10-28 22:12:35 +00:00
|
|
|
} // namespace network
|
|
|
|
|
|
|
|
namespace rappor {
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -830,6 +831,8 @@ class CONTENT_EXPORT ContentBrowserClient {
|
2018-09-14 05:02:16 +00:00
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const blink::mojom::WindowFeatures& features,
|
|
|
|
+ const std::vector<std::string>& additional_features,
|
|
|
|
+ const scoped_refptr<network::ResourceRequestBody>& body,
|
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
|
|
|
bool* no_javascript_access);
|
|
|
|
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
index 596e71dee6b6591f96d1e772e167577c24aa87f8..6820d5aabc8dfcb01e8a10b7b3fe94a35b3468a6 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/renderer/render_view_impl.cc
|
|
|
|
+++ b/content/renderer/render_view_impl.cc
|
2020-01-17 18:41:52 +00:00
|
|
|
@@ -69,6 +69,7 @@
|
2018-09-14 18:03:43 +00:00
|
|
|
#include "content/renderer/ime_event_guard.h"
|
2018-09-14 05:02:16 +00:00
|
|
|
#include "content/renderer/internal_document_state_data.h"
|
|
|
|
#include "content/renderer/loader/request_extra_data.h"
|
|
|
|
+#include "content/renderer/loader/web_url_request_util.h"
|
2018-09-21 00:30:26 +00:00
|
|
|
#include "content/renderer/media/audio/audio_device_factory.h"
|
2019-10-28 22:12:35 +00:00
|
|
|
#include "content/renderer/render_frame_impl.h"
|
2019-12-11 00:22:35 +00:00
|
|
|
#include "content/renderer/render_frame_proxy.h"
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -1278,6 +1279,8 @@ WebView* RenderViewImpl::CreateView(
|
2018-09-14 05:02:16 +00:00
|
|
|
}
|
|
|
|
params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features);
|
|
|
|
|
2019-01-24 14:52:14 +00:00
|
|
|
+ params->body = GetRequestBodyForWebURLRequest(request);
|
2018-09-14 05:02:16 +00:00
|
|
|
+
|
|
|
|
// We preserve this information before sending the message since |params| is
|
|
|
|
// moved on send.
|
|
|
|
bool is_background_tab =
|
2019-01-16 18:07:52 +00:00
|
|
|
diff --git a/content/shell/browser/web_test/web_test_content_browser_client.cc b/content/shell/browser/web_test/web_test_content_browser_client.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
index 62ae14ae5562cb6c94d106b92f6b422b02d63b3c..fed91002d1998ec20449d07c2ca98f75fe190dda 100644
|
2019-01-16 18:07:52 +00:00
|
|
|
--- a/content/shell/browser/web_test/web_test_content_browser_client.cc
|
|
|
|
+++ b/content/shell/browser/web_test/web_test_content_browser_client.cc
|
2020-01-21 17:39:37 +00:00
|
|
|
@@ -322,6 +322,8 @@ bool WebTestContentBrowserClient::CanCreateWindow(
|
2018-09-14 05:02:16 +00:00
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const blink::mojom::WindowFeatures& features,
|
|
|
|
+ const std::vector<std::string>& additional_features,
|
|
|
|
+ const scoped_refptr<network::ResourceRequestBody>& body,
|
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
|
|
|
bool* no_javascript_access) {
|
2019-01-16 18:07:52 +00:00
|
|
|
diff --git a/content/shell/browser/web_test/web_test_content_browser_client.h b/content/shell/browser/web_test/web_test_content_browser_client.h
|
2020-01-17 18:41:52 +00:00
|
|
|
index 5f985e2f11ebef42ed676260297e5e699096ba4a..2f3e68199f50b0e85dbb0d5cb95388279a194028 100644
|
2019-01-16 18:07:52 +00:00
|
|
|
--- a/content/shell/browser/web_test/web_test_content_browser_client.h
|
|
|
|
+++ b/content/shell/browser/web_test/web_test_content_browser_client.h
|
2020-01-17 18:41:52 +00:00
|
|
|
@@ -66,6 +66,8 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
|
2018-09-14 05:02:16 +00:00
|
|
|
const std::string& frame_name,
|
|
|
|
WindowOpenDisposition disposition,
|
|
|
|
const blink::mojom::WindowFeatures& features,
|
|
|
|
+ const std::vector<std::string>& additional_features,
|
|
|
|
+ const scoped_refptr<network::ResourceRequestBody>& body,
|
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
|
|
|
bool* no_javascript_access) override;
|