Skip to content

Commit fdf8d45

Browse files
committed
API: Window.isDevToolsOpen
Query the status of devtools window
1 parent d699ce8 commit fdf8d45

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/api/window/window.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ void Window::CallSync(const std::string& method,
151151
gfx::Point position = shell_->window()->GetPosition();
152152
result->AppendInteger(position.x());
153153
result->AppendInteger(position.y());
154+
} else if (method == "IsDevToolsOpen") {
155+
result->AppendBoolean(shell_->devToolsOpen());
154156
} else {
155157
NOTREACHED() << "Invalid call to Window method:" << method
156158
<< " arguments:" << arguments;

src/api/window_bindings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ Window.prototype.__defineSetter__('isFullscreen', function(flag) {
164164
this.leaveFullscreen();
165165
});
166166

167+
Window.prototype.isDevToolsOpen = function () {
168+
var result = CallObjectMethodSync(this, 'IsDevToolsOpen', []);
169+
return Boolean(result[0]);
170+
}
171+
167172
Window.prototype.__defineGetter__('isFullscreen', function() {
168173
var result = CallObjectMethodSync(this, 'IsFullscreen', []);
169174
return Boolean(result[0]);

src/nw_shell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class Shell : public WebContentsDelegate,
9999
void ReloadOrStop();
100100
void ShowDevTools(const char* jail_id = NULL, bool headless = false);
101101
void CloseDevTools();
102+
bool devToolsOpen() { return devtools_window_.get() != NULL; }
102103
// Send an event to renderer.
103104
void SendEvent(const std::string& event, const std::string& arg1 = "");
104105

0 commit comments

Comments
 (0)