| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 , m_stackTrace(stackTrace) | 119 , m_stackTrace(stackTrace) |
| 120 , m_userGestureToken(userGestureToken) | 120 , m_userGestureToken(userGestureToken) |
| 121 { | 121 { |
| 122 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti
ng(executionContext(), "postMessage"); | 122 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti
ng(executionContext(), "postMessage"); |
| 123 } | 123 } |
| 124 | 124 |
| 125 PassRefPtrWillBeRawPtr<MessageEvent> event() const { return m_event.get(); } | 125 PassRefPtrWillBeRawPtr<MessageEvent> event() const { return m_event.get(); } |
| 126 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } | 126 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } |
| 127 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } | 127 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } |
| 128 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } | 128 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } |
| 129 virtual void stop() override | |
| 130 { | |
| 131 SuspendableTimer::stop(); | |
| 132 // Will destroy this object | |
| 133 m_window->removePostMessageTimer(this); | |
| 134 } | |
| 135 | 129 |
| 136 DEFINE_INLINE_VIRTUAL_TRACE() | 130 DEFINE_INLINE_VIRTUAL_TRACE() |
| 137 { | 131 { |
| 138 visitor->trace(m_event); | 132 visitor->trace(m_event); |
| 139 visitor->trace(m_window); | 133 visitor->trace(m_window); |
| 140 visitor->trace(m_stackTrace); | 134 visitor->trace(m_stackTrace); |
| 141 SuspendableTimer::trace(visitor); | 135 SuspendableTimer::trace(visitor); |
| 142 } | 136 } |
| 143 | 137 |
| 144 private: | 138 private: |
| 145 virtual void fired() override | 139 virtual void fired() override |
| 146 { | 140 { |
| 147 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncOperationCompletedCallbackStarting(executionContext(), m_asyncOperationId); | 141 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncOperationCompletedCallbackStarting(executionContext(), m_asyncOperationId); |
| 148 m_window->postMessageTimerFired(this); | 142 m_window->postMessageTimerFired(this); |
| 149 // Will destroy this object | 143 // This object is deleted now. |
| 150 m_window->removePostMessageTimer(this); | |
| 151 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 144 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
| 152 } | 145 } |
| 153 | 146 |
| 154 RefPtrWillBeMember<MessageEvent> m_event; | 147 RefPtrWillBeMember<MessageEvent> m_event; |
| 155 RawPtrWillBeMember<LocalDOMWindow> m_window; | 148 RawPtrWillBeMember<LocalDOMWindow> m_window; |
| 156 RefPtr<SecurityOrigin> m_targetOrigin; | 149 RefPtr<SecurityOrigin> m_targetOrigin; |
| 157 RefPtrWillBeMember<ScriptCallStack> m_stackTrace; | 150 RefPtrWillBeMember<ScriptCallStack> m_stackTrace; |
| 158 RefPtr<UserGestureToken> m_userGestureToken; | 151 RefPtr<UserGestureToken> m_userGestureToken; |
| 159 int m_asyncOperationId; | 152 int m_asyncOperationId; |
| 160 }; | 153 }; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 // Schedule the message. | 653 // Schedule the message. |
| 661 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess
ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current
Token())); | 654 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess
ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current
Token())); |
| 662 timer->startOneShot(0, FROM_HERE); | 655 timer->startOneShot(0, FROM_HERE); |
| 663 timer->suspendIfNeeded(); | 656 timer->suspendIfNeeded(); |
| 664 m_postMessageTimers.add(timer.release()); | 657 m_postMessageTimers.add(timer.release()); |
| 665 } | 658 } |
| 666 | 659 |
| 667 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer) | 660 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer) |
| 668 { | 661 { |
| 669 if (!isCurrentlyDisplayedInFrame()) { | 662 if (!isCurrentlyDisplayedInFrame()) { |
| 663 m_postMessageTimers.remove(timer); |
| 670 return; | 664 return; |
| 671 } | 665 } |
| 672 | 666 |
| 673 RefPtrWillBeRawPtr<MessageEvent> event = timer->event(); | 667 RefPtrWillBeRawPtr<MessageEvent> event = timer->event(); |
| 674 | 668 |
| 675 UserGestureIndicator gestureIndicator(timer->userGestureToken()); | 669 UserGestureIndicator gestureIndicator(timer->userGestureToken()); |
| 676 | 670 |
| 677 event->entangleMessagePorts(document()); | 671 event->entangleMessagePorts(document()); |
| 678 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); | 672 dispatchMessageEventWithOriginCheck(timer->targetOrigin(), event, timer->sta
ckTrace()); |
| 679 } | |
| 680 | |
| 681 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) | |
| 682 { | |
| 683 m_postMessageTimers.remove(timer); | 673 m_postMessageTimers.remove(timer); |
| 684 } | 674 } |
| 685 | 675 |
| 686 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende
dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtrWillBeRawPtr<Scrip
tCallStack> stackTrace) | 676 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende
dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtrWillBeRawPtr<Scrip
tCallStack> stackTrace) |
| 687 { | 677 { |
| 688 if (intendedTargetOrigin) { | 678 if (intendedTargetOrigin) { |
| 689 // Check target origin now since the target document may have changed si
nce the timer was scheduled. | 679 // Check target origin now since the target document may have changed si
nce the timer was scheduled. |
| 690 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig
in())) { | 680 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrig
in())) { |
| 691 String message = ExceptionMessages::failedToExecute("postMessage", "
DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() +
"') does not match the recipient window's origin ('" + document()->securityOrig
in()->toString() + "')."); | 681 String message = ExceptionMessages::failedToExecute("postMessage", "
DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() +
"') does not match the recipient window's origin ('" + document()->securityOrig
in()->toString() + "')."); |
| 692 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(SecurityMessageSource, ErrorMessageLevel, message); | 682 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(SecurityMessageSource, ErrorMessageLevel, message); |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 DOMWindow::trace(visitor); | 1515 DOMWindow::trace(visitor); |
| 1526 DOMWindowLifecycleNotifier::trace(visitor); | 1516 DOMWindowLifecycleNotifier::trace(visitor); |
| 1527 } | 1517 } |
| 1528 | 1518 |
| 1529 LocalFrame* LocalDOMWindow::frame() const | 1519 LocalFrame* LocalDOMWindow::frame() const |
| 1530 { | 1520 { |
| 1531 return m_frameObserver->frame(); | 1521 return m_frameObserver->frame(); |
| 1532 } | 1522 } |
| 1533 | 1523 |
| 1534 } // namespace blink | 1524 } // namespace blink |
| OLD | NEW |