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

Unified Diff: third_party/WebKit/Source/platform/UserGestureIndicator.cpp

Issue 1799253002: Stricter user gestures for touch - measure and warn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaks Created 4 years, 8 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/platform/UserGestureIndicator.cpp
diff --git a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
index 5b4c4362359b1f205e332a6cb7bf541bf6efd081..26619046c4576c60971f6c4edf8d821b86b44c80 100644
--- a/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
+++ b/third_party/WebKit/Source/platform/UserGestureIndicator.cpp
@@ -128,8 +128,9 @@ ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessi
UserGestureIndicator* UserGestureIndicator::s_topmostIndicator = 0;
bool UserGestureIndicator::s_processedUserGestureSinceLoad = false;
-UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
+UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state, UserGestureUtilizedCallback* usageCallback)
: m_previousState(DefinitelyNotProcessingUserGesture)
+ , m_usageCallback(usageCallback)
{
// Silently ignore UserGestureIndicators on non-main threads.
if (!isMainThread())
@@ -158,8 +159,9 @@ UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
ASSERT(isDefinite(s_state));
}
-UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token)
+UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token, UserGestureUtilizedCallback* usageCallback)
: m_previousState(DefinitelyNotProcessingUserGesture)
+ , m_usageCallback(usageCallback)
{
// Silently ignore UserGestureIndicators on non-main threads.
if (!isMainThread())
@@ -196,6 +198,18 @@ UserGestureIndicator::~UserGestureIndicator()
}
// static
+bool UserGestureIndicator::utilizeUserGesture()
+{
+ if (UserGestureIndicator::processingUserGesture()) {
+ if (s_topmostIndicator->m_usageCallback) {
+ s_topmostIndicator->m_usageCallback->userGestureUtilized();
+ s_topmostIndicator->m_usageCallback = nullptr;
+ }
+ return true;
+ }
+ return false;
+}
+
bool UserGestureIndicator::processingUserGesture()
{
if (auto* token = currentToken()) {
@@ -211,9 +225,14 @@ bool UserGestureIndicator::consumeUserGesture()
{
if (auto* token = currentToken()) {
ASSERT(isMainThread());
- return static_cast<GestureToken*>(token)->consumeGesture();
+ if (static_cast<GestureToken*>(token)->consumeGesture()) {
+ if (s_topmostIndicator->m_usageCallback) {
+ s_topmostIndicator->m_usageCallback->userGestureUtilized();
+ s_topmostIndicator->m_usageCallback = nullptr;
+ }
+ return true;
+ }
}
-
return false;
}

Powered by Google App Engine
This is Rietveld 408576698