OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/serviceworkers/WaitUntilObserver.h" | 5 #include "modules/serviceworkers/WaitUntilObserver.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptFunction.h" | 7 #include "bindings/core/v8/ScriptFunction.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 }; | 79 }; |
80 | 80 |
81 WaitUntilObserver* WaitUntilObserver::create(ExecutionContext* context, | 81 WaitUntilObserver* WaitUntilObserver::create(ExecutionContext* context, |
82 EventType type, | 82 EventType type, |
83 int eventID) { | 83 int eventID) { |
84 return new WaitUntilObserver(context, type, eventID); | 84 return new WaitUntilObserver(context, type, eventID); |
85 } | 85 } |
86 | 86 |
87 void WaitUntilObserver::willDispatchEvent() { | 87 void WaitUntilObserver::willDispatchEvent() { |
88 m_eventDispatchTime = WTF::currentTime(); | 88 m_eventDispatchTime = WTF::currentTime(); |
89 // When handling a notificationclick event, we want to allow one window to | 89 // When handling a notificationclick or paymentrequest event, we want to |
90 // be focused or opened. These calls are allowed between the call to | 90 // allow one window to be focused or opened. These calls are allowed between |
91 // willDispatchEvent() and the last call to decrementPendingActivity(). If | 91 // the call to willDispatchEvent() and the last call to |
92 // waitUntil() isn't called, that means between willDispatchEvent() and | 92 // decrementPendingActivity(). If waitUntil() isn't called, that means |
93 // didDispatchEvent(). | 93 // between willDispatchEvent() and didDispatchEvent(). |
94 if (m_type == NotificationClick) | 94 if (m_type == NotificationClick || m_type == PaymentRequest) |
95 m_executionContext->allowWindowInteraction(); | 95 m_executionContext->allowWindowInteraction(); |
96 | 96 |
97 incrementPendingActivity(); | 97 incrementPendingActivity(); |
98 } | 98 } |
99 | 99 |
100 void WaitUntilObserver::didDispatchEvent(bool errorOccurred) { | 100 void WaitUntilObserver::didDispatchEvent(bool errorOccurred) { |
101 if (errorOccurred) | 101 if (errorOccurred) |
102 m_hasError = true; | 102 m_hasError = true; |
103 decrementPendingActivity(); | 103 decrementPendingActivity(); |
104 m_eventDispatched = true; | 104 m_eventDispatched = true; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (!m_executionContext) | 205 if (!m_executionContext) |
206 return; | 206 return; |
207 m_executionContext->consumeWindowInteraction(); | 207 m_executionContext->consumeWindowInteraction(); |
208 } | 208 } |
209 | 209 |
210 DEFINE_TRACE(WaitUntilObserver) { | 210 DEFINE_TRACE(WaitUntilObserver) { |
211 visitor->trace(m_executionContext); | 211 visitor->trace(m_executionContext); |
212 } | 212 } |
213 | 213 |
214 } // namespace blink | 214 } // namespace blink |
OLD | NEW |