Skip to content

Commit 8e3624e

Browse files
committed
add 'devtools-closed'; always send 'devtools-opened'
1 parent c2ae16e commit 8e3624e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/nw_shell.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ Shell::Shell(WebContents* web_contents, base::DictionaryValue* manifest)
180180
Shell::~Shell() {
181181
SendEvent("closed");
182182

183+
if (is_devtools_ && devtools_owner_.get()) {
184+
devtools_owner_->SendEvent("devtools-closed");
185+
}
186+
183187
for (size_t i = 0; i < windows_.size(); ++i) {
184188
if (windows_[i] == this) {
185189
windows_.erase(windows_.begin() + i);
@@ -344,10 +348,11 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) {
344348
browser_client->shell_browser_main_parts()->devtools_delegate();
345349
GURL url = delegate->devtools_http_handler()->GetFrontendURL(agent.get());
346350

347-
if (headless) {
348-
SendEvent("devtools-opened", url.spec());
351+
SendEvent("devtools-opened", url.spec());
352+
353+
if (headless)
349354
return;
350-
}
355+
351356
// Use our minimum set manifest
352357
base::DictionaryValue manifest;
353358
manifest.SetBoolean(switches::kmToolbar, false);
@@ -370,6 +375,7 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) {
370375
ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, chrome::kFileScheme);
371376
ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, "app");
372377
shell->is_devtools_ = true;
378+
shell->devtools_owner_ = weak_ptr_factory_.GetWeakPtr();
373379
shell->force_close_ = true;
374380
shell->LoadURL(url);
375381

src/nw_shell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class Shell : public WebContentsDelegate,
197197

198198
// Weak potiner to devtools window.
199199
base::WeakPtr<Shell> devtools_window_;
200+
base::WeakPtr<Shell> devtools_owner_;
200201
#if 0
201202
ShellDevToolsFrontend* devtools_frontend_;
202203
#endif

0 commit comments

Comments
 (0)