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

Unified Diff: Source/platform/UserGestureIndicator.cpp

Issue 239503008: Expose the timestamp associated with a user gesture, and make it possible to recreate a new user ge… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/platform/UserGestureIndicator.h ('k') | Source/web/WebScopedUserGesture.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/UserGestureIndicator.cpp
diff --git a/Source/platform/UserGestureIndicator.cpp b/Source/platform/UserGestureIndicator.cpp
index dbebd06a9ddc724f81f454e1af6366d3c0ae55fb..b2899e171344a6af313534a0e0031dcd76b9bf30 100644
--- a/Source/platform/UserGestureIndicator.cpp
+++ b/Source/platform/UserGestureIndicator.cpp
@@ -64,6 +64,11 @@ public:
m_timestamp = WTF::currentTime();
}
+ void setTimestamp(double timestamp)
+ {
+ m_timestamp = timestamp;
+ }
+
bool consumeGesture()
{
if (!m_consumableGestures)
@@ -88,6 +93,11 @@ public:
m_javascriptPrompt = true;
}
+ virtual double timestamp() const OVERRIDE
+ {
+ return m_timestamp;
+ }
+
private:
GestureToken()
: m_consumableGestures(0),
@@ -167,6 +177,26 @@ UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token)
ASSERT(isDefinite(s_state));
}
+UserGestureIndicator::UserGestureIndicator(double timestamp)
+ : m_previousState(s_state)
+{
+ // Silently ignore UserGestureIndicators on non-main threads.
+ if (!isMainThread())
+ return;
+
+ if (!s_topmostIndicator) {
+ s_topmostIndicator = this;
+ m_token = GestureToken::create();
+ } else {
+ m_token = s_topmostIndicator->currentToken();
+ }
+ s_state = DefinitelyProcessingUserGesture;
+
+ static_cast<GestureToken*>(m_token.get())->addGesture();
+ static_cast<GestureToken*>(m_token.get())->setTimestamp(timestamp);
+ ASSERT(isDefinite(s_state));
+}
+
UserGestureIndicator::~UserGestureIndicator()
{
if (!isMainThread())
« no previous file with comments | « Source/platform/UserGestureIndicator.h ('k') | Source/web/WebScopedUserGesture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698