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

Side by Side Diff: extensions/renderer/user_gestures_native_handler.cc

Issue 2454433002: [Extensions + Blink] Account for user gesture in v8 function calls (Closed)
Patch Set: whoops Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/renderer/user_gestures_native_handler.h" 5 #include "extensions/renderer/user_gestures_native_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "extensions/renderer/script_context.h" 8 #include "extensions/renderer/script_context.h"
9 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" 9 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
10 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 10 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
(...skipping 21 matching lines...) Expand all
32 args.GetReturnValue().Set(v8::Boolean::New( 32 args.GetReturnValue().Set(v8::Boolean::New(
33 args.GetIsolate(), 33 args.GetIsolate(),
34 blink::WebUserGestureIndicator::isProcessingUserGesture())); 34 blink::WebUserGestureIndicator::isProcessingUserGesture()));
35 } 35 }
36 36
37 void UserGesturesNativeHandler::RunWithUserGesture( 37 void UserGesturesNativeHandler::RunWithUserGesture(
38 const v8::FunctionCallbackInfo<v8::Value>& args) { 38 const v8::FunctionCallbackInfo<v8::Value>& args) {
39 blink::WebScopedUserGesture user_gesture(context()->web_frame()); 39 blink::WebScopedUserGesture user_gesture(context()->web_frame());
40 CHECK_EQ(args.Length(), 1); 40 CHECK_EQ(args.Length(), 1);
41 CHECK(args[0]->IsFunction()); 41 CHECK(args[0]->IsFunction());
42 v8::Local<v8::Value> no_args; 42 context()->CallFunctionSafe(v8::Local<v8::Function>::Cast(args[0]), 0,
haraken 2016/10/28 08:45:14 Where is CallFunctionSafe defined? I couldn't find
Devlin 2016/10/28 15:00:05 D'oh - this is supposed to be SafeCallFunction() (
43 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); 43 nullptr);
44 } 44 }
45 45
46 void UserGesturesNativeHandler::RunWithoutUserGesture( 46 void UserGesturesNativeHandler::RunWithoutUserGesture(
47 const v8::FunctionCallbackInfo<v8::Value>& args) { 47 const v8::FunctionCallbackInfo<v8::Value>& args) {
48 blink::WebUserGestureIndicator::consumeUserGesture(); 48 blink::WebUserGestureIndicator::consumeUserGesture();
49 CHECK_EQ(args.Length(), 1); 49 CHECK_EQ(args.Length(), 1);
50 CHECK(args[0]->IsFunction()); 50 CHECK(args[0]->IsFunction());
51 v8::Local<v8::Value> no_args; 51 v8::Local<v8::Value> no_args;
52 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); 52 context()->CallFunctionSafe(v8::Local<v8::Function>::Cast(args[0]), 0,
53 nullptr);
53 } 54 }
54 55
55 } // namespace extensions 56 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698