electron/patches/chromium/can_create_window.patch
Electron Bot 2b53788c35
chore: bump chromium to 4b6692e4cc2839729bb7ac009586a (master) (#21864)
* chore: bump chromium in DEPS to a1ea0d7aedd6b5fe58fbabfa3b05aa8ee41304ff

* update patches

* update extensions code

* Remove WebPoint

https://chromium-review.googlesource.com/c/chromium/src/+/2007474

* fix build

* chore: bump chromium in DEPS to 9351e26c2a3714f8bbb10789c71bb51b0b494c75

* update patches

* Remove error description from the DidFailLoadWithError message

https://chromium-review.googlesource.com/c/chromium/src/+/2011280

* Make SimpleNetworkHintsHandlerImpl use the right NetworkIsolationKey

https://chromium-review.googlesource.com/c/chromium/src/+/1994430

* Rename libgtkui to gtk

https://chromium-review.googlesource.com/c/chromium/src/+/2011683

* [metrics] Remove histogram Startup.WarmStartTimeFromRemoteProcessStart*.

https://chromium-review.googlesource.com/c/chromium/src/+/2003211

* fix requestSingleInstanceLock test

* chore: bump chromium in DEPS to a813567a4f17ea08292c2b26fa10d0ffd47010d9

* chore: bump chromium in DEPS to f0aca2de536ceecd6eb66e928051d11e6d11991f

* chore: bump chromium in DEPS to 865556af6d0c9d990f5b1816cb792f7c3859667b

* chore: bump chromium in DEPS to 98538fdd28c4b6692e4cc2839729bb7ac009586a

* update patches

* fix broken tests

* Update node tests for v8 changes

* Update node patches for test failures

* Update for number of tests

Co-authored-by: Jeremy Apthorp <nornagon@nornagon.net>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
2020-01-29 07:01:37 -05:00

118 lines
6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 20 Sep 2018 17:45:32 -0700
Subject: can_create_window.patch
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.
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 59107c7284d76d6d448caed9b5b23a9eb43a18a7..be4896118a93addcc0af5ee4eb07e27447f50cb6 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -4462,6 +4462,7 @@ void RenderFrameHostImpl::CreateNewWindow(
last_committed_origin_, params->window_container_type,
params->target_url, params->referrer.To<Referrer>(),
params->frame_name, params->disposition, *params->features,
+ params->additional_features, params->body,
effective_transient_activation_state, params->opener_suppressed,
&no_javascript_access);
diff --git a/content/common/frame.mojom b/content/common/frame.mojom
index abd2be4bc8e81a28209aa551f4435b9e8d37a249..f33766c98e1a28c89fc41f9e5cfd098ca6bc6150 100644
--- a/content/common/frame.mojom
+++ b/content/common/frame.mojom
@@ -305,6 +305,10 @@ struct CreateNewWindowParams {
// The window features to use for the new window.
blink.mojom.WindowFeatures features;
+
+ // Extra fields added by Electron.
+ array<string> additional_features;
+ network.mojom.URLRequestBody? body;
};
// 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
index bcdc73fdf89d46e267f0c9568e46172ec89f9f23..930e043a0fdf40ef0e48a19597da567c8603878c 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -505,6 +505,8 @@ bool ContentBrowserClient::CanCreateWindow(
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
index 5807d1d7d6021e045b2b3c6d4e2e4106e118ab3b..7abfa455bce8b8a4d7ba9d3e3c5aab4477dceaa2 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -145,6 +145,7 @@ class NetworkService;
class TrustedURLLoaderHeaderClient;
} // namespace mojom
struct ResourceRequest;
+class ResourceRequestBody;
} // namespace network
namespace rappor {
@@ -830,6 +831,8 @@ class CONTENT_EXPORT ContentBrowserClient {
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
index 8b6362f566c215552e5eaba06cbbac31c6ab792d..272f0ed4ffada8191e725f31c8533bcb35622e46 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -69,6 +69,7 @@
#include "content/renderer/ime_event_guard.h"
#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"
#include "content/renderer/media/audio/audio_device_factory.h"
#include "content/renderer/render_frame_impl.h"
#include "content/renderer/render_frame_proxy.h"
@@ -1276,6 +1277,8 @@ WebView* RenderViewImpl::CreateView(
}
params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features);
+ params->body = GetRequestBodyForWebURLRequest(request);
+
// We preserve this information before sending the message since |params| is
// moved on send.
bool is_background_tab =
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
index 4497b2d0c264f3e8ebc05230bdc117b6abccc23b..2eaa105035208d92cdcfe0e4de2a62ebbce1414b 100644
--- a/content/shell/browser/web_test/web_test_content_browser_client.cc
+++ b/content/shell/browser/web_test/web_test_content_browser_client.cc
@@ -326,6 +326,8 @@ bool WebTestContentBrowserClient::CanCreateWindow(
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/shell/browser/web_test/web_test_content_browser_client.h b/content/shell/browser/web_test/web_test_content_browser_client.h
index 5f985e2f11ebef42ed676260297e5e699096ba4a..2f3e68199f50b0e85dbb0d5cb95388279a194028 100644
--- a/content/shell/browser/web_test/web_test_content_browser_client.h
+++ b/content/shell/browser/web_test/web_test_content_browser_client.h
@@ -66,6 +66,8 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
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;