| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 : m_window(window) | 110 : m_window(window) |
| 111 , m_message(message) | 111 , m_message(message) |
| 112 , m_origin(sourceOrigin) | 112 , m_origin(sourceOrigin) |
| 113 , m_source(source) | 113 , m_source(source) |
| 114 , m_channels(channels) | 114 , m_channels(channels) |
| 115 , m_targetOrigin(targetOrigin) | 115 , m_targetOrigin(targetOrigin) |
| 116 , m_stackTrace(stackTrace) | 116 , m_stackTrace(stackTrace) |
| 117 { | 117 { |
| 118 } | 118 } |
| 119 | 119 |
| 120 PassRefPtr<MessageEvent> event(ExecutionContext* context) | 120 PassRefPtr<MessageEvent> event() |
| 121 { | 121 { |
| 122 OwnPtr<MessagePortArray> messagePorts = MessagePort::entanglePorts(*cont
ext, m_channels.release()); | 122 return MessageEvent::create(m_channels.release(), m_message, m_origin, S
tring(), m_source); |
| 123 return MessageEvent::create(messagePorts.release(), m_message, m_origin,
String(), m_source); | 123 |
| 124 } | 124 } |
| 125 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } | 125 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } |
| 126 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } | 126 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 virtual void fired() | 129 virtual void fired() |
| 130 { | 130 { |
| 131 m_window->postMessageTimerFired(adoptPtr(this)); | 131 m_window->postMessageTimerFired(adoptPtr(this)); |
| 132 // This object is deleted now. | 132 // This object is deleted now. |
| 133 } | 133 } |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 timer->startOneShot(0); | 776 timer->startOneShot(0); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) | 779 void DOMWindow::postMessageTimerFired(PassOwnPtr<PostMessageTimer> t) |
| 780 { | 780 { |
| 781 OwnPtr<PostMessageTimer> timer(t); | 781 OwnPtr<PostMessageTimer> timer(t); |
| 782 | 782 |
| 783 if (!document() || !isCurrentlyDisplayedInFrame()) | 783 if (!document() || !isCurrentlyDisplayedInFrame()) |
| 784 return; | 784 return; |
| 785 | 785 |
| 786 RefPtr<MessageEvent> event = timer->event(document()); | 786 RefPtr<MessageEvent> event = timer->event(); |
| 787 | 787 |
| 788 // Give the embedder a chance to intercept this postMessage because this | 788 // Give the embedder a chance to intercept this postMessage because this |
| 789 // DOMWindow might be a proxy for another in browsers that support | 789 // DOMWindow might be a proxy for another in browsers that support |
| 790 // postMessage calls across WebKit instances. | 790 // postMessage calls across WebKit instances. |
| 791 if (m_frame->loader()->client()->willCheckAndDispatchMessageEvent(timer->tar
getOrigin(), event.get())) | 791 if (m_frame->loader()->client()->willCheckAndDispatchMessageEvent(timer->tar
getOrigin(), event.get())) |
| 792 return; | 792 return; |
| 793 | 793 |
| 794 event->entangleMessagePorts(document()); |
| 794 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); | 795 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); |
| 795 } | 796 } |
| 796 | 797 |
| 797 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) | 798 void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
etOrigin, PassRefPtr<Event> event, PassRefPtr<ScriptCallStack> stackTrace) |
| 798 { | 799 { |
| 799 if (intendedTargetOrigin) { | 800 if (intendedTargetOrigin) { |
| 800 // Check target origin now since the target document may have changed si
nce the timer was scheduled. | 801 // Check target origin now since the target document may have changed si
nce the timer was scheduled. |
| 801 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig
in())) { | 802 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig
in())) { |
| 802 String message = "Unable to post message to " + intendedTargetOrigin
->toString() + | 803 String message = "Unable to post message to " + intendedTargetOrigin
->toString() + |
| 803 ". Recipient has origin " + document()->securityOri
gin()->toString() + ".\n"; | 804 ". Recipient has origin " + document()->securityOri
gin()->toString() + ".\n"; |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN
otifier()); | 1767 return static_cast<DOMWindowLifecycleNotifier*>(LifecycleContext::lifecycleN
otifier()); |
| 1767 } | 1768 } |
| 1768 | 1769 |
| 1769 PassOwnPtr<LifecycleNotifier> DOMWindow::createLifecycleNotifier() | 1770 PassOwnPtr<LifecycleNotifier> DOMWindow::createLifecycleNotifier() |
| 1770 { | 1771 { |
| 1771 return DOMWindowLifecycleNotifier::create(this); | 1772 return DOMWindowLifecycleNotifier::create(this); |
| 1772 } | 1773 } |
| 1773 | 1774 |
| 1774 | 1775 |
| 1775 } // namespace WebCore | 1776 } // namespace WebCore |
| OLD | NEW |