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

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

Issue 2121083002: Add UseCounters for BeforeInstallPromptEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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: third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
diff --git a/third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.cpp b/third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
index c1c839b4b738c4945c24f876de8c26bef9b937af..f8b979b1bb44b9c153093907a73f0480b765f34a 100644
--- a/third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
+++ b/third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.cpp
@@ -7,6 +7,7 @@
#include "bindings/core/v8/ScriptPromise.h"
#include "core/dom/DOMException.h"
#include "core/dom/ExceptionCode.h"
+#include "core/frame/UseCounter.h"
#include "modules/app_banner/AppBannerCallbacks.h"
#include "modules/app_banner/BeforeInstallPromptEventInit.h"
#include "public/platform/modules/app_banner/WebAppBannerClient.h"
@@ -25,6 +26,7 @@ BeforeInstallPromptEvent::BeforeInstallPromptEvent(const AtomicString& name, Exe
, m_userChoice(new UserChoiceProperty(executionContext, this, UserChoiceProperty::UserChoice))
, m_registered(false)
{
+ UseCounter::count(executionContext, UseCounter::BeforeInstallPromptEvent);
}
BeforeInstallPromptEvent::BeforeInstallPromptEvent(const AtomicString& name, const BeforeInstallPromptEventInit& init)
@@ -47,6 +49,7 @@ Vector<String> BeforeInstallPromptEvent::platforms() const
ScriptPromise BeforeInstallPromptEvent::userChoice(ScriptState* scriptState)
{
+ UseCounter::count(scriptState->getExecutionContext(), UseCounter::BeforeInstallPromptEventUserChoice);
if (m_userChoice && m_client && m_requestId != -1) {
if (!m_registered) {
m_registered = true;
@@ -57,13 +60,10 @@ ScriptPromise BeforeInstallPromptEvent::userChoice(ScriptState* scriptState)
return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "userChoice cannot be accessed on this event."));
}
-const AtomicString& BeforeInstallPromptEvent::interfaceName() const
-{
- return EventNames::BeforeInstallPromptEvent;
-}
-
ScriptPromise BeforeInstallPromptEvent::prompt(ScriptState* scriptState)
{
+ UseCounter::count(scriptState->getExecutionContext(), UseCounter::BeforeInstallPromptEventPrompt);
+
// |m_registered| will be true if userChoice has already been accessed
// or prompt() has already been called. Return a rejected promise in both
// these cases, as well as if we have a null client or invalid requestId.
@@ -76,6 +76,17 @@ ScriptPromise BeforeInstallPromptEvent::prompt(ScriptState* scriptState)
return ScriptPromise::castUndefined(scriptState);
}
+const AtomicString& BeforeInstallPromptEvent::interfaceName() const
+{
+ return EventNames::BeforeInstallPromptEvent;
+}
+
+void BeforeInstallPromptEvent::preventDefault()
+{
+ Event::preventDefault();
+ UseCounter::count(target()->getExecutionContext(), UseCounter::BeforeInstallPromptEventPreventDefault);
+}
+
DEFINE_TRACE(BeforeInstallPromptEvent)
{
visitor->trace(m_userChoice);
« no previous file with comments | « third_party/WebKit/Source/modules/app_banner/BeforeInstallPromptEvent.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698