Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: ui/keyboard/keyboard_ui_handler.cc

Issue 14161009: WebUIHandler for chrome://keyboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "ui/keyboard/keyboard_ui_handler.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_ui.h"
13 #include "ui/aura/root_window.h"
14 #include "ui/base/events/event.h"
15 #include "ui/keyboard/keyboard_util.h"
16
17 namespace keyboard {
18
19 KeyboardUIHandler::KeyboardUIHandler() : root_window_(NULL) {
20 }
21
22 KeyboardUIHandler::KeyboardUIHandler(aura::RootWindow* root_window)
23 : root_window_(root_window) {
24 }
25
26 KeyboardUIHandler::~KeyboardUIHandler() {
27 }
28
29 void KeyboardUIHandler::RegisterMessages() {
30 web_ui()->RegisterMessageCallback(
31 "sendKeyEvent",
32 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage,
33 base::Unretained(this)));
34 }
35
36 void KeyboardUIHandler::HandleSendKeyEventMessage(const base::ListValue* args) {
37 std::string error;
38 scoped_ptr<ui::KeyEvent> event(keyboard::KeyEventFromArgs(args, &error));
39 if (!event) {
40 LOG(ERROR) << "sendKeyEvent failed: " << error;
41 return;
42 }
43
44 if (root_window_) {
45 root_window_->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get());
46 } else {
47 DLOG(INFO) << "KeyboardUIHandler handling sendKeyEvent: key_code="
48 << event->key_code();
49 }
50 }
51
52 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698