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