236 строки
9.2 KiB
Diff
236 строки
9.2 KiB
Diff
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
|
|
index 1bf37e107a90..82ab04e1019d 100644
|
|
--- a/content/browser/frame_host/render_frame_host_impl.cc
|
|
+++ b/content/browser/frame_host/render_frame_host_impl.cc
|
|
@@ -2716,6 +2719,48 @@ void RenderFrameHostImpl::CreateNewWindow(
|
|
"frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
|
|
params->target_url.possibly_invalid_spec());
|
|
|
|
+ scoped_refptr<ResourceRequestBody> body;
|
|
+ if (params->body->has_object) {
|
|
+ body = new ResourceRequestBody;
|
|
+ std::vector<storage::DataElement> elements;
|
|
+ for (const auto& iter : params->body->elements) {
|
|
+ storage::DataElement element;
|
|
+ switch (iter->type) {
|
|
+ case storage::DataElement::TYPE_BYTES: {
|
|
+ element.SetToBytes(iter->bytes.data(), iter->bytes.length());
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_BYTES_DESCRIPTION: {
|
|
+ element.SetToBytesDescription(iter->length);
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_FILE: {
|
|
+ element.SetToFilePathRange(iter->path, iter->offset, iter->length,
|
|
+ iter->expected_modification_time);
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_FILE_FILESYSTEM: {
|
|
+ element.SetToFileSystemUrlRange(iter->filesystem_url,
|
|
+ iter->offset, iter->length,
|
|
+ iter->expected_modification_time);
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_BLOB: {
|
|
+ element.SetToBlobRange(iter->blob_uuid, iter->offset, iter->length);
|
|
+ break;
|
|
+ }
|
|
+ default: {
|
|
+ NOTREACHED();
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ elements.push_back(std::move(element));
|
|
+ }
|
|
+ body->swap_elements(&elements);
|
|
+ body->set_identifier(params->body->identifier);
|
|
+ body->set_contains_sensitive_info(params->body->contains_sensitive_info);
|
|
+ }
|
|
+
|
|
bool no_javascript_access = false;
|
|
|
|
// Filter out URLs that this process cannot request.
|
|
@@ -2729,8 +2774,9 @@ void RenderFrameHostImpl::CreateNewWindow(
|
|
frame_tree_node_->frame_tree()->GetMainFrame()->last_committed_url(),
|
|
last_committed_origin_.GetURL(), params->window_container_type,
|
|
params->target_url, params->referrer, params->frame_name,
|
|
- params->disposition, *params->features, params->user_gesture,
|
|
- params->opener_suppressed, &no_javascript_access);
|
|
+ params->disposition, *params->features, params->additional_features,
|
|
+ body, params->user_gesture, params->opener_suppressed,
|
|
+ &no_javascript_access);
|
|
|
|
mojom::CreateNewWindowReplyPtr reply = mojom::CreateNewWindowReply::New();
|
|
if (!can_create_window) {
|
|
diff --git a/content/common/frame.mojom b/content/common/frame.mojom
|
|
index 613037782fd5..e2ec468a8e36 100644
|
|
--- a/content/common/frame.mojom
|
|
+++ b/content/common/frame.mojom
|
|
@@ -5,6 +5,8 @@
|
|
module content.mojom;
|
|
|
|
import "content/public/common/window_container_type.mojom";
|
|
+import "mojo/common/file_path.mojom";
|
|
+import "mojo/common/time.mojom";
|
|
import "services/service_manager/public/interfaces/interface_provider.mojom";
|
|
import "third_party/WebKit/public/platform/referrer.mojom";
|
|
import "third_party/WebKit/public/web/window_features.mojom";
|
|
@@ -41,6 +43,24 @@ interface FrameFactory {
|
|
CreateFrame(int32 frame_routing_id, Frame& frame, FrameHostInterfaceBroker host);
|
|
};
|
|
|
|
+struct DataElement {
|
|
+ int32 type;
|
|
+ int64 length;
|
|
+ string bytes;
|
|
+ mojo.common.mojom.FilePath path;
|
|
+ int64 offset;
|
|
+ mojo.common.mojom.Time expected_modification_time;
|
|
+ url.mojom.Url filesystem_url;
|
|
+ string blob_uuid;
|
|
+};
|
|
+
|
|
+struct ResourceRequestBody {
|
|
+ bool has_object;
|
|
+ int64 identifier;
|
|
+ bool contains_sensitive_info;
|
|
+ array<DataElement> elements;
|
|
+};
|
|
+
|
|
struct CreateNewWindowParams {
|
|
// True if this open request came in the context of a user gesture.
|
|
bool user_gesture;
|
|
@@ -72,6 +92,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;
|
|
+ ResourceRequestBody body;
|
|
};
|
|
|
|
struct CreateNewWindowReply {
|
|
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
|
|
index 5c2ab72ff537..3e7c25009c6a 100644
|
|
--- a/content/public/browser/content_browser_client.cc
|
|
+++ b/content/public/browser/content_browser_client.cc
|
|
@@ -298,6 +298,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<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 a3d217fd9446..1a6354a291b7 100644
|
|
--- a/content/public/browser/content_browser_client.h
|
|
+++ b/content/public/browser/content_browser_client.h
|
|
@@ -129,6 +129,7 @@ class RenderFrameHost;
|
|
class RenderProcessHost;
|
|
class RenderViewHost;
|
|
class ResourceContext;
|
|
+class ResourceRequestBody;
|
|
class SiteInstance;
|
|
class SpeechRecognitionManagerDelegate;
|
|
class StoragePartition;
|
|
@@ -153,6 +154,14 @@ class CONTENT_EXPORT ContentBrowserClient {
|
|
public:
|
|
virtual ~ContentBrowserClient() {}
|
|
|
|
+ // Electron: Allows overriding the SiteInstance when navigating.
|
|
+ virtual void OverrideSiteInstanceForNavigation(
|
|
+ RenderFrameHost* render_frame_host,
|
|
+ BrowserContext* browser_context,
|
|
+ SiteInstance* current_instance,
|
|
+ const GURL& dest_url,
|
|
+ SiteInstance** new_instance) {}
|
|
+
|
|
// Allows the embedder to set any number of custom BrowserMainParts
|
|
// implementations for the browser startup code. See comments in
|
|
// browser_main_parts.h.
|
|
@@ -509,6 +518,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<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 d9a7e20f21cc..961cb76b162f 100644
|
|
--- a/content/renderer/render_view_impl.cc
|
|
+++ b/content/renderer/render_view_impl.cc
|
|
@@ -44,6 +44,7 @@
|
|
#include "content/child/request_extra_data.h"
|
|
#include "content/child/v8_value_converter_impl.h"
|
|
#include "content/child/webmessageportchannel_impl.h"
|
|
+#include "content/child/web_url_request_util.h"
|
|
#include "content/common/content_constants_internal.h"
|
|
#include "content/common/content_switches_internal.h"
|
|
#include "content/common/dom_storage/dom_storage_types.h"
|
|
@@ -1439,6 +1440,59 @@ WebView* RenderViewImpl::CreateView(WebLocalFrame* creator,
|
|
}
|
|
params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features);
|
|
|
|
+ params->body = mojom::ResourceRequestBody::New();
|
|
+ auto body = GetRequestBodyForWebURLRequest(request);
|
|
+ if (body) {
|
|
+ params->body->has_object = true;
|
|
+ params->body->identifier = body->identifier();
|
|
+ params->body->contains_sensitive_info = body->contains_sensitive_info();
|
|
+ for (const auto& element : *body->elements()) {
|
|
+ content::mojom::DataElementPtr ptr = content::mojom::DataElement::New();
|
|
+ ptr->type = element.type();
|
|
+ switch (element.type()) {
|
|
+ case storage::DataElement::TYPE_BYTES: {
|
|
+ ptr->bytes = std::string(element.bytes(), element.length());
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_BYTES_DESCRIPTION: {
|
|
+ ptr->length = element.length();
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_FILE: {
|
|
+ ptr->path = element.path();
|
|
+ ptr->offset = element.offset();
|
|
+ ptr->length = element.length();
|
|
+ ptr->expected_modification_time = element.expected_modification_time();
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_FILE_FILESYSTEM: {
|
|
+ ptr->filesystem_url = element.filesystem_url();
|
|
+ ptr->offset = element.offset();
|
|
+ ptr->length = element.length();
|
|
+ ptr->expected_modification_time = element.expected_modification_time();
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_BLOB: {
|
|
+ ptr->blob_uuid = element.blob_uuid();
|
|
+ ptr->offset = element.offset();
|
|
+ ptr->length = element.length();
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_DISK_CACHE_ENTRY: {
|
|
+ NOTREACHED() << "Can't be sent by IPC.";
|
|
+ break;
|
|
+ }
|
|
+ case storage::DataElement::TYPE_UNKNOWN: {
|
|
+ NOTREACHED();
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ params->body->elements.push_back(std::move(ptr));
|
|
+ }
|
|
+ } else {
|
|
+ params->body->has_object = false;
|
|
+ }
|
|
+
|
|
// We preserve this information before sending the message since |params| is
|
|
// moved on send.
|
|
bool is_background_tab =
|