| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 window = sourceFrame->toImplBase()->frame()->domWindow(); | 55 window = sourceFrame->toImplBase()->frame()->domWindow(); |
| 56 MessagePortArray* ports = nullptr; | 56 MessagePortArray* ports = nullptr; |
| 57 if (!targetDocument.isNull()) { | 57 if (!targetDocument.isNull()) { |
| 58 Document* coreDocument = targetDocument; | 58 Document* coreDocument = targetDocument; |
| 59 ports = MessagePort::toMessagePortArray(coreDocument, channels); | 59 ports = MessagePort::toMessagePortArray(coreDocument, channels); |
| 60 } | 60 } |
| 61 // Use an empty array for |ports| when it is null because this function | 61 // Use an empty array for |ports| when it is null because this function |
| 62 // is used to implement postMessage(). | 62 // is used to implement postMessage(). |
| 63 if (!ports) | 63 if (!ports) |
| 64 ports = new MessagePortArray; | 64 ports = new MessagePortArray; |
| 65 // TODO(esprehn): Chromium always passes empty string for lastEventId, is that
right? | 65 // TODO(esprehn): Chromium always passes empty string for lastEventId, is that |
| 66 // right? |
| 66 unwrap<MessageEvent>()->initMessageEvent("message", false, false, messageData, | 67 unwrap<MessageEvent>()->initMessageEvent("message", false, false, messageData, |
| 67 origin, "" /*lastEventId*/, window, | 68 origin, "" /*lastEventId*/, window, |
| 68 ports); | 69 ports); |
| 69 } | 70 } |
| 70 | 71 |
| 71 WebSerializedScriptValue WebDOMMessageEvent::data() const { | 72 WebSerializedScriptValue WebDOMMessageEvent::data() const { |
| 72 return WebSerializedScriptValue( | 73 return WebSerializedScriptValue( |
| 73 constUnwrap<MessageEvent>()->dataAsSerializedScriptValue()); | 74 constUnwrap<MessageEvent>()->dataAsSerializedScriptValue()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 WebString WebDOMMessageEvent::origin() const { | 77 WebString WebDOMMessageEvent::origin() const { |
| 77 return WebString(constUnwrap<MessageEvent>()->origin()); | 78 return WebString(constUnwrap<MessageEvent>()->origin()); |
| 78 } | 79 } |
| 79 | 80 |
| 80 WebMessagePortChannelArray WebDOMMessageEvent::releaseChannels() { | 81 WebMessagePortChannelArray WebDOMMessageEvent::releaseChannels() { |
| 81 MessagePortChannelArray* channels = constUnwrap<MessageEvent>()->channels(); | 82 MessagePortChannelArray* channels = constUnwrap<MessageEvent>()->channels(); |
| 82 WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); | 83 WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); |
| 83 if (channels) { | 84 if (channels) { |
| 84 for (size_t i = 0; i < channels->size(); ++i) | 85 for (size_t i = 0; i < channels->size(); ++i) |
| 85 webChannels[i] = (*channels)[i].release(); | 86 webChannels[i] = (*channels)[i].release(); |
| 86 } | 87 } |
| 87 return webChannels; | 88 return webChannels; |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |