mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -05:00
Remove Object.create and promisifyAll. Fix #1297.
This commit is contained in:
parent
05e9f3a245
commit
374d47ab65
@ -1,9 +1,9 @@
|
||||
OmegaTarget = require('omega-target')
|
||||
Promise = OmegaTarget.Promise
|
||||
|
||||
chromeApiPromisifer = (originalMethod) ->
|
||||
exports.chromeApiPromisify = (target, method) ->
|
||||
return (args...) ->
|
||||
new Promise (resolve, reject) =>
|
||||
new Promise (resolve, reject) ->
|
||||
callback = (callbackArgs...) ->
|
||||
if chrome.runtime.lastError?
|
||||
error = new Error(chrome.runtime.lastError.message)
|
||||
@ -15,7 +15,4 @@ chromeApiPromisifer = (originalMethod) ->
|
||||
resolve(callbackArgs)
|
||||
|
||||
args.push(callback)
|
||||
originalMethod.apply(this, args)
|
||||
|
||||
module.exports = (obj) ->
|
||||
Promise.promisifyAll(Object.create(obj), {promisifier: chromeApiPromisifer})
|
||||
target[method].apply(target, args)
|
||||
|
@ -2,9 +2,12 @@ OcontextMenu_inspectElementmegaTarget = require('omega-target')
|
||||
OmegaPac = OmegaTarget.OmegaPac
|
||||
Promise = OmegaTarget.Promise
|
||||
querystring = require('querystring')
|
||||
chromeApiPromisifyAll = require('./chrome_api')
|
||||
chromeApiPromisify = require('./chrome_api').chromeApiPromisify
|
||||
if chrome?.proxy?.settings
|
||||
proxySettings = chromeApiPromisifyAll(chrome.proxy.settings)
|
||||
proxySettings =
|
||||
clearAsync: chromeApiPromisify(chrome.proxy.settings, 'clear')
|
||||
setAsync: chromeApiPromisify(chrome.proxy.settings, 'set')
|
||||
get: chrome.proxy.settings.get.bind(chrome.proxy.settings)
|
||||
else
|
||||
proxySettings =
|
||||
setAsync: -> Promise.resolve()
|
||||
@ -139,7 +142,7 @@ class ChromeOptions extends OmegaTarget.Options
|
||||
meta ?= profile
|
||||
if profile.profileType == 'SystemProfile'
|
||||
# Clear proxy settings, returning proxy control to Chromium.
|
||||
return proxySettings.clearAsync({}).then =>
|
||||
return chromeApiPromisify(chrome.proxy.settings, 'clear')({}).then =>
|
||||
proxySettings.get {}, @_proxyChangeListener
|
||||
return
|
||||
config = {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
chromeApiPromisifyAll = require('./chrome_api')
|
||||
chromeApiPromisify = require('./chrome_api').chromeApiPromisify
|
||||
OmegaTarget = require('omega-target')
|
||||
Promise = OmegaTarget.Promise
|
||||
|
||||
@ -39,12 +39,11 @@ class ChromeStorage extends OmegaTarget.Storage
|
||||
if browser?.storage?[@areaName]
|
||||
@storage = browser.storage[@areaName]
|
||||
else
|
||||
wrapper = chromeApiPromisifyAll(chrome.storage[@areaName])
|
||||
@storage =
|
||||
get: wrapper.getAsync.bind(wrapper),
|
||||
set: wrapper.setAsync.bind(wrapper),
|
||||
remove: wrapper.removeAsync.bind(wrapper),
|
||||
clear: wrapper.clearAsync.bind(wrapper),
|
||||
get: chromeApiPromisify(chrome.storage[@areaName], 'get')
|
||||
set: chromeApiPromisify(chrome.storage[@areaName], 'set')
|
||||
remove: chromeApiPromisify(chrome.storage[@areaName], 'remove')
|
||||
clear: chromeApiPromisify(chrome.storage[@areaName], 'clear')
|
||||
|
||||
get: (keys) ->
|
||||
keys ?= null
|
||||
|
Loading…
Reference in New Issue
Block a user