add option to disable devtools
This commit is contained in:
parent
02ce727ff6
commit
0d7e7be748
5 changed files with 17 additions and 0 deletions
|
@ -290,6 +290,9 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
else if (options.Get("offscreen", &b) && b)
|
else if (options.Get("offscreen", &b) && b)
|
||||||
type_ = OFF_SCREEN;
|
type_ = OFF_SCREEN;
|
||||||
|
|
||||||
|
// Whether to disable DevTools.
|
||||||
|
options.Get("disableDevTools", &disable_devtools_);
|
||||||
|
|
||||||
// Obtain the session.
|
// Obtain the session.
|
||||||
std::string partition;
|
std::string partition;
|
||||||
mate::Handle<api::Session> session;
|
mate::Handle<api::Session> session;
|
||||||
|
@ -940,6 +943,9 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
||||||
if (type_ == REMOTE)
|
if (type_ == REMOTE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (disable_devtools_)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string state;
|
std::string state;
|
||||||
if (type_ == WEB_VIEW || !owner_window()) {
|
if (type_ == WEB_VIEW || !owner_window()) {
|
||||||
state = "detach";
|
state = "detach";
|
||||||
|
|
|
@ -323,6 +323,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
// Whether background throttling is disabled.
|
// Whether background throttling is disabled.
|
||||||
bool background_throttling_;
|
bool background_throttling_;
|
||||||
|
|
||||||
|
// // Whether to disable devtools.
|
||||||
|
bool disable_devtools_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
DISALLOW_COPY_AND_ASSIGN(WebContents);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,10 @@ Window::Window(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||||
if (options.Get("transparent", &transparent))
|
if (options.Get("transparent", &transparent))
|
||||||
web_preferences.Set("transparent", transparent);
|
web_preferences.Set("transparent", transparent);
|
||||||
|
|
||||||
|
// Disable WebContents.OpenDevTools() ?
|
||||||
|
if (options.Get(options::kDisableDevTools, &value))
|
||||||
|
web_preferences.Set(options::kDisableDevTools, value);
|
||||||
|
|
||||||
// Creates the WebContents used by BrowserWindow.
|
// Creates the WebContents used by BrowserWindow.
|
||||||
auto web_contents = WebContents::Create(isolate, web_preferences);
|
auto web_contents = WebContents::Create(isolate, web_preferences);
|
||||||
web_contents_.Reset(isolate, web_contents.ToV8());
|
web_contents_.Reset(isolate, web_contents.ToV8());
|
||||||
|
|
|
@ -96,6 +96,9 @@ const char kNodeIntegration[] = "nodeIntegration";
|
||||||
// Instancd ID of guest WebContents.
|
// Instancd ID of guest WebContents.
|
||||||
const char kGuestInstanceID[] = "guestInstanceId";
|
const char kGuestInstanceID[] = "guestInstanceId";
|
||||||
|
|
||||||
|
// Diable openDevTools.
|
||||||
|
const char kDisableDevTools[] = "disableDevTools";
|
||||||
|
|
||||||
// Web runtime features.
|
// Web runtime features.
|
||||||
const char kExperimentalFeatures[] = "experimentalFeatures";
|
const char kExperimentalFeatures[] = "experimentalFeatures";
|
||||||
const char kExperimentalCanvasFeatures[] = "experimentalCanvasFeatures";
|
const char kExperimentalCanvasFeatures[] = "experimentalCanvasFeatures";
|
||||||
|
|
|
@ -46,6 +46,7 @@ extern const char kBackgroundColor[];
|
||||||
extern const char kHasShadow[];
|
extern const char kHasShadow[];
|
||||||
extern const char kFocusable[];
|
extern const char kFocusable[];
|
||||||
extern const char kWebPreferences[];
|
extern const char kWebPreferences[];
|
||||||
|
extern const char kDisableDevTools[];
|
||||||
|
|
||||||
// WebPreferences.
|
// WebPreferences.
|
||||||
extern const char kZoomFactor[];
|
extern const char kZoomFactor[];
|
||||||
|
|
Loading…
Reference in a new issue