Skip to content

Commit ece6331

Browse files
committed
Merge pull request nwjs#2917 from ghostoy/fix-devtools
Fix devtools
2 parents 16340c2 + 3b0a78f commit ece6331

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/nw_shell.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,21 +438,19 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) {
438438

439439
ShellDevToolsDelegate* delegate =
440440
browser_client->shell_browser_main_parts()->devtools_delegate();
441-
GURL url = delegate->devtools_http_handler()->GetFrontendURL(agent.get());
442441
DevToolsHttpHandlerImpl* http_handler = static_cast<DevToolsHttpHandlerImpl*>(delegate->devtools_http_handler());
443442
http_handler->EnumerateTargets();
444443

444+
GURL url;
445445
if (headless) {
446-
DevToolsAgentHost* agent_host = DevToolsAgentHost::GetOrCreateFor(web_contents()).get();
447-
448-
url = delegate->devtools_http_handler()->GetFrontendURL(agent_host);
449-
DevToolsHttpHandlerImpl* http_handler = static_cast<DevToolsHttpHandlerImpl*>(delegate->devtools_http_handler());
450-
http_handler->EnumerateTargets();
446+
url = delegate->devtools_http_handler()->GetFrontendURL(agent.get());
451447
SendEvent("devtools-opened", url.spec());
452448
return;
449+
} else {
450+
url = delegate->devtools_http_handler()->GetFrontendURL();
451+
SendEvent("devtools-opened", url.spec());
453452
}
454453

455-
SendEvent("devtools-opened", url.spec());
456454
// Use our minimum set manifest
457455
base::DictionaryValue manifest;
458456
manifest.SetBoolean(switches::kmToolbar, false);
@@ -473,7 +471,7 @@ void Shell::ShowDevTools(const char* jail_id, bool headless) {
473471

474472
new ShellDevToolsFrontend(
475473
shell,
476-
DevToolsAgentHost::GetOrCreateFor(web_contents_.get()).get());
474+
agent.get());
477475

478476
int rh_id = shell->web_contents_->GetRenderProcessHost()->GetID();
479477
ChildProcessSecurityPolicyImpl::GetInstance()->GrantScheme(rh_id, url::kFileScheme);

src/shell_devtools_frontend.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ ShellDevToolsFrontend::~ShellDevToolsFrontend() {
6969

7070
void ShellDevToolsFrontend::RenderViewCreated(
7171
RenderViewHost* render_view_host) {
72-
#if 0
7372
if (!frontend_host_) {
7473
frontend_host_.reset(DevToolsFrontendHost::Create(render_view_host, this));
7574
DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
7675
agent_host_.get(), this);
7776
}
78-
#endif
77+
}
78+
79+
void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() {
80+
web_contents()->GetMainFrame()->ExecuteJavaScript(
81+
base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);"));
7982
}
8083

8184
void ShellDevToolsFrontend::WebContentsDestroyed() {

src/shell_devtools_frontend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ShellDevToolsFrontend : public WebContentsObserver,
3737

3838
// WebContentsObserver overrides
3939
virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
40+
virtual void DocumentOnLoadCompletedInMainFrame() OVERRIDE;
4041
virtual void WebContentsDestroyed() OVERRIDE;
4142

4243
// content::DevToolsFrontendHost::Delegate implementation.

0 commit comments

Comments
 (0)