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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 #include "wtf/text/WTFString.h" | 105 #include "wtf/text/WTFString.h" |
106 #include <algorithm> | 106 #include <algorithm> |
107 | 107 |
108 using std::min; | 108 using std::min; |
109 using std::max; | 109 using std::max; |
110 | 110 |
111 namespace WebCore { | 111 namespace WebCore { |
112 | 112 |
113 class PostMessageTimer FINAL : public SuspendableTimer { | 113 class PostMessageTimer FINAL : public SuspendableTimer { |
114 public: | 114 public: |
115 PostMessageTimer(DOMWindow& window, PassRefPtr<SerializedScriptValue> messag e, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessageP ortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallSt ack> stackTrace) | 115 PostMessageTimer(DOMWindow& window, PassRefPtr<SerializedScriptValue> messag e, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessageP ortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallSt ack> stackTrace, bool userGesture) |
116 : SuspendableTimer(window.document()) | 116 : SuspendableTimer(window.document()) |
117 , m_window(window) | 117 , m_window(window) |
118 , m_message(message) | 118 , m_message(message) |
119 , m_origin(sourceOrigin) | 119 , m_origin(sourceOrigin) |
120 , m_source(source) | 120 , m_source(source) |
121 , m_channels(channels) | 121 , m_channels(channels) |
122 , m_targetOrigin(targetOrigin) | 122 , m_targetOrigin(targetOrigin) |
123 , m_stackTrace(stackTrace) | 123 , m_stackTrace(stackTrace) |
124 , m_userGesture(userGesture) | |
124 { | 125 { |
125 } | 126 } |
126 | 127 |
127 PassRefPtr<MessageEvent> event() | 128 PassRefPtr<MessageEvent> event() |
128 { | 129 { |
129 return MessageEvent::create(m_channels.release(), m_message, m_origin, S tring(), m_source); | 130 return MessageEvent::create(m_channels.release(), m_message, m_origin, S tring(), m_source); |
130 | 131 |
131 } | 132 } |
132 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } | 133 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } |
133 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } | 134 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } |
135 bool userGesture() const { return m_userGesture; } | |
134 | 136 |
135 private: | 137 private: |
136 virtual void fired() OVERRIDE | 138 virtual void fired() OVERRIDE |
137 { | 139 { |
138 m_window->postMessageTimerFired(adoptPtr(this)); | 140 m_window->postMessageTimerFired(adoptPtr(this)); |
139 // This object is deleted now. | 141 // This object is deleted now. |
140 } | 142 } |
141 | 143 |
142 RefPtr<DOMWindow> m_window; | 144 RefPtr<DOMWindow> m_window; |
143 RefPtr<SerializedScriptValue> m_message; | 145 RefPtr<SerializedScriptValue> m_message; |
144 String m_origin; | 146 String m_origin; |
145 RefPtr<DOMWindow> m_source; | 147 RefPtr<DOMWindow> m_source; |
146 OwnPtr<MessagePortChannelArray> m_channels; | 148 OwnPtr<MessagePortChannelArray> m_channels; |
147 RefPtr<SecurityOrigin> m_targetOrigin; | 149 RefPtr<SecurityOrigin> m_targetOrigin; |
148 RefPtr<ScriptCallStack> m_stackTrace; | 150 RefPtr<ScriptCallStack> m_stackTrace; |
151 bool m_userGesture; | |
149 }; | 152 }; |
150 | 153 |
151 static void disableSuddenTermination() | 154 static void disableSuddenTermination() |
152 { | 155 { |
153 blink::Platform::current()->suddenTerminationChanged(false); | 156 blink::Platform::current()->suddenTerminationChanged(false); |
154 } | 157 } |
155 | 158 |
156 static void enableSuddenTermination() | 159 static void enableSuddenTermination() |
157 { | 160 { |
158 blink::Platform::current()->suddenTerminationChanged(true); | 161 blink::Platform::current()->suddenTerminationChanged(true); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 if (!sourceDocument) | 848 if (!sourceDocument) |
846 return; | 849 return; |
847 String sourceOrigin = sourceDocument->securityOrigin()->toString(); | 850 String sourceOrigin = sourceDocument->securityOrigin()->toString(); |
848 | 851 |
849 // Capture stack trace only when inspector front-end is loaded as it may be time consuming. | 852 // Capture stack trace only when inspector front-end is loaded as it may be time consuming. |
850 RefPtr<ScriptCallStack> stackTrace; | 853 RefPtr<ScriptCallStack> stackTrace; |
851 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) | 854 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) |
852 stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCa pture, true); | 855 stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCa pture, true); |
853 | 856 |
854 // Schedule the message. | 857 // Schedule the message. |
855 PostMessageTimer* timer = new PostMessageTimer(*this, message, sourceOrigin, source, channels.release(), target.get(), stackTrace.release()); | 858 PostMessageTimer* timer = new PostMessageTimer(*this, message, sourceOrigin, source, channels.release(), target.get(), stackTrace.release(), UserGestureIndi cator::processingUserGesture()); |
856 timer->startOneShot(0, FROM_HERE); | 859 timer->startOneShot(0, FROM_HERE); |
857 timer->suspendIfNeeded(); | 860 timer->suspendIfNeeded(); |
858 } | 861 } |
859 | 862 |
860 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) | 863 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) |
861 { | 864 { |
862 OwnPtr<PostMessageTimer> timer(t); | 865 OwnPtr<PostMessageTimer> timer(t); |
863 | 866 |
864 if (!isCurrentlyDisplayedInFrame()) | 867 if (!isCurrentlyDisplayedInFrame()) |
865 return; | 868 return; |
866 | 869 |
867 RefPtr<MessageEvent> event = timer->event(); | 870 RefPtr<MessageEvent> event = timer->event(); |
868 | 871 |
869 // Give the embedder a chance to intercept this postMessage because this | 872 // Give the embedder a chance to intercept this postMessage because this |
870 // DOMWindow might be a proxy for another in browsers that support | 873 // DOMWindow might be a proxy for another in browsers that support |
871 // postMessage calls across WebKit instances. | 874 // postMessage calls across WebKit instances. |
872 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ etOrigin(), event.get())) | 875 if (m_frame->loader().client()->willCheckAndDispatchMessageEvent(timer->targ etOrigin(), event.get())) |
873 return; | 876 return; |
874 | 877 |
878 scoped_ptr<UserGestureIndicator> gesture; | |
879 if (timer->userGesture()) | |
880 gesture.reset(new UserGestureIndicator(DefinitelyProcessingNewUserGestur e)); | |
abarth-chromium
2014/03/24 17:39:47
As written, this CL is incorrect because if you ha
| |
881 | |
875 event->entangleMessagePorts(document()); | 882 event->entangleMessagePorts(document()); |
876 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace()); | 883 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta ckTrace()); |
877 } | 884 } |
878 | 885 |
879 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) | 886 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) |
880 { | 887 { |
881 if (intendedTargetOrigin) { | 888 if (intendedTargetOrigin) { |
882 // Check target origin now since the target document may have changed si nce the timer was scheduled. | 889 // Check target origin now since the target document may have changed si nce the timer was scheduled. |
883 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig in())) { | 890 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig in())) { |
884 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrig in()->toString() + "')."); | 891 String message = ExceptionMessages::failedToExecute("postMessage", " DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() + "') does not match the recipient window's origin ('" + document()->securityOrig in()->toString() + "')."); |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1861 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); | 1868 return static_cast<DOMWindowLifecycleNotifier&>(LifecycleContext<DOMWindow>: :lifecycleNotifier()); |
1862 } | 1869 } |
1863 | 1870 |
1864 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() | 1871 PassOwnPtr<LifecycleNotifier<DOMWindow> > DOMWindow::createLifecycleNotifier() |
1865 { | 1872 { |
1866 return DOMWindowLifecycleNotifier::create(this); | 1873 return DOMWindowLifecycleNotifier::create(this); |
1867 } | 1874 } |
1868 | 1875 |
1869 | 1876 |
1870 } // namespace WebCore | 1877 } // namespace WebCore |
OLD | NEW |