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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_view.h" | 13 #include "content/public/browser/web_contents_view.h" |
14 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/base/ime/input_method.h" | 18 #include "ui/base/ime/input_method.h" |
19 #include "ui/base/ime/text_input_client.h" | 19 #include "ui/base/ime/text_input_client.h" |
| 20 #include "ui/keyboard/keyboard_controller.h" |
20 #include "ui/keyboard/keyboard_util.h" | 21 #include "ui/keyboard/keyboard_util.h" |
21 | 22 |
22 namespace keyboard { | 23 namespace keyboard { |
23 | 24 |
24 KeyboardUIHandler::KeyboardUIHandler() { | 25 KeyboardUIHandler::KeyboardUIHandler() { |
25 } | 26 } |
26 | 27 |
27 KeyboardUIHandler::~KeyboardUIHandler() { | 28 KeyboardUIHandler::~KeyboardUIHandler() { |
28 } | 29 } |
29 | 30 |
30 void KeyboardUIHandler::RegisterMessages() { | 31 void KeyboardUIHandler::RegisterMessages() { |
31 web_ui()->RegisterMessageCallback( | 32 web_ui()->RegisterMessageCallback( |
32 "insertText", | 33 "insertText", |
33 base::Bind(&KeyboardUIHandler::HandleInsertTextMessage, | 34 base::Bind(&KeyboardUIHandler::HandleInsertTextMessage, |
34 base::Unretained(this))); | 35 base::Unretained(this))); |
35 web_ui()->RegisterMessageCallback( | 36 web_ui()->RegisterMessageCallback( |
36 "getInputContext", | 37 "getInputContext", |
37 base::Bind(&KeyboardUIHandler::HandleGetInputContextMessage, | 38 base::Bind(&KeyboardUIHandler::HandleGetInputContextMessage, |
38 base::Unretained(this))); | 39 base::Unretained(this))); |
39 web_ui()->RegisterMessageCallback( | 40 web_ui()->RegisterMessageCallback( |
40 "sendKeyEvent", | 41 "sendKeyEvent", |
41 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage, | 42 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage, |
42 base::Unretained(this))); | 43 base::Unretained(this))); |
43 | 44 web_ui()->RegisterMessageCallback( |
| 45 "hideKeyboard", |
| 46 base::Bind(&KeyboardUIHandler::HandleHideKeyboard, |
| 47 base::Unretained(this))); |
44 } | 48 } |
45 | 49 |
46 void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) { | 50 void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) { |
47 string16 text; | 51 string16 text; |
48 if (!args->GetString(0, &text)) { | 52 if (!args->GetString(0, &text)) { |
49 LOG(ERROR) << "insertText failed: bad argument"; | 53 LOG(ERROR) << "insertText failed: bad argument"; |
50 return; | 54 return; |
51 } | 55 } |
52 | 56 |
53 aura::RootWindow* root_window = | 57 aura::RootWindow* root_window = |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 122 |
119 if (!keyboard::SendKeyEvent(type, | 123 if (!keyboard::SendKeyEvent(type, |
120 char_value, | 124 char_value, |
121 key_code, | 125 key_code, |
122 shift_modifier, | 126 shift_modifier, |
123 root_window)) { | 127 root_window)) { |
124 LOG(ERROR) << "sendKeyEvent failed"; | 128 LOG(ERROR) << "sendKeyEvent failed"; |
125 } | 129 } |
126 } | 130 } |
127 | 131 |
| 132 void KeyboardUIHandler::HandleHideKeyboard(const base::ListValue* args) { |
| 133 // TODO(stevet): Call into the keyboard controller to hide the keyboard |
| 134 // directly. |
| 135 NOTIMPLEMENTED(); |
| 136 return; |
| 137 } |
| 138 |
128 } // namespace keyboard | 139 } // namespace keyboard |
OLD | NEW |