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

Unified Diff: chrome/renderer/extensions/messaging_bindings.cc

Issue 240223004: When passing a user gesture along with a message, include the timestamp of the user gesture to prev… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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
Index: chrome/renderer/extensions/messaging_bindings.cc
diff --git a/chrome/renderer/extensions/messaging_bindings.cc b/chrome/renderer/extensions/messaging_bindings.cc
index 4e273b72e4502d9b1b5c91be0ff57d19191f663c..00dad22bc4ce190aee1ee1f297e368b9275a4a6c 100644
--- a/chrome/renderer/extensions/messaging_bindings.cc
+++ b/chrome/renderer/extensions/messaging_bindings.cc
@@ -31,6 +31,7 @@
#include "third_party/WebKit/public/web/WebScopedUserGesture.h"
#include "third_party/WebKit/public/web/WebScopedWindowFocusAllowedIndicator.h"
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
+#include "third_party/WebKit/public/web/WebUserGestureToken.h"
#include "v8/include/v8.h"
// Message passing API example (in a content script):
@@ -120,10 +121,19 @@ class ExtensionImpl : public ChromeV8Extension {
return;
}
+ bool user_gesture =
+ blink::WebUserGestureIndicator::isProcessingUserGesture();
+ double user_gesture_timestamp = 0.0;
+ if (user_gesture) {
+ user_gesture_timestamp =
+ blink::WebUserGestureIndicator::currentUserGestureToken().timestamp();
+ }
renderview->Send(new ExtensionHostMsg_PostMessage(
- renderview->GetRoutingID(), port_id,
+ renderview->GetRoutingID(),
+ port_id,
Message(*v8::String::Utf8Value(args[1]),
- blink::WebUserGestureIndicator::isProcessingUserGesture())));
+ user_gesture,
+ user_gesture_timestamp)));
}
// Forcefully disconnects a port.
@@ -353,8 +363,11 @@ void MessagingBindings::DeliverMessage(
scoped_ptr<blink::WebScopedUserGesture> web_user_gesture;
scoped_ptr<blink::WebScopedWindowFocusAllowedIndicator> allow_window_focus;
if (message.user_gesture) {
- web_user_gesture.reset(new blink::WebScopedUserGesture);
- allow_window_focus.reset(new blink::WebScopedWindowFocusAllowedIndicator);
+ web_user_gesture.reset(
+ new blink::WebScopedUserGesture(message.user_gesture_timestamp));
+ if (blink::WebUserGestureIndicator::isProcessingUserGesture()) {
+ allow_window_focus.reset(new blink::WebScopedWindowFocusAllowedIndicator);
+ }
}
v8::Isolate* isolate = v8::Isolate::GetCurrent();
« no previous file with comments | « chrome/browser/extensions/api/messaging/message_service.cc ('k') | extensions/common/api/messaging/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698