| 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 "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" | 5 #include "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 .SetMethod("getKeyboardConfig", &VKBindings::NotImplemented); | 136 .SetMethod("getKeyboardConfig", &VKBindings::NotImplemented); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void SendKeyEvent(gin::Arguments* args) { | 139 void SendKeyEvent(gin::Arguments* args) { |
| 140 VKEvent event; | 140 VKEvent event; |
| 141 if (!args->GetNext(&event)) { | 141 if (!args->GetNext(&event)) { |
| 142 LOG(ERROR) << "Failed to get the type"; | 142 LOG(ERROR) << "Failed to get the type"; |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 base::ListValue params; | 145 base::ListValue params; |
| 146 params.Set(0, base::Value::CreateStringValue(event.event_type)); | 146 params.Set(0, new base::StringValue(event.event_type)); |
| 147 params.Set(1, base::Value::CreateIntegerValue(event.char_value)); | 147 params.Set(1, new base::FundamentalValue(event.char_value)); |
| 148 params.Set(2, base::Value::CreateIntegerValue(event.key_code)); | 148 params.Set(2, new base::FundamentalValue(event.key_code)); |
| 149 params.Set(3, base::Value::CreateStringValue(event.key_name)); | 149 params.Set(3, new base::StringValue(event.key_name)); |
| 150 params.Set(4, base::Value::CreateIntegerValue(event.modifiers)); | 150 params.Set(4, new base::FundamentalValue(event.modifiers)); |
| 151 | 151 |
| 152 std::string params_json; | 152 std::string params_json; |
| 153 JSONStringValueSerializer serializer(¶ms_json); | 153 JSONStringValueSerializer serializer(¶ms_json); |
| 154 if (!serializer.Serialize(params)) | 154 if (!serializer.Serialize(params)) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 render_view_->GetMainRenderFrame()->ExecuteJavaScript( | 157 render_view_->GetMainRenderFrame()->ExecuteJavaScript( |
| 158 base::UTF8ToUTF16("chrome.send('sendKeyEvent', " + params_json + ")")); | 158 base::UTF8ToUTF16("chrome.send('sendKeyEvent', " + params_json + ")")); |
| 159 } | 159 } |
| 160 | 160 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 } // namespace | 195 } // namespace |
| 196 | 196 |
| 197 VirtualKeyboardBindings* VirtualKeyboardBindings::Create( | 197 VirtualKeyboardBindings* VirtualKeyboardBindings::Create( |
| 198 content::RenderView* render_view) { | 198 content::RenderView* render_view) { |
| 199 return new VirtualKeyboardBindingsImpl(render_view); | 199 return new VirtualKeyboardBindingsImpl(render_view); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace athena | 202 } // namespace athena |
| OLD | NEW |