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/TestInterfaces.h" | 7 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
9 #include "gin/arguments.h" | 9 #include "gin/arguments.h" |
10 #include "gin/handle.h" | 10 #include "gin/handle.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Handle<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()) |
| 72 return; |
71 v8::Handle<v8::Object> global = context->Global(); | 73 v8::Handle<v8::Object> global = context->Global(); |
72 global->Set(gin::StringToV8(isolate, "gamepadController"), bindings.ToV8()); | 74 global->Set(gin::StringToV8(isolate, "gamepadController"), bindings.ToV8()); |
73 } | 75 } |
74 | 76 |
75 GamepadControllerBindings::GamepadControllerBindings( | 77 GamepadControllerBindings::GamepadControllerBindings( |
76 base::WeakPtr<GamepadController> controller) | 78 base::WeakPtr<GamepadController> controller) |
77 : controller_(controller) {} | 79 : controller_(controller) {} |
78 | 80 |
79 GamepadControllerBindings::~GamepadControllerBindings() {} | 81 GamepadControllerBindings::~GamepadControllerBindings() {} |
80 | 82 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 237 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
236 return; | 238 return; |
237 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) | 239 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) |
238 return; | 240 return; |
239 gamepads_.items[index].axes[axis] = data; | 241 gamepads_.items[index].axes[axis] = data; |
240 if (delegate_) | 242 if (delegate_) |
241 delegate_->setGamepadData(gamepads_); | 243 delegate_->setGamepadData(gamepads_); |
242 } | 244 } |
243 | 245 |
244 } // namespace content | 246 } // namespace content |
OLD | NEW |