From a96cde254b18667863b3f5aad929b5b35e47630f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 24 Oct 2014 21:46:47 +0800 Subject: [PATCH] Send unhandled key event to embedder --- atom/browser/api/atom_api_web_contents.cc | 11 +++++++++++ atom/browser/api/atom_api_web_contents.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 5d732cc9..caddb2b3 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -83,6 +83,17 @@ content::WebContents* WebContents::OpenURLFromTab( return web_contents(); } +void WebContents::HandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event) { + if (!attached()) + return; + + // Send the unhandled keyboard events back to the embedder to reprocess them. + embedder_web_contents_->GetDelegate()->HandleKeyboardEvent( + web_contents(), event); +} + void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) { base::ListValue args; args.AppendInteger(render_view_host->GetProcess()->GetID()); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 393fd496..90f45caf 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -88,9 +88,12 @@ class WebContents : public mate::EventEmitter, v8::Isolate* isolate) override; // content::WebContentsDelegate: - virtual content::WebContents* OpenURLFromTab( + content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) override; + void HandleKeyboardEvent( + content::WebContents* source, + const content::NativeWebKeyboardEvent& event) override; // content::WebContentsObserver: virtual void RenderViewDeleted(content::RenderViewHost*) override; -- 2.43.0