From: Cheng Zhao Date: Fri, 24 Oct 2014 13:46:47 +0000 (+0800) Subject: Send unhandled key event to embedder X-Git-Tag: v0.19.0~3^2~19 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a96cde254b18667863b3f5aad929b5b35e47630f;p=electron.git Send unhandled key event to embedder --- 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;