Make keyboard shortcuts work when the dev tools are focused
We just pass unhandled key events from dev tools along to the main WebContentsDelegate. Part of #2.
This commit is contained in:
parent
be6d990a97
commit
4ca59ba279
2 changed files with 19 additions and 1 deletions
|
@ -24,8 +24,10 @@ content::WebContents* DevToolsFrontend::Show(content::WebContents* inspected_con
|
||||||
|
|
||||||
DevToolsFrontend::DevToolsFrontend(content::WebContents* inspected_contents)
|
DevToolsFrontend::DevToolsFrontend(content::WebContents* inspected_contents)
|
||||||
: WebContentsObserver(content::WebContents::Create(content::WebContents::CreateParams(inspected_contents->GetBrowserContext()))),
|
: WebContentsObserver(content::WebContents::Create(content::WebContents::CreateParams(inspected_contents->GetBrowserContext()))),
|
||||||
|
inspected_web_contents_(inspected_contents),
|
||||||
agent_host_(content::DevToolsAgentHost::GetFor(inspected_contents->GetRenderViewHost())),
|
agent_host_(content::DevToolsAgentHost::GetFor(inspected_contents->GetRenderViewHost())),
|
||||||
frontend_host_(content::DevToolsClientHost::CreateDevToolsFrontendHost(web_contents(), this)) {
|
frontend_host_(content::DevToolsClientHost::CreateDevToolsFrontendHost(web_contents(), this)) {
|
||||||
|
web_contents()->SetDelegate(this);
|
||||||
auto client = static_cast<BrowserClient*>(content::GetContentClient()->browser());
|
auto client = static_cast<BrowserClient*>(content::GetContentClient()->browser());
|
||||||
auto handler = client->browser_main_parts()->devtools_http_handler();
|
auto handler = client->browser_main_parts()->devtools_http_handler();
|
||||||
auto url = handler->GetFrontendURL(nullptr);
|
auto url = handler->GetFrontendURL(nullptr);
|
||||||
|
@ -81,4 +83,10 @@ void DevToolsFrontend::WebContentsDestroyed(content::WebContents*) {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevToolsFrontend::HandleKeyboardEvent(content::WebContents* source, const content::NativeWebKeyboardEvent& event) {
|
||||||
|
auto delegate = inspected_web_contents_->GetDelegate();
|
||||||
|
if (delegate)
|
||||||
|
delegate->HandleKeyboardEvent(source, event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "content/public/browser/devtools_frontend_host_delegate.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"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
|
@ -16,7 +17,7 @@ class DevToolsClientHost;
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class DevToolsFrontend : content::DevToolsFrontendHostDelegate, content::WebContentsObserver {
|
class DevToolsFrontend : content::DevToolsFrontendHostDelegate, content::WebContentsObserver, content::WebContentsDelegate {
|
||||||
public:
|
public:
|
||||||
static content::WebContents* Show(content::WebContents* inspected_contents);
|
static content::WebContents* Show(content::WebContents* inspected_contents);
|
||||||
|
|
||||||
|
@ -24,6 +25,8 @@ private:
|
||||||
DevToolsFrontend(content::WebContents* inspected_contents);
|
DevToolsFrontend(content::WebContents* inspected_contents);
|
||||||
~DevToolsFrontend();
|
~DevToolsFrontend();
|
||||||
|
|
||||||
|
// content::DevToolsFrontendHostDelegate
|
||||||
|
|
||||||
virtual void ActivateWindow() OVERRIDE;
|
virtual void ActivateWindow() OVERRIDE;
|
||||||
virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE;
|
virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE;
|
||||||
virtual void CloseWindow() OVERRIDE;
|
virtual void CloseWindow() OVERRIDE;
|
||||||
|
@ -40,9 +43,16 @@ private:
|
||||||
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
|
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
|
||||||
virtual void InspectedContentsClosing() OVERRIDE;
|
virtual void InspectedContentsClosing() OVERRIDE;
|
||||||
|
|
||||||
|
// content::WebContentsObserver
|
||||||
|
|
||||||
virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE;
|
virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE;
|
||||||
virtual void WebContentsDestroyed(content::WebContents*) 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<content::DevToolsAgentHost> agent_host_;
|
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||||
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue