Merge pull request #1839 from deepak1556/devtools_api_patch
devtools: initialise devtoolsWebContents when opened with inspect* apis
This commit is contained in:
commit
912ed2ca10
3 changed files with 10 additions and 4 deletions
|
@ -527,7 +527,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("_openDevTools", &Window::OpenDevTools)
|
||||
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
||||
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
||||
.SetMethod("inspectElement", &Window::InspectElement)
|
||||
.SetMethod("_inspectElement", &Window::InspectElement)
|
||||
.SetMethod("focusOnWebView", &Window::FocusOnWebView)
|
||||
.SetMethod("blurWebView", &Window::BlurWebView)
|
||||
.SetMethod("isWebViewFocused", &Window::IsWebViewFocused)
|
||||
|
@ -549,7 +549,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
#endif
|
||||
.SetMethod("_getWebContents", &Window::GetWebContents)
|
||||
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents)
|
||||
.SetMethod("inspectServiceWorker", &Window::InspectServiceWorker);
|
||||
.SetMethod("_inspectServiceWorker", &Window::InspectServiceWorker);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -55,6 +55,14 @@ BrowserWindow::openDevTools = (options={}) ->
|
|||
BrowserWindow::toggleDevTools = ->
|
||||
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
|
||||
|
||||
BrowserWindow::inspectElement = (x, y) ->
|
||||
@openDevTools true
|
||||
@_inspectElement x, y
|
||||
|
||||
BrowserWindow::inspectServiceWorker = ->
|
||||
@openDevTools true
|
||||
@_inspectServiceWorker()
|
||||
|
||||
BrowserWindow::getWebContents = ->
|
||||
wrapWebContents @_getWebContents()
|
||||
|
||||
|
|
|
@ -308,7 +308,6 @@ bool NativeWindow::IsDevToolsOpened() {
|
|||
}
|
||||
|
||||
void NativeWindow::InspectElement(int x, int y) {
|
||||
OpenDevTools(true);
|
||||
scoped_refptr<content::DevToolsAgentHost> agent(
|
||||
content::DevToolsAgentHost::GetOrCreateFor(GetWebContents()));
|
||||
agent->InspectElement(x, y);
|
||||
|
@ -318,7 +317,6 @@ void NativeWindow::InspectServiceWorker() {
|
|||
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
|
||||
if (agent_host->GetType() ==
|
||||
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
|
||||
OpenDevTools(true);
|
||||
inspectable_web_contents()->AttachTo(agent_host);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue