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-29 21:45:08 +00:00
|
|
|
index 04fb97db324c9051ea794e4445e543d7926af9ee..849d51d9158b6f091b798cee5bda66a8327d2b28 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-29 21:45:08 +00:00
|
|
|
@@ -4483,6 +4483,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-29 12:01:37 +00:00
|
|
|
index abd2be4bc8e81a28209aa551f4435b9e8d37a249..f33766c98e1a28c89fc41f9e5cfd098ca6bc6150 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-29 12:01:37 +00:00
|
|
|
index bcdc73fdf89d46e267f0c9568e46172ec89f9f23..930e043a0fdf40ef0e48a19597da567c8603878c 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-29 21:45:08 +00:00
|
|
|
index d6948f86672e8567b68d0222ca5d2278cab63e55..1fcc4c057ac5686f47eba791d1f0cf2c8c639574 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-29 21:45:08 +00:00
|
|
|
@@ -146,6 +146,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-29 21:45:08 +00:00
|
|
|
@@ -831,6 +832,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-29 12:01:37 +00:00
|
|
|
index 8b6362f566c215552e5eaba06cbbac31c6ab792d..272f0ed4ffada8191e725f31c8533bcb35622e46 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-29 12:01:37 +00:00
|
|
|
@@ -1276,6 +1277,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-29 12:01:37 +00:00
|
|
|
index 4497b2d0c264f3e8ebc05230bdc117b6abccc23b..2eaa105035208d92cdcfe0e4de2a62ebbce1414b 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-29 12:01:37 +00:00
|
|
|
@@ -326,6 +326,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;
|