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

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

Issue 256623008: Mark forwarded user gestures as forwarded, and don't forward already forwarded user gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test 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 | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/messaging_bindings.cc
diff --git a/chrome/renderer/extensions/messaging_bindings.cc b/chrome/renderer/extensions/messaging_bindings.cc
index e906f4dc228a92dc64b7dea69a3dfa4c668e3832..1590724c4c34a1721de06dd84e35254923e22de8 100644
--- a/chrome/renderer/extensions/messaging_bindings.cc
+++ b/chrome/renderer/extensions/messaging_bindings.cc
@@ -30,6 +30,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):
@@ -102,6 +103,12 @@ class ExtensionImpl : public ObjectBackedNativeHandler {
dispatcher_->ClearPortData(port_id);
}
+ bool ShouldForwardUserGesture() {
+ return blink::WebUserGestureIndicator::isProcessingUserGesture() &&
+ !blink::WebUserGestureIndicator::currentUserGestureToken()
+ .wasForwarded();
+ }
+
// Sends a message along the given channel.
void PostMessage(const v8::FunctionCallbackInfo<v8::Value>& args) {
content::RenderView* renderview = context()->GetRenderView();
@@ -121,9 +128,9 @@ class ExtensionImpl : public ObjectBackedNativeHandler {
}
renderview->Send(new ExtensionHostMsg_PostMessage(
- renderview->GetRoutingID(), port_id,
- Message(*v8::String::Utf8Value(args[1]),
- blink::WebUserGestureIndicator::isProcessingUserGesture())));
+ renderview->GetRoutingID(),
+ port_id,
+ Message(*v8::String::Utf8Value(args[1]), ShouldForwardUserGesture())));
}
// Forcefully disconnects a port.
@@ -357,6 +364,7 @@ void MessagingBindings::DeliverMessage(
scoped_ptr<blink::WebScopedWindowFocusAllowedIndicator> allow_window_focus;
if (message.user_gesture) {
web_user_gesture.reset(new blink::WebScopedUserGesture);
+ blink::WebUserGestureIndicator::currentUserGestureToken().setForwarded();
allow_window_focus.reset(new blink::WebScopedWindowFocusAllowedIndicator);
}
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698