feat: add more info in setWindowOpenHandler details (#28518)
* fix: invoke the window open handler for _blank links * feat: add disposition to setWindowOpenHandler details * fix: pass postData to new-window event * postData can be heterogeneous * fix type of postBody * fix type of UploadFile and UploadRawData to be discriminated unions * exclude the empty string from additionalFeatures * add a test * add postBody and referrer to setWindowOpenHandler args * appease typescript * Update api-browser-window-spec.ts * update snapshots
This commit is contained in:
parent
b6315612dd
commit
dba4df9326
16 changed files with 152 additions and 65 deletions
|
@ -1012,8 +1012,9 @@ bool WebContents::IsWebContentsCreationOverridden(
|
|||
content::mojom::WindowContainerType window_container_type,
|
||||
const GURL& opener_url,
|
||||
const content::mojom::CreateNewWindowParams& params) {
|
||||
bool default_prevented = Emit("-will-add-new-contents", params.target_url,
|
||||
params.frame_name, params.raw_features);
|
||||
bool default_prevented = Emit(
|
||||
"-will-add-new-contents", params.target_url, params.frame_name,
|
||||
params.raw_features, params.disposition, *params.referrer, params.body);
|
||||
// If the app prevented the default, redirect to CreateCustomWebContents,
|
||||
// which always returns nullptr, which will result in the window open being
|
||||
// prevented (window.open() will return null in the renderer).
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "gin/converter.h"
|
||||
#include "shell/common/gin_converters/gfx_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/keyboard_util.h"
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include "third_party/blink/public/common/input/web_mouse_event.h"
|
||||
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
|
||||
#include "third_party/blink/public/common/widget/device_emulation_params.h"
|
||||
#include "third_party/blink/public/mojom/loader/referrer.mojom.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
#include "ui/events/blink/blink_event_util.h"
|
||||
#include "ui/events/keycodes/dom/keycode_converter.h"
|
||||
|
@ -481,6 +483,33 @@ bool Converter<network::mojom::ReferrerPolicy>::FromV8(
|
|||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<blink::mojom::Referrer>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::mojom::Referrer& val) {
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("url", ConvertToV8(isolate, val.url));
|
||||
dict.Set("policy", ConvertToV8(isolate, val.policy));
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
}
|
||||
//
|
||||
// static
|
||||
bool Converter<blink::mojom::Referrer>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
blink::mojom::Referrer* out) {
|
||||
gin_helper::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
||||
if (!dict.Get("url", &out->url))
|
||||
return false;
|
||||
|
||||
if (!dict.Get("policy", &out->policy))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<blink::CloneableMessage>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::CloneableMessage& in) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
#include "third_party/blink/public/common/messaging/cloneable_message.h"
|
||||
#include "third_party/blink/public/common/web_cache/web_cache_resource_type_stats.h"
|
||||
#include "third_party/blink/public/mojom/loader/referrer.mojom-forward.h"
|
||||
|
||||
namespace blink {
|
||||
class WebMouseEvent;
|
||||
|
@ -95,6 +96,15 @@ struct Converter<network::mojom::ReferrerPolicy> {
|
|||
network::mojom::ReferrerPolicy* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::mojom::Referrer> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const blink::mojom::Referrer& val);
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
blink::mojom::Referrer* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::CloneableMessage> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue