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

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

Issue 1843803002: [Extensions] Add an access check before executing native code in the renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 UserGesturesNativeHandler::UserGesturesNativeHandler(ScriptContext* context) 14 UserGesturesNativeHandler::UserGesturesNativeHandler(ScriptContext* context)
15 : ObjectBackedNativeHandler(context) { 15 : ObjectBackedNativeHandler(context) {
16 RouteFunction("IsProcessingUserGesture", 16 RouteFunction("IsProcessingUserGesture",
17 "test",
Devlin 2016/03/30 22:02:28 Ideally, we'd be able to attribute all the native
17 base::Bind(&UserGesturesNativeHandler::IsProcessingUserGesture, 18 base::Bind(&UserGesturesNativeHandler::IsProcessingUserGesture,
18 base::Unretained(this))); 19 base::Unretained(this)));
19 RouteFunction("RunWithUserGesture", 20 RouteFunction("RunWithUserGesture",
21 "test",
20 base::Bind(&UserGesturesNativeHandler::RunWithUserGesture, 22 base::Bind(&UserGesturesNativeHandler::RunWithUserGesture,
21 base::Unretained(this))); 23 base::Unretained(this)));
22 RouteFunction("RunWithoutUserGesture", 24 RouteFunction("RunWithoutUserGesture",
25 "test",
23 base::Bind(&UserGesturesNativeHandler::RunWithoutUserGesture, 26 base::Bind(&UserGesturesNativeHandler::RunWithoutUserGesture,
24 base::Unretained(this))); 27 base::Unretained(this)));
25 } 28 }
26 29
27 void UserGesturesNativeHandler::IsProcessingUserGesture( 30 void UserGesturesNativeHandler::IsProcessingUserGesture(
28 const v8::FunctionCallbackInfo<v8::Value>& args) { 31 const v8::FunctionCallbackInfo<v8::Value>& args) {
29 args.GetReturnValue().Set(v8::Boolean::New( 32 args.GetReturnValue().Set(v8::Boolean::New(
30 args.GetIsolate(), 33 args.GetIsolate(),
31 blink::WebUserGestureIndicator::isProcessingUserGesture())); 34 blink::WebUserGestureIndicator::isProcessingUserGesture()));
32 } 35 }
(...skipping 10 matching lines...) Expand all
43 void UserGesturesNativeHandler::RunWithoutUserGesture( 46 void UserGesturesNativeHandler::RunWithoutUserGesture(
44 const v8::FunctionCallbackInfo<v8::Value>& args) { 47 const v8::FunctionCallbackInfo<v8::Value>& args) {
45 blink::WebUserGestureIndicator::consumeUserGesture(); 48 blink::WebUserGestureIndicator::consumeUserGesture();
46 CHECK_EQ(args.Length(), 1); 49 CHECK_EQ(args.Length(), 1);
47 CHECK(args[0]->IsFunction()); 50 CHECK(args[0]->IsFunction());
48 v8::Local<v8::Value> no_args; 51 v8::Local<v8::Value> no_args;
49 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args); 52 context()->CallFunction(v8::Local<v8::Function>::Cast(args[0]), 0, &no_args);
50 } 53 }
51 54
52 } // namespace extensions 55 } // namespace extensions
OLDNEW
« extensions/renderer/script_context.cc ('K') | « extensions/renderer/script_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698