diff --git a/brightray/browser/devtools_frontend.cc b/brightray/browser/devtools_frontend.cc index 773c1c9a915b..097e28c9ff19 100644 --- a/brightray/browser/devtools_frontend.cc +++ b/brightray/browser/devtools_frontend.cc @@ -24,8 +24,10 @@ content::WebContents* DevToolsFrontend::Show(content::WebContents* inspected_con DevToolsFrontend::DevToolsFrontend(content::WebContents* inspected_contents) : WebContentsObserver(content::WebContents::Create(content::WebContents::CreateParams(inspected_contents->GetBrowserContext()))), + inspected_web_contents_(inspected_contents), agent_host_(content::DevToolsAgentHost::GetFor(inspected_contents->GetRenderViewHost())), frontend_host_(content::DevToolsClientHost::CreateDevToolsFrontendHost(web_contents(), this)) { + web_contents()->SetDelegate(this); auto client = static_cast(content::GetContentClient()->browser()); auto handler = client->browser_main_parts()->devtools_http_handler(); auto url = handler->GetFrontendURL(nullptr); @@ -81,4 +83,10 @@ void DevToolsFrontend::WebContentsDestroyed(content::WebContents*) { delete this; } +void DevToolsFrontend::HandleKeyboardEvent(content::WebContents* source, const content::NativeWebKeyboardEvent& event) { + auto delegate = inspected_web_contents_->GetDelegate(); + if (delegate) + delegate->HandleKeyboardEvent(source, event); +} + } diff --git a/brightray/browser/devtools_frontend.h b/brightray/browser/devtools_frontend.h index 07772f42ea28..051b86b2b845 100644 --- a/brightray/browser/devtools_frontend.h +++ b/brightray/browser/devtools_frontend.h @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/devtools_frontend_host_delegate.h" +#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" namespace content { @@ -16,7 +17,7 @@ class DevToolsClientHost; namespace brightray { -class DevToolsFrontend : content::DevToolsFrontendHostDelegate, content::WebContentsObserver { +class DevToolsFrontend : content::DevToolsFrontendHostDelegate, content::WebContentsObserver, content::WebContentsDelegate { public: static content::WebContents* Show(content::WebContents* inspected_contents); @@ -24,6 +25,8 @@ private: DevToolsFrontend(content::WebContents* inspected_contents); ~DevToolsFrontend(); + // content::DevToolsFrontendHostDelegate + virtual void ActivateWindow() OVERRIDE; virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE; virtual void CloseWindow() OVERRIDE; @@ -40,9 +43,16 @@ private: virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE; virtual void InspectedContentsClosing() OVERRIDE; + // content::WebContentsObserver + virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE; virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE; + // content::WebContentsDelegate + + virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; + + content::WebContents* inspected_web_contents_; scoped_refptr agent_host_; scoped_ptr frontend_host_; };