Skip to content

Commit 319f7ec

Browse files
author
Cong Liu
committed
Fixed devtools issue
fixed nwjs#2660 fixed nwjs#2603
1 parent 16340c2 commit 319f7ec

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/nw_shell.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,12 @@ 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());
441+
GURL url = delegate->devtools_http_handler()->GetFrontendURL();
442442
DevToolsHttpHandlerImpl* http_handler = static_cast<DevToolsHttpHandlerImpl*>(delegate->devtools_http_handler());
443443
http_handler->EnumerateTargets();
444444

445445
if (headless) {
446-
DevToolsAgentHost* agent_host = DevToolsAgentHost::GetOrCreateFor(web_contents()).get();
447-
448-
url = delegate->devtools_http_handler()->GetFrontendURL(agent_host);
446+
url = delegate->devtools_http_handler()->GetFrontendURL();
449447
DevToolsHttpHandlerImpl* http_handler = static_cast<DevToolsHttpHandlerImpl*>(delegate->devtools_http_handler());
450448
http_handler->EnumerateTargets();
451449
SendEvent("devtools-opened", url.spec());
@@ -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)