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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/values.h" | |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_view.h" | 14 #include "content/public/browser/web_contents_view.h" |
14 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
15 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
16 #include "ui/base/events/event.h" | 17 #include "ui/base/events/event.h" |
17 #include "ui/keyboard/keyboard_util.h" | 18 #include "ui/keyboard/keyboard_util.h" |
18 | 19 |
19 namespace keyboard { | 20 namespace keyboard { |
20 | 21 |
21 KeyboardUIHandler::KeyboardUIHandler() { | 22 KeyboardUIHandler::KeyboardUIHandler() { |
22 } | 23 } |
23 | 24 |
24 KeyboardUIHandler::~KeyboardUIHandler() { | 25 KeyboardUIHandler::~KeyboardUIHandler() { |
25 } | 26 } |
26 | 27 |
27 void KeyboardUIHandler::RegisterMessages() { | 28 void KeyboardUIHandler::RegisterMessages() { |
28 web_ui()->RegisterMessageCallback( | 29 web_ui()->RegisterMessageCallback( |
30 "setKeyboardVisibility", | |
sadrul
2013/05/14 06:23:19
Will this be ever used to show the keyboard? i.e.
| |
31 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage, | |
32 base::Unretained(this))); | |
33 web_ui()->RegisterMessageCallback( | |
29 "sendKeyEvent", | 34 "sendKeyEvent", |
30 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage, | 35 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage, |
31 base::Unretained(this))); | 36 base::Unretained(this))); |
32 } | 37 } |
33 | 38 |
39 void KeyboardUIHandler::HandleSetKeyboardVisibility( | |
40 const base::ListValue* args) { | |
41 bool visible; | |
42 if (!args->GetBoolean(0, &visible)) { | |
43 LOG(ERROR) << "setKeyboardVisibility failed: argument parsing error"; | |
44 return; | |
45 } | |
46 // TODO(sadrul): get the KeyboardController without using the Shell | |
sadrul
2013/05/14 06:23:19
I can't think of a good way of doing this. One opt
| |
47 } | |
48 | |
34 void KeyboardUIHandler::HandleSendKeyEventMessage(const base::ListValue* args) { | 49 void KeyboardUIHandler::HandleSendKeyEventMessage(const base::ListValue* args) { |
35 std::string error; | 50 std::string error; |
36 scoped_ptr<ui::KeyEvent> event(keyboard::KeyEventFromArgs(args, &error)); | 51 scoped_ptr<ui::KeyEvent> event(keyboard::KeyEventFromArgs(args, &error)); |
37 if (!event) { | 52 if (!event) { |
38 LOG(ERROR) << "sendKeyEvent failed: " << error; | 53 LOG(ERROR) << "sendKeyEvent failed: " << error; |
39 return; | 54 return; |
40 } | 55 } |
41 | 56 |
42 aura::RootWindow* root_window = | 57 aura::RootWindow* root_window = |
43 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); | 58 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); |
44 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get()); | 59 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get()); |
45 } | 60 } |
46 | 61 |
47 } // namespace keyboard | 62 } // namespace keyboard |
OLD | NEW |