Add support for DevTools inspect element via a new |inspect_element_at| parameter added to CefBrowserHost::ShowDevTools (issue #586).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1870 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2014-10-11 00:12:01 +00:00
parent 5c1f3e4ffa
commit d15f6abc3a
15 changed files with 113 additions and 27 deletions

View File

@@ -98,21 +98,24 @@ class ShowDevToolsHelper {
ShowDevToolsHelper(CefRefPtr<CefBrowserHostImpl> browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings)
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at)
: browser_(browser),
window_info_(windowInfo),
client_(client),
settings_(settings) {}
settings_(settings),
inspect_element_at_(inspect_element_at) {}
CefRefPtr<CefBrowserHostImpl> browser_;
CefWindowInfo window_info_;
CefRefPtr<CefClient> client_;
CefBrowserSettings settings_;
CefPoint inspect_element_at_;
};
void ShowDevToolsWithHelper(ShowDevToolsHelper* helper) {
helper->browser_->ShowDevTools(helper->window_info_, helper->client_,
helper->settings_);
helper->settings_, helper->inspect_element_at_);
delete helper;
}
@@ -812,7 +815,8 @@ void CefBrowserHostImpl::StopFinding(bool clearSelection) {
void CefBrowserHostImpl::ShowDevTools(
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings) {
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) {
if (CEF_CURRENTLY_ON_UIT()) {
if (!web_contents_)
return;
@@ -823,12 +827,13 @@ void CefBrowserHostImpl::ShowDevTools(
}
devtools_frontend_ = CefDevToolsFrontend::Show(
this, windowInfo, client, settings);
this, windowInfo, client, settings, inspect_element_at);
devtools_observer_.reset(new DevToolsWebContentsObserver(
this, devtools_frontend_->frontend_browser()->web_contents()));
} else {
ShowDevToolsHelper* helper =
new ShowDevToolsHelper(this, windowInfo, client, settings);
new ShowDevToolsHelper(this, windowInfo, client, settings,
inspect_element_at);
CEF_POST_TASK(CEF_UIT, base::Bind(ShowDevToolsWithHelper, helper));
}
}

View File

@@ -153,7 +153,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
virtual void StopFinding(bool clearSelection) OVERRIDE;
virtual void ShowDevTools(const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings) OVERRIDE;
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) OVERRIDE;
virtual void CloseDevTools() OVERRIDE;
virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE;
virtual bool IsMouseCursorChangeDisabled() OVERRIDE;

View File

@@ -26,7 +26,8 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
CefRefPtr<CefBrowserHostImpl> inspected_browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings) {
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at) {
CefBrowserSettings new_settings = settings;
if (CefColorGetA(new_settings.background_color) == 0) {
// Use white as the default background color for DevTools instead of the
@@ -40,12 +41,17 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
inspected_browser->GetWindowHandle(), true,
inspected_browser->GetRequestContext());
scoped_refptr<content::DevToolsAgentHost> agent_host =
content::DevToolsAgentHost::GetOrCreateFor(
inspected_browser->GetWebContents());
if (!inspect_element_at.IsEmpty())
agent_host->InspectElement(inspect_element_at.x, inspect_element_at.y);
// CefDevToolsFrontend will delete itself when the frontend WebContents is
// destroyed.
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
static_cast<CefBrowserHostImpl*>(frontend_browser.get()),
content::DevToolsAgentHost::GetOrCreateFor(
inspected_browser->GetWebContents()).get());
agent_host.get());
// Need to load the URL after creating the DevTools objects.
CefDevToolsDelegate* delegate =

View File

@@ -28,7 +28,8 @@ class CefDevToolsFrontend : public content::WebContentsObserver,
CefRefPtr<CefBrowserHostImpl> inspected_browser,
const CefWindowInfo& windowInfo,
CefRefPtr<CefClient> client,
const CefBrowserSettings& settings);
const CefBrowserSettings& settings,
const CefPoint& inspect_element_at);
void Activate();
void Focus();