Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: Source/modules/serviceworkers/WaitUntilObserver.cpp

Issue 866983004: Allow creating new windows from a notificationclick event in SW. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/WaitUntilObserver.cpp
diff --git a/Source/modules/serviceworkers/WaitUntilObserver.cpp b/Source/modules/serviceworkers/WaitUntilObserver.cpp
index 55a289762c41b04b169f44c82d53ba69c9955492..bf4ed4e459ed914644c38adc2f24df6041e8e076 100644
--- a/Source/modules/serviceworkers/WaitUntilObserver.cpp
+++ b/Source/modules/serviceworkers/WaitUntilObserver.cpp
@@ -92,11 +92,13 @@ void WaitUntilObserver::waitUntil(ScriptState* scriptState, const ScriptValue& v
return;
// When handling a notificationclick event, we want to allow one window to
- // be focused. Regardless of whether one window was focused,
- // |consumeWindowFocus| will be called when all the pending activities will
- // be resolved.
- if (m_type == NotificationClick)
- executionContext()->allowWindowFocus();
+ // be focused or opened. Regardless of whether such action happened,
+ // |consumeWindowInteraction| will be called when all the pending activities
+ // will be resolved or after a
+ if (m_type == NotificationClick) {
+ executionContext()->allowWindowInteraction();
+ m_consumeWindowInteractionTimer.startOneShot(ServiceWorkerGlobalScope::kWindowInteractionTimeout, FROM_HERE);
+ }
incrementPendingActivity();
ScriptPromise::cast(scriptState, value).then(
@@ -111,6 +113,7 @@ WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, EventType type,
, m_pendingActivity(0)
, m_hasError(false)
, m_eventDispatched(false)
+ , m_consumeWindowInteractionTimer(this, &WaitUntilObserver::consumeWindowInteraction)
{
}
@@ -144,7 +147,8 @@ void WaitUntilObserver::decrementPendingActivity()
break;
case NotificationClick:
client->didHandleNotificationClickEvent(m_eventID, result);
- executionContext()->consumeWindowFocus();
+ m_consumeWindowInteractionTimer.stop();
+ consumeWindowInteraction(nullptr);
break;
case Push:
client->didHandlePushEvent(m_eventID, result);
@@ -153,6 +157,13 @@ void WaitUntilObserver::decrementPendingActivity()
observeContext(0);
}
+void WaitUntilObserver::consumeWindowInteraction(Timer<WaitUntilObserver>*)
+{
+ if (!executionContext())
+ return;
+ executionContext()->consumeWindowInteraction();
+}
+
void WaitUntilObserver::trace(Visitor* visitor)
{
ContextLifecycleObserver::trace(visitor);
« no previous file with comments | « Source/modules/serviceworkers/WaitUntilObserver.h ('k') | Source/web/tests/WebScopedWindowFocusAllowedIndicatorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698