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

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

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.h
diff --git a/third_party/WebKit/Source/platform/UserGestureIndicator.h b/third_party/WebKit/Source/platform/UserGestureIndicator.h
index aa945209ad1bf09762b260d803bafa27fd754e67..3a35cb1b6818e493a804cf90d68fe0a80494918c 100644
--- a/third_party/WebKit/Source/platform/UserGestureIndicator.h
+++ b/third_party/WebKit/Source/platform/UserGestureIndicator.h
@@ -51,18 +51,53 @@ public:
virtual void setPauseInDebugger() = 0;
};
+// Callback to be invoked when the state of a UserGestureIndicator is
+// used (only during the scope of a UserGestureIndicator, does
+// not flow with the UserGestureToken). It's the responsibility of the
+// caller to ensure the UserGestureUtilizedCallback is kept alive as long
+// as the UserGestureIndicator it's used in.
+// Note that this doesn't currently track EVERY way in which the
+// state of a UserGesture can be read (sometimes it's just propagated
+// elsewhere, or otherwise read in a way that's hard to know if it will
+// actually be used), but should include the primary use cases. Therefore
+// this is suitable mainly for diagnostics and measurement purposes.
+class PLATFORM_EXPORT UserGestureUtilizedCallback {
+public:
+ virtual ~UserGestureUtilizedCallback() = default;
+ virtual void userGestureUtilized() = 0;
+};
+
class PLATFORM_EXPORT UserGestureIndicator final {
USING_FAST_MALLOC(UserGestureIndicator);
WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
public:
+ // Returns whether a user gesture is currently in progress.
+ // Does not invoke the UserGestureUtilizedCallback. Consider calling
+ // utilizeUserGesture instead if you know for sure that the return value
+ // will have an effect.
static bool processingUserGesture();
+
+ // Indicates that a user gesture (if any) is being used, without preventing it
+ // from being used again. Returns whether a user gesture is currently in progress.
+ // If true, invokes (and then clears) any UserGestureUtilizedCallback.
+ static bool utilizeUserGesture();
+
+ // Mark the current user gesture (if any) as having been used, such that
+ // it cannot be used again. This is done only for very security-sensitive
+ // operations like creating a new process.
+ // Like utilizeUserGesture, may invoke/clear any UserGestureUtilizedCallback.
static bool consumeUserGesture();
+
static UserGestureToken* currentToken();
+
+ // Reset the notion of "since load".
static void clearProcessedUserGestureSinceLoad();
+
+ // Returns whether a user gesture has occurred since page load.
static bool processedUserGestureSinceLoad();
- explicit UserGestureIndicator(ProcessingUserGestureState);
- explicit UserGestureIndicator(PassRefPtr<UserGestureToken>);
+ explicit UserGestureIndicator(ProcessingUserGestureState, UserGestureUtilizedCallback* = 0);
+ explicit UserGestureIndicator(PassRefPtr<UserGestureToken>, UserGestureUtilizedCallback* = 0);
~UserGestureIndicator();
private:
@@ -71,6 +106,7 @@ private:
static bool s_processedUserGestureSinceLoad;
ProcessingUserGestureState m_previousState;
RefPtr<UserGestureToken> m_token;
+ UserGestureUtilizedCallback* m_usageCallback;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698