Merge pull request #7096 from minggo/add-option-to-disable-devtools
add option to disable devtools
This commit is contained in:
commit
4eba8094d4
4 changed files with 20 additions and 3 deletions
|
@ -261,7 +261,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
embedder_(nullptr),
|
||||
type_(REMOTE),
|
||||
request_id_(0),
|
||||
background_throttling_(true) {
|
||||
background_throttling_(true),
|
||||
enable_devtools_(true) {
|
||||
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
|
||||
|
||||
Init(isolate);
|
||||
|
@ -273,7 +274,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
: embedder_(nullptr),
|
||||
type_(BROWSER_WINDOW),
|
||||
request_id_(0),
|
||||
background_throttling_(true) {
|
||||
background_throttling_(true),
|
||||
enable_devtools_(true) {
|
||||
// Read options.
|
||||
options.Get("backgroundThrottling", &background_throttling_);
|
||||
|
||||
|
@ -290,6 +292,9 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
else if (options.Get("offscreen", &b) && b)
|
||||
type_ = OFF_SCREEN;
|
||||
|
||||
// Whether to enable DevTools.
|
||||
options.Get("devTools", &enable_devtools_);
|
||||
|
||||
// Obtain the session.
|
||||
std::string partition;
|
||||
mate::Handle<api::Session> session;
|
||||
|
@ -940,6 +945,9 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
|
|||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
return;
|
||||
|
||||
std::string state;
|
||||
if (type_ == WEB_VIEW || !owner_window()) {
|
||||
state = "detach";
|
||||
|
@ -1006,6 +1014,9 @@ void WebContents::InspectElement(int x, int y) {
|
|||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
return;
|
||||
|
||||
if (!managed_web_contents()->GetDevToolsWebContents())
|
||||
OpenDevTools(nullptr);
|
||||
scoped_refptr<content::DevToolsAgentHost> agent(
|
||||
|
@ -1017,6 +1028,9 @@ void WebContents::InspectServiceWorker() {
|
|||
if (type_ == REMOTE)
|
||||
return;
|
||||
|
||||
if (!enable_devtools_)
|
||||
return;
|
||||
|
||||
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
|
||||
if (agent_host->GetType() ==
|
||||
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue