diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 3db4582abc7c..9f9f5811d76a 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -2,7 +2,6 @@ electron = require 'electron' {EventEmitter} = require 'events' bindings = process.atomBinding 'app' -sessionBindings = process.atomBinding 'session' downloadItemBindings = process.atomBinding 'download_item' app = bindings.app @@ -61,11 +60,6 @@ deprecate.event app, 'activate-with-no-open-windows', 'activate', (event, hasVis deprecate.event app, 'select-certificate', 'select-client-certificate' # Wrappers for native classes. -wrapSession = (session) -> - # session is an EventEmitter. - session.__proto__ = EventEmitter.prototype -sessionBindings._setWrapSession wrapSession - wrapDownloadItem = (downloadItem) -> # downloadItem is an EventEmitter. downloadItem.__proto__ = EventEmitter.prototype diff --git a/atom/browser/api/lib/exports/electron.coffee b/atom/browser/api/lib/exports/electron.coffee index f0c3b87c987b..3f7d9b1a13fe 100644 --- a/atom/browser/api/lib/exports/electron.coffee +++ b/atom/browser/api/lib/exports/electron.coffee @@ -42,6 +42,9 @@ Object.defineProperties module.exports, screen: enumerable: true get: -> require '../screen' + session: + enumerable: true + get: -> require '../session' Tray: enumerable: true get: -> require '../tray' diff --git a/atom/browser/api/lib/session.coffee b/atom/browser/api/lib/session.coffee new file mode 100644 index 000000000000..e0fc7b6e0bca --- /dev/null +++ b/atom/browser/api/lib/session.coffee @@ -0,0 +1,17 @@ +{EventEmitter} = require 'events' + +bindings = process.atomBinding 'session' + +PERSIST_PERFIX = 'persist:' + +exports.fromPartition = (partition='') -> + if partition.startsWith PERSIST_PERFIX + bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false + else + bindings.fromPartition partition, true + +wrapSession = (session) -> + # session is an EventEmitter. + session.__proto__ = EventEmitter.prototype + +bindings._setWrapSession wrapSession diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index 1a224c7416f5..335928dcea81 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -1,5 +1,5 @@ {EventEmitter} = require 'events' -{deprecate, ipcMain, NavigationController, Menu} = require 'electron' +{deprecate, ipcMain, session, NavigationController, Menu} = require 'electron' binding = process.atomBinding 'web_contents' diff --git a/filenames.gypi b/filenames.gypi index 7e1f3e1827e0..7157079178ee 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -26,6 +26,7 @@ 'atom/browser/api/lib/power-monitor.coffee', 'atom/browser/api/lib/power-save-blocker.coffee', 'atom/browser/api/lib/protocol.coffee', + 'atom/browser/api/lib/session.coffee', 'atom/browser/api/lib/screen.coffee', 'atom/browser/api/lib/tray.coffee', 'atom/browser/api/lib/web-contents.coffee',