electron/atom/browser/api/lib/session.coffee
Cheng Zhao 1392873cbc Add session.defaultSession and remove app.defaultSession
The latter has never been a public API, no need to keep it.
2015-11-19 21:03:42 +08:00

23 lines
638 B
CoffeeScript

{EventEmitter} = require 'events'
bindings = process.atomBinding 'session'
PERSIST_PERFIX = 'persist:'
# Returns the Session from |partition| string.
exports.fromPartition = (partition='') ->
if partition.startsWith PERSIST_PERFIX
bindings.fromPartition partition.substr(PERSIST_PERFIX.length), false
else
bindings.fromPartition partition, true
# Returns the default session.
Object.defineProperty exports, 'defaultSession',
enumerable: true
get: -> exports.fromPartition ''
wrapSession = (session) ->
# session is an EventEmitter.
session.__proto__ = EventEmitter.prototype
bindings._setWrapSession wrapSession