Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: Source/web/WebDOMMessageEvent.cpp

Issue 1289033003: Start changing WebDOMMessageEvent for using target execution context. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address code review Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | public/web/WebDOMMessageEvent.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebDOMMessageEvent.cpp
diff --git a/Source/web/WebDOMMessageEvent.cpp b/Source/web/WebDOMMessageEvent.cpp
index 573ae5495198011867ed41ef341f4c9b3239de4f..3e172dc5af2a526033273f70d87a73216d2ccab3 100644
--- a/Source/web/WebDOMMessageEvent.cpp
+++ b/Source/web/WebDOMMessageEvent.cpp
@@ -37,24 +37,25 @@
#include "core/events/MessageEvent.h"
#include "core/frame/LocalDOMWindow.h"
#include "public/platform/WebString.h"
+#include "public/web/WebDocument.h"
#include "public/web/WebFrame.h"
#include "public/web/WebSerializedScriptValue.h"
#include "web/WebLocalFrameImpl.h"
namespace blink {
-void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMessagePortChannelArray& webChannels)
+void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebDocument& targetDocument, const WebString& lastEventId, const WebMessagePortChannelArray& webChannels)
{
ASSERT(m_private.get());
ASSERT(isMessageEvent());
DOMWindow* window = nullptr;
- // TODO(alexmos): Figure out if this is the right thing to do.
if (sourceFrame)
window = toCoreFrame(sourceFrame)->domWindow();
MessagePortArray* ports = nullptr;
- // TODO(alexmos): make ports work properly with OOPIF.
- if (sourceFrame && sourceFrame->isWebLocalFrame())
- ports = MessagePort::toMessagePortArray(toLocalDOMWindow(window)->document(), webChannels);
+ if (!targetDocument.isNull()) {
+ RefPtrWillBeRawPtr<Document> coreDocument = PassRefPtrWillBeRawPtr<Document>(targetDocument);
+ ports = MessagePort::toMessagePortArray(coreDocument.get(), webChannels);
+ }
// Use an empty array for |ports| when it is null because this function
// is used to implement postMessage().
if (!ports)
@@ -62,6 +63,16 @@ void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble,
unwrap<MessageEvent>()->initMessageEvent(type, canBubble, cancelable, messageData, origin, lastEventId, window, ports);
}
+void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMessagePortChannelArray& webChannels)
+{
+ WebDocument document;
+ if (sourceFrame && sourceFrame->isWebLocalFrame()) {
+ DOMWindow* window = toCoreFrame(sourceFrame)->domWindow();
+ document = toLocalDOMWindow(window)->document();
+ }
+ initMessageEvent(type, canBubble, cancelable, messageData, origin, sourceFrame, document, lastEventId, webChannels);
+}
+
WebSerializedScriptValue WebDOMMessageEvent::data() const
{
return WebSerializedScriptValue(constUnwrap<MessageEvent>()->dataAsSerializedScriptValue());
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | public/web/WebDOMMessageEvent.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698