From dfe7ae21249b02bbeee00501813ddca3c9e094a0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 28 May 2016 10:10:24 +0900 Subject: [PATCH] Add webContents.fromId --- atom/browser/api/atom_api_web_contents.cc | 2 ++ lib/browser/api/web-contents.js | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index b38362972e01..9f447f8e34e4 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1344,6 +1344,8 @@ void Initialize(v8::Local exports, v8::Local unused, mate::Dictionary dict(isolate, exports); dict.SetMethod("create", &atom::api::WebContents::Create); dict.SetMethod("_setWrapWebContents", &atom::api::SetWrapWebContents); + dict.SetMethod("fromId", + &mate::TrackableObject::FromWeakMapID); } } // namespace diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 03697199836e..1b601f095dbb 100644 --- a/lib/browser/api/web-contents.js +++ b/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) }