Fixes after code review.

This commit is contained in:
Bundyo 2015-03-04 11:29:52 +02:00
parent e8d648bcba
commit dbbc35bd13
2 changed files with 15 additions and 17 deletions

View file

@ -32,9 +32,9 @@ createGuest = (embedder, url, frameName, options) ->
guest.once 'closed', -> guest.once 'closed', ->
delete frameToGuest[frameName] delete frameToGuest[frameName]
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, method, args...) -> ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, message, targetOrigin) ->
if embedder.getUrl().indexOf(args[1]) is 0 or args[1] is '*' if embedder.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*'
embedder.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', args[0], args[1] embedder.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', message, targetOrigin
guest.id guest.id
@ -55,11 +55,11 @@ ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', (event, guestId, method,
return unless BrowserWindow.windows.has guestId return unless BrowserWindow.windows.has guestId
BrowserWindow.windows.get(guestId)[method] args... BrowserWindow.windows.get(guestId)[method] args...
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (event, guestId, method, args...) -> ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (event, guestId, message, targetOrigin) ->
return unless BrowserWindow.windows.has guestId return unless BrowserWindow.windows.has guestId
window = BrowserWindow.windows.get(guestId) window = BrowserWindow.windows.get(guestId)
if window.getUrl().indexOf(args[1]) is 0 or args[1] is '*' if window.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*'
window.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', args[0], args[1] window.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', message, targetOrigin
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', (event, guestId, method, args...) -> ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', (event, guestId, method, args...) ->
return unless BrowserWindow.windows.has guestId return unless BrowserWindow.windows.has guestId

View file

@ -5,11 +5,9 @@ remote = require 'remote'
# Window object returned by "window.open". # Window object returned by "window.open".
class FakeWindow class FakeWindow
constructor: (@guestId) -> constructor: (@guestId) ->
that = this ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', (guestId) =>
if guestId is @guestId
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', (guestId) -> @closed = true
if guestId is that.guestId
that.closed = true
close: -> close: ->
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', @guestId ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', @guestId
@ -20,8 +18,8 @@ class FakeWindow
blur: -> blur: ->
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', @guestId, 'blur' ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', @guestId, 'blur'
postMessage: (args...) -> postMessage: (message, targetOrigin) ->
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', @guestId, 'postMessage', args[0], args[1] ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', @guestId, message, targetOrigin
eval: (args...) -> eval: (args...) ->
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', @guestId, 'executeJavaScript', args... ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', @guestId, 'executeJavaScript', args...
@ -73,8 +71,8 @@ window.prompt = ->
throw new Error('prompt() is and will not be supported in atom-shell.') throw new Error('prompt() is and will not be supported in atom-shell.')
window.opener = window.opener =
postMessage: (args...) -> postMessage: (message, targetOrigin) ->
ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', 'postMessage', args[0], args[1] ipc.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', message, targetOrigin
ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (data, origin) -> ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (message, targetOrigin) ->
window.postMessage(data, origin) window.postMessage(message, targetOrigin)