]> khamidou — GitHub mirrors - electron.git/commitdiff
Add webContents.focus
authorCheng Zhao <zcbenz@gmail.com>
Fri, 24 Jul 2015 04:58:28 +0000 (12:58 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 24 Jul 2015 04:58:28 +0000 (12:58 +0800)
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h

index 4bd1e9b6d6e826a23a751bc6e50216aa9dc5b79d..b79338548063045af226bec5210d1dfc2f9bb999 100644 (file)
@@ -733,6 +733,14 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
   web_contents()->ReplaceMisspelling(word);
 }
 
+void WebContents::Focus() {
+  web_contents()->Focus();
+}
+
+void WebContents::TabTraverse(bool reverse) {
+  web_contents()->FocusThroughTabTraversal(reverse);
+}
+
 bool WebContents::SendIPCMessage(const base::string16& channel,
                                  const base::ListValue& args) {
   return Send(new AtomViewMsg_Message(routing_id(), channel, args));
@@ -792,6 +800,8 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
         .SetMethod("unselect", &WebContents::Unselect)
         .SetMethod("replace", &WebContents::Replace)
         .SetMethod("replaceMisspelling", &WebContents::ReplaceMisspelling)
+        .SetMethod("focus", &WebContents::Focus)
+        .SetMethod("tabTraverse", &WebContents::TabTraverse)
         .SetMethod("_send", &WebContents::SendIPCMessage, true)
         .SetMethod("setSize", &WebContents::SetSize)
         .SetMethod("setAllowTransparency", &WebContents::SetAllowTransparency)
index e3dc363972d446eb5431fe3e4cd98bd56fc39c73..1dcf5f4f6d2936749525b5dd7fb2b5d077994131 100644 (file)
@@ -96,6 +96,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
   void Replace(const base::string16& word);
   void ReplaceMisspelling(const base::string16& word);
 
+  // Focus.
+  void Focus();
+  void TabTraverse(bool reverse);
+
   // Sending messages to browser.
   bool SendIPCMessage(const base::string16& channel,
                       const base::ListValue& args);