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

Unified Diff: Source/modules/app_banner/BeforeInstallPromptEvent.cpp

Issue 1160413004: Add hooks for BeforeInstallPromptEvent to be redispatched. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Making prompt() return a promise Created 5 years, 6 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/app_banner/BeforeInstallPromptEvent.cpp
diff --git a/Source/modules/app_banner/BeforeInstallPromptEvent.cpp b/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
index a11e7cd5a000f3bdb356628b4544d541f294dc86..607acc0c63c718ad1f6042fb2948533c0e5d9456 100644
--- a/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
+++ b/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
@@ -22,6 +22,7 @@ BeforeInstallPromptEvent::BeforeInstallPromptEvent(const AtomicString& name, con
, m_platforms(platforms)
, m_requestId(requestId)
, m_client(client)
+ , m_redispatched(false)
{
}
@@ -30,6 +31,7 @@ BeforeInstallPromptEvent::BeforeInstallPromptEvent(const AtomicString& name, con
, m_platforms(init.platforms())
, m_requestId(-1)
, m_client(nullptr)
+ , m_redispatched(false)
{
}
@@ -59,4 +61,20 @@ const AtomicString& BeforeInstallPromptEvent::interfaceName() const
return EventNames::BeforeInstallPromptEvent;
}
+ScriptPromise BeforeInstallPromptEvent::prompt(ScriptState* scriptState)
+{
+ RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
mlamouri (slow - plz ping) 2015/06/11 00:42:17 You probably don't need a |resolver| or a |promise
+ if (m_client && defaultPrevented() && !m_redispatched) {
+ ASSERT(m_requestId != -1);
+ m_redispatched = true;
+ m_client->resolveEventRedispatch(m_requestId);
+ resolver->resolve();
+ userChoice(scriptState);
mlamouri (slow - plz ping) 2015/06/11 00:42:17 Why do you call that?
+ } else {
+ resolver->reject();
mlamouri (slow - plz ping) 2015/06/11 00:42:17 I think you should reject with an InvalidState err
+ }
+ return promise;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698