| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 public: | 116 public: |
| 117 PostMessageTimer(LocalDOMWindow& window, PassRefPtrWillBeRawPtr<MessageEvent
> event, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, U
serGestureToken* userGestureToken) | 117 PostMessageTimer(LocalDOMWindow& window, PassRefPtrWillBeRawPtr<MessageEvent
> event, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, U
serGestureToken* userGestureToken) |
| 118 : SuspendableTimer(window.document()) | 118 : SuspendableTimer(window.document()) |
| 119 , m_event(event) | 119 , m_event(event) |
| 120 , m_window(&window) | 120 , m_window(&window) |
| 121 , m_targetOrigin(targetOrigin) | 121 , m_targetOrigin(targetOrigin) |
| 122 , m_stackTrace(stackTrace) | 122 , m_stackTrace(stackTrace) |
| 123 , m_userGestureToken(userGestureToken) | 123 , m_userGestureToken(userGestureToken) |
| 124 , m_disposalAllowed(true) | 124 , m_disposalAllowed(true) |
| 125 { | 125 { |
| 126 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti
ng(executionContext(), "postMessage"); | 126 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti
ng(getExecutionContext(), "postMessage"); |
| 127 } | 127 } |
| 128 | 128 |
| 129 PassRefPtrWillBeRawPtr<MessageEvent> event() const { return m_event.get(); } | 129 PassRefPtrWillBeRawPtr<MessageEvent> event() const { return m_event.get(); } |
| 130 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } | 130 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } |
| 131 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } | 131 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } |
| 132 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } | 132 UserGestureToken* userGestureToken() const { return m_userGestureToken.get()
; } |
| 133 void stop() override | 133 void stop() override |
| 134 { | 134 { |
| 135 SuspendableTimer::stop(); | 135 SuspendableTimer::stop(); |
| 136 | 136 |
| 137 if (m_disposalAllowed) | 137 if (m_disposalAllowed) |
| 138 dispose(); | 138 dispose(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 // Eager finalization is needed to promptly stop this timer object. | 141 // Eager finalization is needed to promptly stop this timer object. |
| 142 // (see DOMTimer comment for more.) | 142 // (see DOMTimer comment for more.) |
| 143 EAGERLY_FINALIZE(); | 143 EAGERLY_FINALIZE(); |
| 144 DEFINE_INLINE_VIRTUAL_TRACE() | 144 DEFINE_INLINE_VIRTUAL_TRACE() |
| 145 { | 145 { |
| 146 visitor->trace(m_event); | 146 visitor->trace(m_event); |
| 147 visitor->trace(m_window); | 147 visitor->trace(m_window); |
| 148 SuspendableTimer::trace(visitor); | 148 SuspendableTimer::trace(visitor); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specif
ic default task runner. | 151 // TODO(alexclarke): Override timerTaskRunner() to pass in a document specif
ic default task runner. |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 void fired() override | 154 void fired() override |
| 155 { | 155 { |
| 156 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncOperationCompletedCallbackStarting(executionContext(), m_asyncOperationId); | 156 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncOperationCompletedCallbackStarting(getExecutionContext(), m_asyncOperationId
); |
| 157 m_disposalAllowed = false; | 157 m_disposalAllowed = false; |
| 158 m_window->postMessageTimerFired(this); | 158 m_window->postMessageTimerFired(this); |
| 159 dispose(); | 159 dispose(); |
| 160 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 160 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void dispose() | 163 void dispose() |
| 164 { | 164 { |
| 165 // Oilpan optimization: unregister as an observer right away. | 165 // Oilpan optimization: unregister as an observer right away. |
| 166 clearContext(); | 166 clearContext(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(frame()-
>view(), HorizontalScrollbar); | 367 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(frame()-
>view(), HorizontalScrollbar); |
| 368 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(frame()-
>view(), VerticalScrollbar); | 368 scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(frame()-
>view(), VerticalScrollbar); |
| 369 scrollingCoordinator->scrollableAreaScrollLayerDidChange(frame()->vi
ew()); | 369 scrollingCoordinator->scrollableAreaScrollLayerDidChange(frame()->vi
ew()); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 frame()->selection().updateSecureKeyboardEntryIfActive(); | 373 frame()->selection().updateSecureKeyboardEntryIfActive(); |
| 374 return m_document; | 374 return m_document; |
| 375 } | 375 } |
| 376 | 376 |
| 377 EventQueue* LocalDOMWindow::eventQueue() const | 377 EventQueue* LocalDOMWindow::getEventQueue() const |
| 378 { | 378 { |
| 379 return m_eventQueue.get(); | 379 return m_eventQueue.get(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void LocalDOMWindow::enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event> event) | 382 void LocalDOMWindow::enqueueWindowEvent(PassRefPtrWillBeRawPtr<Event> event) |
| 383 { | 383 { |
| 384 if (!m_eventQueue) | 384 if (!m_eventQueue) |
| 385 return; | 385 return; |
| 386 event->setTarget(this); | 386 event->setTarget(this); |
| 387 m_eventQueue->enqueueEvent(event); | 387 m_eventQueue->enqueueEvent(event); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // want to access their associated LocalDOMWindow from their destructors. | 471 // want to access their associated LocalDOMWindow from their destructors. |
| 472 // | 472 // |
| 473 // (Non-Oilpan, LocalDOMWindow::reset() will always be invoked, the last opp
ortunity | 473 // (Non-Oilpan, LocalDOMWindow::reset() will always be invoked, the last opp
ortunity |
| 474 // being via ~LocalFrame's setDOMWindow() call. Asserted for in the destruct
or.) | 474 // being via ~LocalFrame's setDOMWindow() call. Asserted for in the destruct
or.) |
| 475 if (!frame()) | 475 if (!frame()) |
| 476 return; | 476 return; |
| 477 | 477 |
| 478 removeAllEventListeners(); | 478 removeAllEventListeners(); |
| 479 } | 479 } |
| 480 | 480 |
| 481 ExecutionContext* LocalDOMWindow::executionContext() const | 481 ExecutionContext* LocalDOMWindow::getExecutionContext() const |
| 482 { | 482 { |
| 483 return m_document.get(); | 483 return m_document.get(); |
| 484 } | 484 } |
| 485 | 485 |
| 486 const LocalDOMWindow* LocalDOMWindow::toDOMWindow() const | 486 const LocalDOMWindow* LocalDOMWindow::toDOMWindow() const |
| 487 { | 487 { |
| 488 return this; | 488 return this; |
| 489 } | 489 } |
| 490 | 490 |
| 491 LocalDOMWindow* LocalDOMWindow::toDOMWindow() | 491 LocalDOMWindow* LocalDOMWindow::toDOMWindow() |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 707 |
| 708 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) | 708 void LocalDOMWindow::removePostMessageTimer(PostMessageTimer* timer) |
| 709 { | 709 { |
| 710 m_postMessageTimers.remove(timer); | 710 m_postMessageTimers.remove(timer); |
| 711 } | 711 } |
| 712 | 712 |
| 713 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende
dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtr<ScriptCallStack>
stackTrace) | 713 void LocalDOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intende
dTargetOrigin, PassRefPtrWillBeRawPtr<Event> event, PassRefPtr<ScriptCallStack>
stackTrace) |
| 714 { | 714 { |
| 715 if (intendedTargetOrigin) { | 715 if (intendedTargetOrigin) { |
| 716 // Check target origin now since the target document may have changed si
nce the timer was scheduled. | 716 // Check target origin now since the target document may have changed si
nce the timer was scheduled. |
| 717 if (!intendedTargetOrigin->isSameSchemeHostPortAndSuborigin(document()->
securityOrigin())) { | 717 if (!intendedTargetOrigin->isSameSchemeHostPortAndSuborigin(document()->
getSecurityOrigin())) { |
| 718 String message = ExceptionMessages::failedToExecute("postMessage", "
DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() +
"') does not match the recipient window's origin ('" + document()->securityOrig
in()->toString() + "')."); | 718 String message = ExceptionMessages::failedToExecute("postMessage", "
DOMWindow", "The target origin provided ('" + intendedTargetOrigin->toString() +
"') does not match the recipient window's origin ('" + document()->getSecurityO
rigin()->toString() + "')."); |
| 719 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(SecurityMessageSource, ErrorMessageLevel, message); | 719 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::
create(SecurityMessageSource, ErrorMessageLevel, message); |
| 720 consoleMessage->setCallStack(stackTrace); | 720 consoleMessage->setCallStack(stackTrace); |
| 721 frameConsole()->addMessage(consoleMessage.release()); | 721 frameConsole()->addMessage(consoleMessage.release()); |
| 722 return; | 722 return; |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 | 725 |
| 726 dispatchEvent(event); | 726 dispatchEvent(event); |
| 727 } | 727 } |
| 728 | 728 |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 { | 1519 { |
| 1520 // If the LocalDOMWindow still has a frame reference, that frame must point | 1520 // If the LocalDOMWindow still has a frame reference, that frame must point |
| 1521 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1521 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
| 1522 // where script execution leaks between different LocalDOMWindows. | 1522 // where script execution leaks between different LocalDOMWindows. |
| 1523 if (m_frameObserver->frame()) | 1523 if (m_frameObserver->frame()) |
| 1524 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1524 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
| 1525 return m_frameObserver->frame(); | 1525 return m_frameObserver->frame(); |
| 1526 } | 1526 } |
| 1527 | 1527 |
| 1528 } // namespace blink | 1528 } // namespace blink |
| OLD | NEW |