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
3 // found in the LICENSE file.
5 #include "ui/keyboard/keyboard_ui_handler.h"
10 #include "base/logging.h"
11 #include "base/values.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_view.h"
14 #include "content/public/browser/web_ui.h"
15 #include "ui/aura/window.h"
16 #include "ui/keyboard/keyboard_util.h"
20 KeyboardUIHandler::KeyboardUIHandler() {
23 KeyboardUIHandler::~KeyboardUIHandler() {
26 void KeyboardUIHandler::RegisterMessages() {
27 web_ui()->RegisterMessageCallback(
29 base::Bind(&KeyboardUIHandler::HandleInsertTextMessage
,
30 base::Unretained(this)));
33 void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue
* args
) {
35 if (!args
->GetString(0, &text
)) {
36 LOG(ERROR
) << "insertText failed: bad argument";
40 aura::RootWindow
* root_window
=
41 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow();
43 LOG(ERROR
) << "insertText failed: no root window";
47 if (!keyboard::InsertText(text
, root_window
))
48 LOG(ERROR
) << "insertText failed";
51 } // namespace keyboard