| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_ui_handler.h" | 5 #include "ui/keyboard/keyboard_ui_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 base::Unretained(this))); | 47 base::Unretained(this))); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) { | 50 void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) { |
| 51 string16 text; | 51 string16 text; |
| 52 if (!args->GetString(0, &text)) { | 52 if (!args->GetString(0, &text)) { |
| 53 LOG(ERROR) << "insertText failed: bad argument"; | 53 LOG(ERROR) << "insertText failed: bad argument"; |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 | 56 |
| 57 aura::RootWindow* root_window = | 57 aura::Window* root_window = |
| 58 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); | 58 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); |
| 59 if (!root_window) { | 59 if (!root_window) { |
| 60 LOG(ERROR) << "insertText failed: no root window"; | 60 LOG(ERROR) << "insertText failed: no root window"; |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 if (!keyboard::InsertText(text, root_window)) | 64 if (!keyboard::InsertText(text, root_window)) |
| 65 LOG(ERROR) << "insertText failed"; | 65 LOG(ERROR) << "insertText failed"; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void KeyboardUIHandler::HandleGetInputContextMessage( | 68 void KeyboardUIHandler::HandleGetInputContextMessage( |
| 69 const base::ListValue* args) { | 69 const base::ListValue* args) { |
| 70 int request_id; | 70 int request_id; |
| 71 if (!args->GetInteger(0, &request_id)) { | 71 if (!args->GetInteger(0, &request_id)) { |
| 72 LOG(ERROR) << "getInputContext failed: bad argument"; | 72 LOG(ERROR) << "getInputContext failed: bad argument"; |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 base::DictionaryValue results; | 75 base::DictionaryValue results; |
| 76 results.SetInteger("requestId", request_id); | 76 results.SetInteger("requestId", request_id); |
| 77 | 77 |
| 78 aura::RootWindow* root_window = | 78 aura::Window* root_window = |
| 79 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); | 79 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); |
| 80 if (!root_window) { | 80 if (!root_window) { |
| 81 LOG(ERROR) << "getInputContext failed: no root window"; | 81 LOG(ERROR) << "getInputContext failed: no root window"; |
| 82 return; | 82 return; |
| 83 } | 83 } |
| 84 ui::InputMethod* input_method = | 84 ui::InputMethod* input_method = |
| 85 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 85 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
| 86 if (!input_method) { | 86 if (!input_method) { |
| 87 LOG(ERROR) << "getInputContext failed: no input method"; | 87 LOG(ERROR) << "getInputContext failed: no input method"; |
| 88 return; | 88 return; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 if (!args->GetDictionary(0, ¶ms) || | 107 if (!args->GetDictionary(0, ¶ms) || |
| 108 !params->GetString("type", &type) || | 108 !params->GetString("type", &type) || |
| 109 !params->GetInteger("charValue", &char_value) || | 109 !params->GetInteger("charValue", &char_value) || |
| 110 !params->GetInteger("keyCode", &key_code) || | 110 !params->GetInteger("keyCode", &key_code) || |
| 111 !params->GetBoolean("shiftKey", &shift_modifier)) { | 111 !params->GetBoolean("shiftKey", &shift_modifier)) { |
| 112 LOG(ERROR) << "SendKeyEvent failed: bad argument"; | 112 LOG(ERROR) << "SendKeyEvent failed: bad argument"; |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 aura::RootWindow* root_window = | 116 aura::WindowEventDispatcher* dispatcher = |
| 117 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); | 117 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetDispatcher(); |
| 118 if (!root_window) { | 118 if (!dispatcher) { |
| 119 LOG(ERROR) << "sendKeyEvent failed: no root window"; | 119 LOG(ERROR) << "sendKeyEvent failed: no dispatcher"; |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 if (!keyboard::SendKeyEvent(type, | 123 if (!keyboard::SendKeyEvent(type, |
| 124 char_value, | 124 char_value, |
| 125 key_code, | 125 key_code, |
| 126 shift_modifier, | 126 shift_modifier, |
| 127 root_window)) { | 127 dispatcher)) { |
| 128 LOG(ERROR) << "sendKeyEvent failed"; | 128 LOG(ERROR) << "sendKeyEvent failed"; |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 void KeyboardUIHandler::HandleHideKeyboard(const base::ListValue* args) { | 132 void KeyboardUIHandler::HandleHideKeyboard(const base::ListValue* args) { |
| 133 // TODO(stevet): Call into the keyboard controller to hide the keyboard | 133 // TODO(stevet): Call into the keyboard controller to hide the keyboard |
| 134 // directly. | 134 // directly. |
| 135 NOTIMPLEMENTED(); | 135 NOTIMPLEMENTED(); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace keyboard | 139 } // namespace keyboard |
| OLD | NEW |