Add session.defaultSession and remove app.defaultSession
The latter has never been a public API, no need to keep it.
This commit is contained in:
parent
47d7d49d19
commit
1392873cbc
5 changed files with 15 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
|||
electron = require 'electron'
|
||||
{deprecate, session, Menu} = require 'electron'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
bindings = process.atomBinding 'app'
|
||||
|
@ -8,10 +8,10 @@ app = bindings.app
|
|||
app.__proto__ = EventEmitter.prototype
|
||||
|
||||
app.setApplicationMenu = (menu) ->
|
||||
electron.Menu.setApplicationMenu menu
|
||||
Menu.setApplicationMenu menu
|
||||
|
||||
app.getApplicationMenu = ->
|
||||
electron.Menu.getApplicationMenu()
|
||||
Menu.getApplicationMenu()
|
||||
|
||||
app.commandLine =
|
||||
appendSwitch: bindings.appendSwitch,
|
||||
|
@ -35,7 +35,8 @@ app.getAppPath = ->
|
|||
appPath
|
||||
|
||||
# Helpers.
|
||||
app.resolveProxy = (url, callback) -> @defaultSession.resolveProxy url, callback
|
||||
app.resolveProxy = (url, callback) ->
|
||||
session.defaultSession.resolveProxy url, callback
|
||||
|
||||
# Routes the events to webContents.
|
||||
for name in ['login', 'certificate-error', 'select-client-certificate']
|
||||
|
@ -44,7 +45,6 @@ for name in ['login', 'certificate-error', 'select-client-certificate']
|
|||
webContents.emit name, event, args...
|
||||
|
||||
# Deprecated.
|
||||
{deprecate} = electron
|
||||
app.getHomeDir = deprecate 'app.getHomeDir', 'app.getPath', ->
|
||||
@getPath 'home'
|
||||
app.getDataPath = deprecate 'app.getDataPath', 'app.getPath', ->
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{app, ipcMain, deprecate} = require 'electron'
|
||||
{ipcMain, deprecate} = require 'electron'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
{BrowserWindow} = process.atomBinding 'window'
|
||||
BrowserWindow::__proto__ = EventEmitter.prototype
|
||||
|
||||
BrowserWindow::_init = ->
|
||||
{app} = require 'electron' # avoid recursive require.
|
||||
|
||||
# Simulate the application menu on platforms other than OS X.
|
||||
if process.platform isnt 'darwin'
|
||||
menu = app.getApplicationMenu()
|
||||
|
|
|
@ -4,12 +4,18 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue