Add remote.getCurrentWebContents API
This commit is contained in:
parent
fc2bc20572
commit
4c10925694
3 changed files with 15 additions and 1 deletions
|
@ -107,6 +107,9 @@ ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, guestInstanceId) ->
|
||||||
catch e
|
catch e
|
||||||
event.returnValue = errorToMeta e
|
event.returnValue = errorToMeta e
|
||||||
|
|
||||||
|
ipc.on 'ATOM_BROWSER_CURRENT_WEB_CONTENTS', (event) ->
|
||||||
|
event.returnValue = valueToMeta event.sender, event.sender
|
||||||
|
|
||||||
ipc.on 'ATOM_BROWSER_CONSTRUCTOR', (event, id, args) ->
|
ipc.on 'ATOM_BROWSER_CONSTRUCTOR', (event, id, args) ->
|
||||||
try
|
try
|
||||||
args = unwrapArgs event.sender, args
|
args = unwrapArgs event.sender, args
|
||||||
|
|
|
@ -110,13 +110,20 @@ exports.require = (module) ->
|
||||||
meta = ipc.sendSync 'ATOM_BROWSER_REQUIRE', module
|
meta = ipc.sendSync 'ATOM_BROWSER_REQUIRE', module
|
||||||
moduleCache[module] = metaToValue meta
|
moduleCache[module] = metaToValue meta
|
||||||
|
|
||||||
# Get current window object.
|
# Get current BrowserWindow object.
|
||||||
windowCache = null
|
windowCache = null
|
||||||
exports.getCurrentWindow = ->
|
exports.getCurrentWindow = ->
|
||||||
return windowCache if windowCache?
|
return windowCache if windowCache?
|
||||||
meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WINDOW', process.guestInstanceId
|
meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WINDOW', process.guestInstanceId
|
||||||
windowCache = metaToValue meta
|
windowCache = metaToValue meta
|
||||||
|
|
||||||
|
# Get current WebContents object.
|
||||||
|
webContentsCache = null
|
||||||
|
exports.getCurrentWebContents = ->
|
||||||
|
return webContentsCache if webContentsCache?
|
||||||
|
meta = ipc.sendSync 'ATOM_BROWSER_CURRENT_WEB_CONTENTS'
|
||||||
|
webContentsCache = metaToValue meta
|
||||||
|
|
||||||
# Get a global object in browser.
|
# Get a global object in browser.
|
||||||
exports.getGlobal = (name) ->
|
exports.getGlobal = (name) ->
|
||||||
meta = ipc.sendSync 'ATOM_BROWSER_GLOBAL', name
|
meta = ipc.sendSync 'ATOM_BROWSER_GLOBAL', name
|
||||||
|
|
|
@ -138,6 +138,10 @@ Returns the object returned by `require(module)` in the main process.
|
||||||
Returns the [BrowserWindow](browser-window.md) object which this web page
|
Returns the [BrowserWindow](browser-window.md) object which this web page
|
||||||
belongs to.
|
belongs to.
|
||||||
|
|
||||||
|
## remote.getCurrentWebContent()
|
||||||
|
|
||||||
|
Returns the WebContents object of this web page.
|
||||||
|
|
||||||
## remote.getGlobal(name)
|
## remote.getGlobal(name)
|
||||||
|
|
||||||
* `name` String
|
* `name` String
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue