OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 #include "wtf/text/WTFString.h" | 108 #include "wtf/text/WTFString.h" |
109 #include <algorithm> | 109 #include <algorithm> |
110 | 110 |
111 using std::min; | 111 using std::min; |
112 using std::max; | 112 using std::max; |
113 | 113 |
114 namespace WebCore { | 114 namespace WebCore { |
115 | 115 |
116 class PostMessageTimer FINAL : public SuspendableTimer { | 116 class PostMessageTimer FINAL : public SuspendableTimer { |
117 public: | 117 public: |
118 PostMessageTimer(DOMWindow& window, PassRefPtr<SerializedScriptValue> messag
e, const String& sourceOrigin, PassRefPtrWillBeRawPtr<DOMWindow> source, PassOwn
Ptr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<
ScriptCallStack> stackTrace, UserGestureToken* userGestureToken) | 118 PostMessageTimer(DOMWindow& window, PassRefPtr<SerializedScriptValue> messag
e, const String& sourceOrigin, PassRefPtrWillBeRawPtr<DOMWindow> source, PassOwn
Ptr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtrW
illBeRawPtr<ScriptCallStack> stackTrace, UserGestureToken* userGestureToken) |
119 : SuspendableTimer(window.document()) | 119 : SuspendableTimer(window.document()) |
120 , m_window(window) | 120 , m_window(window) |
121 , m_message(message) | 121 , m_message(message) |
122 , m_origin(sourceOrigin) | 122 , m_origin(sourceOrigin) |
123 , m_source(source) | 123 , m_source(source) |
124 , m_channels(channels) | 124 , m_channels(channels) |
125 , m_targetOrigin(targetOrigin) | 125 , m_targetOrigin(targetOrigin) |
126 , m_stackTrace(stackTrace) | 126 , m_stackTrace(stackTrace) |
127 , m_userGestureToken(userGestureToken) | 127 , m_userGestureToken(userGestureToken) |
128 { | 128 { |
(...skipping 14 matching lines...) Expand all Loading... |
143 m_window->postMessageTimerFired(adoptPtr(this)); | 143 m_window->postMessageTimerFired(adoptPtr(this)); |
144 // This object is deleted now. | 144 // This object is deleted now. |
145 } | 145 } |
146 | 146 |
147 RefPtrWillBePersistent<DOMWindow> m_window; | 147 RefPtrWillBePersistent<DOMWindow> m_window; |
148 RefPtr<SerializedScriptValue> m_message; | 148 RefPtr<SerializedScriptValue> m_message; |
149 String m_origin; | 149 String m_origin; |
150 RefPtrWillBePersistent<DOMWindow> m_source; | 150 RefPtrWillBePersistent<DOMWindow> m_source; |
151 OwnPtr<MessagePortChannelArray> m_channels; | 151 OwnPtr<MessagePortChannelArray> m_channels; |
152 RefPtr<SecurityOrigin> m_targetOrigin; | 152 RefPtr<SecurityOrigin> m_targetOrigin; |
153 RefPtr<ScriptCallStack> m_stackTrace; | 153 RefPtrWillBePersistent<ScriptCallStack> m_stackTrace; |
154 RefPtr<UserGestureToken> m_userGestureToken; | 154 RefPtr<UserGestureToken> m_userGestureToken; |
155 }; | 155 }; |
156 | 156 |
157 static void disableSuddenTermination() | 157 static void disableSuddenTermination() |
158 { | 158 { |
159 blink::Platform::current()->suddenTerminationChanged(false); | 159 blink::Platform::current()->suddenTerminationChanged(false); |
160 } | 160 } |
161 | 161 |
162 static void enableSuddenTermination() | 162 static void enableSuddenTermination() |
163 { | 163 { |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 if (!sourceDocument) | 852 if (!sourceDocument) |
853 return; | 853 return; |
854 String sourceOrigin = sourceDocument->securityOrigin()->toString(); | 854 String sourceOrigin = sourceDocument->securityOrigin()->toString(); |
855 | 855 |
856 if (MixedContentChecker::isMixedContent(sourceDocument->securityOrigin(), do
cument()->url())) | 856 if (MixedContentChecker::isMixedContent(sourceDocument->securityOrigin(), do
cument()->url())) |
857 UseCounter::count(document(), UseCounter::PostMessageFromSecureToInsecur
e); | 857 UseCounter::count(document(), UseCounter::PostMessageFromSecureToInsecur
e); |
858 else if (MixedContentChecker::isMixedContent(document()->securityOrigin(), s
ourceDocument->url())) | 858 else if (MixedContentChecker::isMixedContent(document()->securityOrigin(), s
ourceDocument->url())) |
859 UseCounter::count(document(), UseCounter::PostMessageFromInsecureToSecur
e); | 859 UseCounter::count(document(), UseCounter::PostMessageFromInsecureToSecur
e); |
860 | 860 |
861 // Capture stack trace only when inspector front-end is loaded as it may be
time consuming. | 861 // Capture stack trace only when inspector front-end is loaded as it may be
time consuming. |
862 RefPtr<ScriptCallStack> stackTrace; | 862 RefPtrWillBeRawPtr<ScriptCallStack> stackTrace = nullptr; |
863 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) | 863 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) |
864 stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCa
pture, true); | 864 stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCa
pture, true); |
865 | 865 |
866 // Schedule the message. | 866 // Schedule the message. |
867 PostMessageTimer* timer = new PostMessageTimer(*this, message, sourceOrigin,
source, channels.release(), target.get(), stackTrace.release(), UserGestureIndi
cator::currentToken()); | 867 PostMessageTimer* timer = new PostMessageTimer(*this, message, sourceOrigin,
source, channels.release(), target.get(), stackTrace.release(), UserGestureIndi
cator::currentToken()); |
868 timer->startOneShot(0, FROM_HERE); | 868 timer->startOneShot(0, FROM_HERE); |
869 timer->suspendIfNeeded(); | 869 timer->suspendIfNeeded(); |
870 } | 870 } |
871 | 871 |
872 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) | 872 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) |
(...skipping 10 matching lines...) Expand all Loading... |
883 // postMessage calls across WebKit instances. | 883 // postMessage calls across WebKit instances. |
884 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ
etOrigin(), event.get())) | 884 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ
etOrigin(), event.get())) |
885 return; | 885 return; |
886 | 886 |
887 UserGestureIndicator gestureIndicator(timer->userGestureToken()); | 887 UserGestureIndicator gestureIndicator(timer->userGestureToken()); |
888 | 888 |
889 event->entangleMessagePorts(document()); | 889 event->entangleMessagePorts(document()); |
890 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); | 890 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); |
891 } | 891 } |
892 | 892 |
893 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
etOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtr<ScriptCallStack> stack
Trace) | 893 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
etOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtrWillBeRawPtr<ScriptCall
Stack> stackTrace) |
894 { | 894 { |
895 if (intendedTargetOrigin) { | 895 if (intendedTargetOrigin) { |
896 // Check target origin now since the target document may have changed si
nce the timer was scheduled. | 896 // Check target origin now since the target document may have changed si
nce the timer was scheduled. |
897 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig
in())) { | 897 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig
in())) { |
898 String message = ExceptionMessages::failedToExecute("postMessage", "
DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() +
"') does not match the recipient window's origin ('" + document()->securityOrig
in()->toString() + "')."); | 898 String message = ExceptionMessages::failedToExecute("postMessage", "
DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() +
"') does not match the recipient window's origin ('" + document()->securityOrig
in()->toString() + "')."); |
899 frameConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel,
message, stackTrace); | 899 frameConsole()->addMessage(SecurityMessageSource, ErrorMessageLevel,
message, stackTrace); |
900 return; | 900 return; |
901 } | 901 } |
902 } | 902 } |
903 | 903 |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 visitor->trace(m_sessionStorage); | 1921 visitor->trace(m_sessionStorage); |
1922 visitor->trace(m_localStorage); | 1922 visitor->trace(m_localStorage); |
1923 visitor->trace(m_applicationCache); | 1923 visitor->trace(m_applicationCache); |
1924 visitor->trace(m_performance); | 1924 visitor->trace(m_performance); |
1925 visitor->trace(m_css); | 1925 visitor->trace(m_css); |
1926 WillBeHeapSupplementable<DOMWindow>::trace(visitor); | 1926 WillBeHeapSupplementable<DOMWindow>::trace(visitor); |
1927 EventTargetWithInlineData::trace(visitor); | 1927 EventTargetWithInlineData::trace(visitor); |
1928 } | 1928 } |
1929 | 1929 |
1930 } // namespace WebCore | 1930 } // namespace WebCore |
OLD | NEW |