Merge pull request #1461 from deepak1556/webview_devtools_patch

webview: add inspectElement method
This commit is contained in:
Cheng Zhao 2015-04-25 16:14:13 +08:00
commit 858198a2bd
4 changed files with 17 additions and 0 deletions

View file

@ -494,6 +494,13 @@ bool WebContents::IsDevToolsOpened() {
return storage_->IsDevToolsViewShowing();
}
void WebContents::InspectElement(int x, int y) {
OpenDevTools();
scoped_refptr<content::DevToolsAgentHost> agent(
content::DevToolsAgentHost::GetOrCreateFor(storage_->GetWebContents()));
agent->InspectElement(x, y);
}
void WebContents::Undo() {
web_contents()->Undo();
}
@ -616,6 +623,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
.SetMethod("openDevTools", &WebContents::OpenDevTools)
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
.SetMethod("inspectElement", &WebContents::InspectElement)
.SetMethod("undo", &WebContents::Undo)
.SetMethod("redo", &WebContents::Redo)
.SetMethod("cut", &WebContents::Cut)

View file

@ -71,6 +71,7 @@ class WebContents : public mate::EventEmitter,
void OpenDevTools();
void CloseDevTools();
bool IsDevToolsOpened();
void InspectElement(int x, int y);
// Editing commands.
void Undo();

View file

@ -255,6 +255,7 @@ registerWebViewElement = ->
"openDevTools"
"closeDevTools"
"isDevToolsOpened"
"inspectElement"
"undo"
"redo"
"cut"

View file

@ -223,6 +223,13 @@ Closes the devtools window of guest page.
Returns whether guest page has a devtools window attached.
### `<webview>`.inspectElement(x, y)
* `x` Integer
* `y` Integer
Starts inspecting element at position (`x`, `y`) of guest page.
### `<webview>`.undo()
Executes editing command `undo` in page.