Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "public/web/WebDOMMessageEvent.h" | 32 #include "public/web/WebDOMMessageEvent.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/SerializedScriptValue.h" | 34 #include "bindings/core/v8/SerializedScriptValue.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/MessagePort.h" | 36 #include "core/dom/MessagePort.h" |
| 37 #include "core/events/MessageEvent.h" | 37 #include "core/events/MessageEvent.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 38 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "public/platform/WebString.h" | 39 #include "public/platform/WebString.h" |
| 40 #include "public/web/WebDocument.h" | |
| 40 #include "public/web/WebFrame.h" | 41 #include "public/web/WebFrame.h" |
| 41 #include "public/web/WebSerializedScriptValue.h" | 42 #include "public/web/WebSerializedScriptValue.h" |
| 42 #include "web/WebLocalFrameImpl.h" | 43 #include "web/WebLocalFrameImpl.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 47 void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebDocument& targetDocument, const We bString& lastEventId, const WebMessagePortChannelArray& webChannels) | |
| 48 { | |
| 49 ASSERT(m_private.get()); | |
| 50 ASSERT(isMessageEvent()); | |
| 51 DOMWindow* window = nullptr; | |
| 52 // TODO(alexmos): Figure out if this is the right thing to do. | |
|
adamk
2015/08/15 00:01:15
Would hate to leave this TODO in the new version.
alexmos
2015/08/15 01:07:02
I think we can just remove this. dcheng@ original
sgurun-gerrit only
2015/08/15 01:12:11
Done.
| |
| 53 if (sourceFrame) | |
| 54 window = toCoreFrame(sourceFrame)->domWindow(); | |
| 55 RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document> (targetDocument); | |
| 56 MessagePortArray* ports = MessagePort::toMessagePortArray(coreDocument.get() , webChannels); | |
| 57 // Use an empty array for |ports| when it is null because this function | |
| 58 // is used to implement postMessage(). | |
| 59 if (!ports) | |
| 60 ports = new MessagePortArray; | |
| 61 unwrap<MessageEvent>()->initMessageEvent(type, canBubble, cancelable, messag eData, origin, lastEventId, window, ports); | |
| 62 } | |
| 63 | |
| 46 void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMess agePortChannelArray& webChannels) | 64 void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMess agePortChannelArray& webChannels) |
| 47 { | 65 { |
| 48 ASSERT(m_private.get()); | 66 ASSERT(m_private.get()); |
| 49 ASSERT(isMessageEvent()); | 67 ASSERT(isMessageEvent()); |
| 50 DOMWindow* window = nullptr; | 68 DOMWindow* window = nullptr; |
| 51 // TODO(alexmos): Figure out if this is the right thing to do. | 69 // TODO(alexmos): Figure out if this is the right thing to do. |
| 52 if (sourceFrame) | 70 if (sourceFrame) |
| 53 window = toCoreFrame(sourceFrame)->domWindow(); | 71 window = toCoreFrame(sourceFrame)->domWindow(); |
| 54 MessagePortArray* ports = nullptr; | 72 MessagePortArray* ports = nullptr; |
| 55 // TODO(alexmos): make ports work properly with OOPIF. | 73 // TODO(alexmos): make ports work properly with OOPIF. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 77 MessagePortChannelArray* channels = constUnwrap<MessageEvent>()->channels(); | 95 MessagePortChannelArray* channels = constUnwrap<MessageEvent>()->channels(); |
| 78 WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); | 96 WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); |
| 79 if (channels) { | 97 if (channels) { |
| 80 for (size_t i = 0; i < channels->size(); ++i) | 98 for (size_t i = 0; i < channels->size(); ++i) |
| 81 webChannels[i] = (*channels)[i].leakPtr(); | 99 webChannels[i] = (*channels)[i].leakPtr(); |
| 82 } | 100 } |
| 83 return webChannels; | 101 return webChannels; |
| 84 } | 102 } |
| 85 | 103 |
| 86 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |