OLD | NEW |
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 "content/shell/renderer/test_runner/gamepad_controller.h" | 5 #include "content/shell/renderer/test_runner/gamepad_controller.h" |
6 | 6 |
7 #include "content/shell/renderer/test_runner/web_test_delegate.h" | 7 #include "content/shell/renderer/test_runner/web_test_delegate.h" |
8 #include "gin/arguments.h" | 8 #include "gin/arguments.h" |
9 #include "gin/handle.h" | 9 #include "gin/handle.h" |
10 #include "gin/object_template_builder.h" | 10 #include "gin/object_template_builder.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 gin::WrapperInfo GamepadControllerBindings::kWrapperInfo = { | 54 gin::WrapperInfo GamepadControllerBindings::kWrapperInfo = { |
55 gin::kEmbedderNativeGin}; | 55 gin::kEmbedderNativeGin}; |
56 | 56 |
57 // static | 57 // static |
58 void GamepadControllerBindings::Install( | 58 void GamepadControllerBindings::Install( |
59 base::WeakPtr<GamepadController> controller, | 59 base::WeakPtr<GamepadController> controller, |
60 WebFrame* frame) { | 60 WebFrame* frame) { |
61 v8::Isolate* isolate = blink::mainThreadIsolate(); | 61 v8::Isolate* isolate = blink::mainThreadIsolate(); |
62 v8::HandleScope handle_scope(isolate); | 62 v8::HandleScope handle_scope(isolate); |
63 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 63 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
64 if (context.IsEmpty()) | 64 if (context.IsEmpty()) |
65 return; | 65 return; |
66 | 66 |
67 v8::Context::Scope context_scope(context); | 67 v8::Context::Scope context_scope(context); |
68 | 68 |
69 gin::Handle<GamepadControllerBindings> bindings = | 69 gin::Handle<GamepadControllerBindings> bindings = |
70 gin::CreateHandle(isolate, new GamepadControllerBindings(controller)); | 70 gin::CreateHandle(isolate, new GamepadControllerBindings(controller)); |
71 if (bindings.IsEmpty()) | 71 if (bindings.IsEmpty()) |
72 return; | 72 return; |
73 v8::Handle<v8::Object> global = context->Global(); | 73 v8::Local<v8::Object> global = context->Global(); |
74 global->Set(gin::StringToV8(isolate, "gamepadController"), bindings.ToV8()); | 74 global->Set(gin::StringToV8(isolate, "gamepadController"), bindings.ToV8()); |
75 } | 75 } |
76 | 76 |
77 GamepadControllerBindings::GamepadControllerBindings( | 77 GamepadControllerBindings::GamepadControllerBindings( |
78 base::WeakPtr<GamepadController> controller) | 78 base::WeakPtr<GamepadController> controller) |
79 : controller_(controller) {} | 79 : controller_(controller) {} |
80 | 80 |
81 GamepadControllerBindings::~GamepadControllerBindings() {} | 81 GamepadControllerBindings::~GamepadControllerBindings() {} |
82 | 82 |
83 gin::ObjectTemplateBuilder GamepadControllerBindings::GetObjectTemplateBuilder( | 83 gin::ObjectTemplateBuilder GamepadControllerBindings::GetObjectTemplateBuilder( |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 void GamepadController::SetAxisData(int index, int axis, double data) { | 249 void GamepadController::SetAxisData(int index, int axis, double data) { |
250 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 250 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
251 return; | 251 return; |
252 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) | 252 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) |
253 return; | 253 return; |
254 gamepads_.items[index].axes[axis] = data; | 254 gamepads_.items[index].axes[axis] = data; |
255 } | 255 } |
256 | 256 |
257 } // namespace content | 257 } // namespace content |
OLD | NEW |