Skip to content

Commit f7e4bb6

Browse files
committed
add window.closeDevTools()
1 parent acce8c9 commit f7e4bb6

File tree

4 files changed

+10
-24
lines changed

4 files changed

+10
-24
lines changed

src/api/window/window.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ void Window::Call(const std::string& method,
8484
arguments.GetString(0, &jail_id);
8585
arguments.GetBoolean(1, &headless);
8686
shell_->ShowDevTools(jail_id.c_str(), headless);
87-
} else if (method == "ResizeTo") {
87+
} else if (method == "CloseDevTools") {
88+
shell_->CloseDevTools();
89+
}else if (method == "ResizeTo") {
8890
int width, height;
8991
if (arguments.GetInteger(0, &width) &&
9092
arguments.GetInteger(1, &height))

src/api/window_bindings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ Window.prototype.toggleKioskMode = function() {
269269
CallObjectMethod(this, 'ToggleKioskMode', []);
270270
}
271271

272+
Window.prototype.closeDevTools = function() {
273+
CallObjectMethod(this, 'CloseDevTools', []);
274+
}
275+
272276
Window.prototype.showDevTools = function(frm, headless) {
273277
var id = '';
274278
if (typeof frm === 'string') {

src/nw_shell.cc

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -300,31 +300,14 @@ void Shell::ReloadOrStop() {
300300
Reload();
301301
}
302302

303-
#if 0
304303
void Shell::CloseDevTools() {
305-
if (!devtools_frontend_)
304+
if (!devtools_window_)
306305
return;
307-
registrar_.Remove(this,
308-
NOTIFICATION_WEB_CONTENTS_DESTROYED,
309-
Source<WebContents>(
310-
devtools_frontend_->frontend_shell()->web_contents()));
311-
devtools_frontend_->Close();
312-
devtools_frontend_ = NULL;
306+
devtools_window_->window()->Close();
307+
devtools_window_.reset();
313308
}
314-
#endif
315309

316310
void Shell::ShowDevTools(const char* jail_id, bool headless) {
317-
#if 0
318-
if (devtools_frontend_) {
319-
devtools_frontend_->Focus();
320-
return;
321-
}
322-
devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents());
323-
registrar_.Add(this,
324-
NOTIFICATION_WEB_CONTENTS_DESTROYED,
325-
Source<WebContents>(
326-
devtools_frontend_->frontend_shell()->web_contents()));
327-
#else
328311
ShellContentBrowserClient* browser_client =
329312
static_cast<ShellContentBrowserClient*>(
330313
GetContentClient()->browser());
@@ -387,7 +370,6 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) {
387370
browser_context->set_pinning_renderer(true);
388371
// Save devtools window in current shell.
389372
devtools_window_ = shell->weak_ptr_factory_.GetWeakPtr();
390-
#endif
391373
}
392374

393375
void Shell::UpdateDraggableRegions(

src/nw_shell.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ class Shell : public WebContentsDelegate,
9898
void Stop();
9999
void ReloadOrStop();
100100
void ShowDevTools(const char* jail_id = NULL, bool headless = false);
101-
#if 0
102101
void CloseDevTools();
103-
#endif
104102
// Send an event to renderer.
105103
void SendEvent(const std::string& event, const std::string& arg1 = "");
106104

0 commit comments

Comments
 (0)