Revert "sec: deprecate some webPreference defaults to be secure-by-default (#14284)" (#14380)

This reverts commit 66d6ba8689.
This commit is contained in:
Samuel Attard 2018-08-30 09:57:49 +12:00 committed by GitHub
parent 66d6ba8689
commit 1b7418fb7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 100 deletions

View file

@ -8,7 +8,6 @@
#include <string>
#include <vector>
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/native_window.h"
#include "atom/browser/web_view_manager.h"
#include "atom/common/native_mate_converters/value_converter.h"
@ -100,14 +99,12 @@ WebContentsPreferences::WebContentsPreferences(
// Set WebPreferences defaults onto the JS object
SetDefaultBoolIfUndefined(options::kPlugins, false);
SetDefaultBoolIfUndefined(options::kExperimentalFeatures, false);
bool node = SetDefaultBoolIfUndefined(options::kNodeIntegration, true,
Status::Deprecated);
bool node = SetDefaultBoolIfUndefined(options::kNodeIntegration, true);
SetDefaultBoolIfUndefined(options::kNodeIntegrationInWorker, false);
SetDefaultBoolIfUndefined(options::kWebviewTag, node, Status::Deprecated);
SetDefaultBoolIfUndefined(options::kWebviewTag, node);
SetDefaultBoolIfUndefined(options::kSandbox, false);
SetDefaultBoolIfUndefined(options::kNativeWindowOpen, false);
SetDefaultBoolIfUndefined(options::kContextIsolation, false,
Status::Deprecated);
SetDefaultBoolIfUndefined(options::kContextIsolation, false);
SetDefaultBoolIfUndefined("javascript", true);
SetDefaultBoolIfUndefined("images", true);
SetDefaultBoolIfUndefined("textAreasAreResizable", true);
@ -137,24 +134,15 @@ WebContentsPreferences::~WebContentsPreferences() {
bool WebContentsPreferences::SetDefaultBoolIfUndefined(
const base::StringPiece& key,
bool val,
Status status) {
bool val) {
auto* current_value =
preference_.FindKeyOfType(key, base::Value::Type::BOOLEAN);
if (current_value) {
return current_value->GetBool();
} else {
preference_.SetKey(key, base::Value(val));
if (status == Status::Deprecated && web_contents_) {
auto internal_contents = atom::api::WebContents::CreateFrom(
v8::Isolate::GetCurrent(), web_contents_);
internal_contents->Emit("-deprecated-default",
std::string("webPreferences.") + key.data(),
/* oldDefault */ val, /* newDefault */ !val);
}
return val;
}
return val;
}
bool WebContentsPreferences::IsEnabled(const base::StringPiece& name,