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 |