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

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: 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..11b14183708dcc6c2fa0f69f4f520f4e102daf95 100644
--- a/third_party/WebKit/Source/platform/UserGestureIndicator.h
+++ b/third_party/WebKit/Source/platform/UserGestureIndicator.h
@@ -51,18 +51,51 @@ public:
virtual void setPauseInDebugger() = 0;
};
+// Callback to be invoked when the state of a UserGestureIndicator is
+// first tested (only during the scope of a UserGestureIndiactor, does
+// not flow with the UserGestureToken). It's the responsibility of the
+// caller to ensure the UserGestureUsedCallback 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 used (sometimes it's just propagated
+// elsewhere), but should include most use cases. Therefore this is
+// suitable mainly for diagnostics and measurement purposes.
+class PLATFORM_EXPORT UserGestureUsedCallback {
+ WTF_MAKE_NONCOPYABLE(UserGestureUsedCallback);
+public:
+ UserGestureUsedCallback() { }
+ virtual ~UserGestureUsedCallback() { }
+ virtual void userGestureUsed() = 0;
+};
+
class PLATFORM_EXPORT UserGestureIndicator final {
USING_FAST_MALLOC(UserGestureIndicator);
WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
public:
+ // Returns whether a user gesture is currently in progress.
+ // If true, invokes (and then clears) any UserGestureUsedCallback.
static bool processingUserGesture();
+
+ // Returns whether a user gesture is currently in progress.
+ // Does not invoke the UserGestureQueriedCallback.
+ static bool processingUserGestureUntracked();
+
+ // 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 processingUserGesture, may invoke/clear any UserGestureUsedCallback.
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, UserGestureUsedCallback* usageCallback = 0);
+ explicit UserGestureIndicator(PassRefPtr<UserGestureToken>, UserGestureUsedCallback* usageCallback = 0);
~UserGestureIndicator();
private:
@@ -71,6 +104,7 @@ private:
static bool s_processedUserGestureSinceLoad;
ProcessingUserGestureState m_previousState;
RefPtr<UserGestureToken> m_token;
+ UserGestureUsedCallback* m_usageCallback;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698