Browse Source

Add webContents.fromId

Cheng Zhao 9 years ago
parent
commit
dfe7ae2124
2 changed files with 9 additions and 4 deletions
  1. 2 0
      atom/browser/api/atom_api_web_contents.cc
  2. 7 4
      lib/browser/api/web-contents.js

+ 2 - 0
atom/browser/api/atom_api_web_contents.cc

@@ -1344,6 +1344,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
   mate::Dictionary dict(isolate, exports);
   dict.SetMethod("create", &atom::api::WebContents::Create);
   dict.SetMethod("_setWrapWebContents", &atom::api::SetWrapWebContents);
+  dict.SetMethod("fromId",
+                 &mate::TrackableObject<atom::api::WebContents>::FromWeakMapID);
 }
 
 }  // namespace

+ 7 - 4
lib/browser/api/web-contents.js

@@ -226,9 +226,12 @@ binding._setWrapWebContents(wrapWebContents)
 debuggerBinding._setWrapDebugger(wrapDebugger)
 sessionBinding._setWrapSession(wrapSession)
 
-module.exports.create = function (options) {
-  if (options == null) {
-    options = {}
+module.exports = {
+  create (options = {}) {
+    return binding.create(options)
+  },
+
+  fromId (id) {
+    return binding.fromId(id)
   }
-  return binding.create(options)
 }