feat: remove nativeWindowOpen option (#29405)
Co-authored-by: Cheng Zhao <zcbenz@gmail.com> Co-authored-by: Milan Burda <milan.burda@gmail.com>
This commit is contained in:
parent
2f9fd06534
commit
d44a187d0b
39 changed files with 316 additions and 1164 deletions
|
@ -81,8 +81,7 @@ BrowserView::BrowserView(gin::Arguments* args,
|
|||
|
||||
v8::Local<v8::Value> value;
|
||||
|
||||
// Copy the webContents option to webPreferences. This is only used internally
|
||||
// to implement nativeWindowOpen option.
|
||||
// Copy the webContents option to webPreferences.
|
||||
if (options.Get("webContents", &value)) {
|
||||
web_preferences.SetHidden("webContents", value);
|
||||
}
|
||||
|
|
|
@ -78,8 +78,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
|
|||
web_preferences.Set(options::kEnableBlinkFeatures, enabled_features);
|
||||
}
|
||||
|
||||
// Copy the webContents option to webPreferences. This is only used internally
|
||||
// to implement nativeWindowOpen option.
|
||||
// Copy the webContents option to webPreferences.
|
||||
if (options.Get("webContents", &value)) {
|
||||
web_preferences.SetHidden("webContents", value);
|
||||
}
|
||||
|
|
|
@ -721,7 +721,7 @@ bool ElectronBrowserClient::CanCreateWindow(
|
|||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(opener);
|
||||
WebContentsPreferences* prefs = WebContentsPreferences::From(web_contents);
|
||||
if (prefs && prefs->ShouldUseNativeWindowOpen()) {
|
||||
if (prefs) {
|
||||
if (prefs->ShouldDisablePopups()) {
|
||||
// <webview> without allowpopups attribute should return
|
||||
// null from window.open calls
|
||||
|
|
|
@ -130,7 +130,6 @@ void WebContentsPreferences::Clear() {
|
|||
disable_html_fullscreen_window_resize_ = false;
|
||||
webview_tag_ = false;
|
||||
sandbox_ = absl::nullopt;
|
||||
native_window_open_ = true;
|
||||
context_isolation_ = true;
|
||||
javascript_ = true;
|
||||
images_ = true;
|
||||
|
@ -148,7 +147,6 @@ void WebContentsPreferences::Clear() {
|
|||
default_monospace_font_size_ = absl::nullopt;
|
||||
minimum_font_size_ = absl::nullopt;
|
||||
default_encoding_ = absl::nullopt;
|
||||
opener_id_ = 0;
|
||||
is_webview_ = false;
|
||||
custom_args_.clear();
|
||||
custom_switches_.clear();
|
||||
|
@ -194,7 +192,6 @@ void WebContentsPreferences::Merge(
|
|||
bool sandbox;
|
||||
if (web_preferences.Get(options::kSandbox, &sandbox))
|
||||
sandbox_ = sandbox;
|
||||
web_preferences.Get(options::kNativeWindowOpen, &native_window_open_);
|
||||
web_preferences.Get(options::kContextIsolation, &context_isolation_);
|
||||
web_preferences.Get(options::kJavaScript, &javascript_);
|
||||
web_preferences.Get(options::kImages, &images_);
|
||||
|
@ -223,7 +220,6 @@ void WebContentsPreferences::Merge(
|
|||
std::string encoding;
|
||||
if (web_preferences.Get("defaultEncoding", &encoding))
|
||||
default_encoding_ = encoding;
|
||||
web_preferences.Get(options::kOpenerID, &opener_id_);
|
||||
web_preferences.Get(options::kCustomArgs, &custom_args_);
|
||||
web_preferences.Get("commandLineSwitches", &custom_switches_);
|
||||
web_preferences.Get("disablePopups", &disable_popups_);
|
||||
|
@ -406,13 +402,10 @@ void WebContentsPreferences::AppendCommandLineSwitches(
|
|||
|
||||
void WebContentsPreferences::SaveLastPreferences() {
|
||||
last_web_preferences_ = base::Value(base::Value::Type::DICTIONARY);
|
||||
last_web_preferences_.SetKey(options::kOpenerID, base::Value(opener_id_));
|
||||
last_web_preferences_.SetKey(options::kNodeIntegration,
|
||||
base::Value(node_integration_));
|
||||
last_web_preferences_.SetKey(options::kNodeIntegrationInSubFrames,
|
||||
base::Value(node_integration_in_sub_frames_));
|
||||
last_web_preferences_.SetKey(options::kNativeWindowOpen,
|
||||
base::Value(native_window_open_));
|
||||
last_web_preferences_.SetKey(options::kSandbox, base::Value(IsSandboxed()));
|
||||
last_web_preferences_.SetKey(options::kContextIsolation,
|
||||
base::Value(context_isolation_));
|
||||
|
@ -477,9 +470,6 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
|||
if (default_encoding_)
|
||||
prefs->default_encoding = *default_encoding_;
|
||||
|
||||
// Pass the opener's window id.
|
||||
prefs->opener_id = opener_id_;
|
||||
|
||||
// Run Electron APIs and preload script in isolated world
|
||||
prefs->context_isolation = context_isolation_;
|
||||
prefs->is_webview = is_webview_;
|
||||
|
@ -507,7 +497,6 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
|||
if (preload_path_)
|
||||
prefs->preload = *preload_path_;
|
||||
|
||||
prefs->native_window_open = native_window_open_;
|
||||
prefs->node_integration = node_integration_;
|
||||
prefs->node_integration_in_worker = node_integration_in_worker_;
|
||||
prefs->node_integration_in_sub_frames = node_integration_in_sub_frames_;
|
||||
|
|
|
@ -75,7 +75,6 @@ class WebContentsPreferences
|
|||
bool ShouldUseSafeDialogs() const { return safe_dialogs_; }
|
||||
bool GetSafeDialogsMessage(std::string* message) const;
|
||||
bool ShouldDisablePopups() const { return disable_popups_; }
|
||||
bool ShouldUseNativeWindowOpen() const { return native_window_open_; }
|
||||
bool IsWebSecurityEnabled() const { return web_security_; }
|
||||
bool GetPreloadPath(base::FilePath* path) const;
|
||||
bool IsSandboxed() const;
|
||||
|
@ -100,7 +99,6 @@ class WebContentsPreferences
|
|||
bool disable_html_fullscreen_window_resize_;
|
||||
bool webview_tag_;
|
||||
absl::optional<bool> sandbox_;
|
||||
bool native_window_open_;
|
||||
bool context_isolation_;
|
||||
bool javascript_;
|
||||
bool images_;
|
||||
|
@ -118,7 +116,6 @@ class WebContentsPreferences
|
|||
absl::optional<int> default_monospace_font_size_;
|
||||
absl::optional<int> minimum_font_size_;
|
||||
absl::optional<std::string> default_encoding_;
|
||||
int opener_id_;
|
||||
bool is_webview_;
|
||||
std::vector<std::string> custom_args_;
|
||||
std::vector<std::string> custom_switches_;
|
||||
|
|
|
@ -102,10 +102,6 @@ void RequestGarbageCollectionForTesting(v8::Isolate* isolate) {
|
|||
v8::Isolate::GarbageCollectionType::kFullGarbageCollection);
|
||||
}
|
||||
|
||||
bool IsSameOrigin(const GURL& l, const GURL& r) {
|
||||
return url::Origin::Create(l).IsSameOriginWith(url::Origin::Create(r));
|
||||
}
|
||||
|
||||
// This causes a fatal error by creating a circular extension dependency.
|
||||
void TriggerFatalErrorForTesting(v8::Isolate* isolate) {
|
||||
static const char* aDeps[] = {"B"};
|
||||
|
@ -132,7 +128,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
|
||||
dict.SetMethod("requestGarbageCollectionForTesting",
|
||||
&RequestGarbageCollectionForTesting);
|
||||
dict.SetMethod("isSameOrigin", &IsSameOrigin);
|
||||
dict.SetMethod("triggerFatalErrorForTesting", &TriggerFatalErrorForTesting);
|
||||
dict.SetMethod("runUntilIdle", &RunUntilIdle);
|
||||
}
|
||||
|
|
|
@ -129,9 +129,6 @@ const char kContextIsolation[] = "contextIsolation";
|
|||
// Web runtime features.
|
||||
const char kExperimentalFeatures[] = "experimentalFeatures";
|
||||
|
||||
// Opener window's ID.
|
||||
const char kOpenerID[] = "openerId";
|
||||
|
||||
// Enable the rubber banding effect.
|
||||
const char kScrollBounce[] = "scrollBounce";
|
||||
|
||||
|
@ -147,8 +144,6 @@ const char kNodeIntegrationInWorker[] = "nodeIntegrationInWorker";
|
|||
// Enable the web view tag.
|
||||
const char kWebviewTag[] = "webviewTag";
|
||||
|
||||
const char kNativeWindowOpen[] = "nativeWindowOpen";
|
||||
|
||||
const char kCustomArgs[] = "additionalArguments";
|
||||
|
||||
const char kPlugins[] = "plugins";
|
||||
|
|
|
@ -69,13 +69,11 @@ extern const char kPreloadURL[];
|
|||
extern const char kNodeIntegration[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kExperimentalFeatures[];
|
||||
extern const char kOpenerID[];
|
||||
extern const char kScrollBounce[];
|
||||
extern const char kEnableBlinkFeatures[];
|
||||
extern const char kDisableBlinkFeatures[];
|
||||
extern const char kNodeIntegrationInWorker[];
|
||||
extern const char kWebviewTag[];
|
||||
extern const char kNativeWindowOpen[];
|
||||
extern const char kCustomArgs[];
|
||||
extern const char kPlugins[];
|
||||
extern const char kSandbox[];
|
||||
|
|
|
@ -496,9 +496,6 @@ class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>,
|
|||
|
||||
if (pref_name == options::kPreloadScripts) {
|
||||
return gin::ConvertToV8(isolate, prefs.preloads);
|
||||
} else if (pref_name == options::kOpenerID) {
|
||||
// NOTE: openerId is internal-only.
|
||||
return gin::ConvertToV8(isolate, prefs.opener_id);
|
||||
} else if (pref_name == "isWebView") {
|
||||
// FIXME(zcbenz): For child windows opened with window.open('') from
|
||||
// webview, the WebPreferences is inherited from webview and the value
|
||||
|
@ -516,8 +513,6 @@ class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>,
|
|||
return gin::ConvertToV8(isolate, prefs.offscreen);
|
||||
} else if (pref_name == options::kPreloadScript) {
|
||||
return gin::ConvertToV8(isolate, prefs.preload.value());
|
||||
} else if (pref_name == options::kNativeWindowOpen) {
|
||||
return gin::ConvertToV8(isolate, prefs.native_window_open);
|
||||
} else if (pref_name == options::kNodeIntegration) {
|
||||
return gin::ConvertToV8(isolate, prefs.node_integration);
|
||||
} else if (pref_name == options::kNodeIntegrationInWorker) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue