]> khamidou — GitHub mirrors - electron.git/commitdiff
Send unhandled key event to embedder
authorCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 13:46:47 +0000 (21:46 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 13:46:47 +0000 (21:46 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h

index 5d732cc97f3ca59b72da8aea69b5606a2423fe10..caddb2b3e6504967e52885017946444701299c2e 100644 (file)
@@ -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());
index 393fd4969d1626baa5fbba7eb39ae7c047a58b2e..90f45caf98261b99efe538a32c961689b0867d10 100644 (file)
@@ -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;