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

Unified Diff: third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp

Issue 2454433002: [Extensions + Blink] Account for user gesture in v8 function calls (Closed)
Patch Set: hmm Created 4 years, 2 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 | « extensions/renderer/user_gestures_native_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
diff --git a/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp b/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
index 20aba329814e771e03d166318aecd919a4079194..9e1817ca2a444e55392eb59d6685252e78cec5a9 100644
--- a/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
+++ b/third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
@@ -81,7 +81,8 @@ class V8FunctionExecutor : public SuspendableScriptExecutor::Executor {
v8::Local<v8::Function>,
v8::Local<v8::Value> receiver,
int argc,
- v8::Local<v8::Value> argv[]);
+ v8::Local<v8::Value> argv[],
+ bool userGesture);
Vector<v8::Local<v8::Value>> execute(LocalFrame*) override;
@@ -90,6 +91,7 @@ class V8FunctionExecutor : public SuspendableScriptExecutor::Executor {
ScopedPersistent<v8::Value> m_receiver;
V8PersistentValueVector<v8::Value> m_args;
RefPtr<ScriptState> m_scriptState;
+ bool m_userGesture;
};
V8FunctionExecutor::V8FunctionExecutor(v8::Isolate* isolate,
@@ -97,11 +99,13 @@ V8FunctionExecutor::V8FunctionExecutor(v8::Isolate* isolate,
v8::Local<v8::Function> function,
v8::Local<v8::Value> receiver,
int argc,
- v8::Local<v8::Value> argv[])
+ v8::Local<v8::Value> argv[],
+ bool userGesture)
: m_function(isolate, function),
m_receiver(isolate, receiver),
m_args(isolate),
- m_scriptState(scriptState) {
+ m_scriptState(scriptState),
+ m_userGesture(userGesture) {
m_args.ReserveCapacity(argc);
for (int i = 0; i < argc; ++i)
m_args.Append(argv[i]);
@@ -118,12 +122,22 @@ Vector<v8::Local<v8::Value>> V8FunctionExecutor::execute(LocalFrame* frame) {
args.reserveCapacity(m_args.Size());
for (size_t i = 0; i < m_args.Size(); ++i)
args.append(m_args.Get(i));
- if (V8ScriptRunner::callFunction(m_function.newLocal(isolate),
- frame->document(),
- m_receiver.newLocal(isolate), args.size(),
- args.data(), toIsolate(frame))
- .ToLocal(&singleResult))
- results.append(singleResult);
+
+ {
+ std::unique_ptr<UserGestureIndicator> indicator;
+ if (m_userGesture && !UserGestureIndicator::processingUserGesture()) {
Devlin 2016/10/26 22:45:22 I'm very unsure about this. I originally started
dcheng 2016/10/26 23:16:49 I believe we should be saving the original UserGes
Devlin 2016/10/27 23:33:28 Tried it out; ptal.
+ indicator =
+ wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create(
+ frame->document(), UserGestureToken::NewGesture)));
+ }
+
+ if (V8ScriptRunner::callFunction(m_function.newLocal(isolate),
+ frame->document(),
+ m_receiver.newLocal(isolate), args.size(),
+ args.data(), toIsolate(frame))
+ .ToLocal(&singleResult))
+ results.append(singleResult);
+ }
return results;
}
@@ -158,8 +172,9 @@ void SuspendableScriptExecutor::createAndRun(
return;
}
SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(
- frame, callback, new V8FunctionExecutor(isolate, scriptState, function,
- receiver, argc, argv));
+ frame, callback, new V8FunctionExecutor(
+ isolate, scriptState, function, receiver, argc, argv,
+ UserGestureIndicator::processingUserGesture()));
executor->run();
}
« no previous file with comments | « extensions/renderer/user_gestures_native_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698