This reverts commit 66d6ba8689
.
This commit is contained in:
parent
66d6ba8689
commit
1b7418fb7b
9 changed files with 43 additions and 100 deletions
|
@ -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,
|
||||
|
|
|
@ -66,15 +66,11 @@ class WebContentsPreferences
|
|||
friend class content::WebContentsUserData<WebContentsPreferences>;
|
||||
friend class AtomBrowserClient;
|
||||
|
||||
enum class Status { Deprecated, Stable };
|
||||
|
||||
// Get WebContents according to process ID.
|
||||
static content::WebContents* GetWebContentsFromProcessID(int process_id);
|
||||
|
||||
// Set preference value to given bool if user did not provide value
|
||||
bool SetDefaultBoolIfUndefined(const base::StringPiece& key,
|
||||
bool val,
|
||||
Status status = Status::Stable);
|
||||
bool SetDefaultBoolIfUndefined(const base::StringPiece& key, bool val);
|
||||
|
||||
static std::vector<WebContentsPreferences*> instances_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue