Update strings for turning off Smart Lock.
[chromium-blink-merge.git] / extensions / renderer / user_gestures_native_handler.cc
blob9875ac020748e39eea04ab5c47aadcce153cba37
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
3 // found in the LICENSE file.
5 #include "extensions/renderer/user_gestures_native_handler.h"
7 #include "base/bind.h"
8 #include "extensions/renderer/script_context.h"
9 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
10 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
12 namespace extensions {
14 UserGesturesNativeHandler::UserGesturesNativeHandler(ScriptContext* context)
15 : ObjectBackedNativeHandler(context) {
16 RouteFunction("IsProcessingUserGesture",
17 base::Bind(&UserGesturesNativeHandler::IsProcessingUserGesture,
18 base::Unretained(this)));
19 RouteFunction("RunWithUserGesture",
20 base::Bind(&UserGesturesNativeHandler::RunWithUserGesture,
21 base::Unretained(this)));
22 RouteFunction("RunWithoutUserGesture",
23 base::Bind(&UserGesturesNativeHandler::RunWithoutUserGesture,
24 base::Unretained(this)));
27 void UserGesturesNativeHandler::IsProcessingUserGesture(
28 const v8::FunctionCallbackInfo<v8::Value>& args) {
29 args.GetReturnValue().Set(v8::Boolean::New(
30 args.GetIsolate(),
31 blink::WebUserGestureIndicator::isProcessingUserGesture()));
34 void UserGesturesNativeHandler::RunWithUserGesture(
35 const v8::FunctionCallbackInfo<v8::Value>& args) {
36 blink::WebScopedUserGesture user_gesture;
37 CHECK_EQ(args.Length(), 1);
38 CHECK(args[0]->IsFunction());
39 v8::Handle<v8::Value> no_args;
40 context()->CallFunction(v8::Handle<v8::Function>::Cast(args[0]), 0, &no_args);
43 void UserGesturesNativeHandler::RunWithoutUserGesture(
44 const v8::FunctionCallbackInfo<v8::Value>& args) {
45 blink::WebUserGestureIndicator::consumeUserGesture();
46 CHECK_EQ(args.Length(), 1);
47 CHECK(args[0]->IsFunction());
48 v8::Handle<v8::Value> no_args;
49 context()->CallFunction(v8::Handle<v8::Function>::Cast(args[0]), 0, &no_args);
52 } // namespace extensions