| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 , m_window(window) | 117 , m_window(window) |
| 118 { | 118 { |
| 119 } | 119 } |
| 120 | 120 |
| 121 Member<LocalDOMWindow> m_window; | 121 Member<LocalDOMWindow> m_window; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer
>, public SuspendableTimer { | 124 class PostMessageTimer final : public GarbageCollectedFinalized<PostMessageTimer
>, public SuspendableTimer { |
| 125 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); | 125 USING_GARBAGE_COLLECTED_MIXIN(PostMessageTimer); |
| 126 public: | 126 public: |
| 127 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, SecurityOrigin
* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureToken* userGe
stureToken) | 127 PostMessageTimer(LocalDOMWindow& window, MessageEvent* event, PassRefPtr<Sec
urityOrigin> targetOrigin, PassRefPtr<ScriptCallStack> stackTrace, UserGestureTo
ken* userGestureToken) |
| 128 : SuspendableTimer(window.document()) | 128 : SuspendableTimer(window.document()) |
| 129 , m_event(event) | 129 , m_event(event) |
| 130 , m_window(&window) | 130 , m_window(&window) |
| 131 , m_targetOrigin(targetOrigin) | 131 , m_targetOrigin(targetOrigin) |
| 132 , m_stackTrace(stackTrace) | 132 , m_stackTrace(stackTrace) |
| 133 , m_userGestureToken(userGestureToken) | 133 , m_userGestureToken(userGestureToken) |
| 134 , m_disposalAllowed(true) | 134 , m_disposalAllowed(true) |
| 135 { | 135 { |
| 136 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes
sage", this); | 136 InspectorInstrumentation::asyncTaskScheduled(window.document(), "postMes
sage", this); |
| 137 } | 137 } |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 return m_applicationCache.get(); | 656 return m_applicationCache.get(); |
| 657 } | 657 } |
| 658 | 658 |
| 659 Navigator* LocalDOMWindow::navigator() const | 659 Navigator* LocalDOMWindow::navigator() const |
| 660 { | 660 { |
| 661 if (!m_navigator) | 661 if (!m_navigator) |
| 662 m_navigator = Navigator::create(frame()); | 662 m_navigator = Navigator::create(frame()); |
| 663 return m_navigator.get(); | 663 return m_navigator.get(); |
| 664 } | 664 } |
| 665 | 665 |
| 666 void LocalDOMWindow::schedulePostMessage(MessageEvent* event, SecurityOrigin* ta
rget, PassRefPtr<ScriptCallStack> stackTrace) | 666 void LocalDOMWindow::schedulePostMessage(MessageEvent* event, PassRefPtr<Securit
yOrigin> target, Document* source) |
| 667 { | 667 { |
| 668 // Allowing unbounded amounts of messages to build up for a suspended contex
t | 668 // Allowing unbounded amounts of messages to build up for a suspended contex
t |
| 669 // is problematic; consider imposing a limit or other restriction if this | 669 // is problematic; consider imposing a limit or other restriction if this |
| 670 // surfaces often as a problem (see crbug.com/587012). | 670 // surfaces often as a problem (see crbug.com/587012). |
| 671 | 671 |
| 672 // Capture stack trace only when inspector front-end is loaded as it may be
time consuming. |
| 673 RefPtr<ScriptCallStack> stackTrace; |
| 674 if (InspectorInstrumentation::consoleAgentEnabled(source)) |
| 675 stackTrace = ScriptCallStack::capture(); |
| 676 |
| 672 // Schedule the message. | 677 // Schedule the message. |
| 673 PostMessageTimer* timer = new PostMessageTimer(*this, event, target, stackTr
ace, UserGestureIndicator::currentToken()); | 678 PostMessageTimer* timer = new PostMessageTimer(*this, event, target, stackTr
ace.release(), UserGestureIndicator::currentToken()); |
| 674 timer->startOneShot(0, BLINK_FROM_HERE); | 679 timer->startOneShot(0, BLINK_FROM_HERE); |
| 675 timer->suspendIfNeeded(); | 680 timer->suspendIfNeeded(); |
| 676 m_postMessageTimers.add(timer); | 681 m_postMessageTimers.add(timer); |
| 677 } | 682 } |
| 678 | 683 |
| 679 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer) | 684 void LocalDOMWindow::postMessageTimerFired(PostMessageTimer* timer) |
| 680 { | 685 { |
| 681 if (!isCurrentlyDisplayedInFrame()) | 686 if (!isCurrentlyDisplayedInFrame()) |
| 682 return; | 687 return; |
| 683 | 688 |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 { | 1535 { |
| 1531 // If the LocalDOMWindow still has a frame reference, that frame must point | 1536 // If the LocalDOMWindow still has a frame reference, that frame must point |
| 1532 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1537 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
| 1533 // where script execution leaks between different LocalDOMWindows. | 1538 // where script execution leaks between different LocalDOMWindows. |
| 1534 if (m_frameObserver->frame()) | 1539 if (m_frameObserver->frame()) |
| 1535 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1540 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
| 1536 return m_frameObserver->frame(); | 1541 return m_frameObserver->frame(); |
| 1537 } | 1542 } |
| 1538 | 1543 |
| 1539 } // namespace blink | 1544 } // namespace blink |
| OLD | NEW |