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

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: fix license headers 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
« no previous file with comments | « ui/keyboard/keyboard_ui_handler.h ('k') | ui/keyboard/keyboard_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_contents.h"
13 #include "content/public/browser/web_contents_view.h"
14 #include "content/public/browser/web_ui.h"
15 #include "ui/aura/root_window.h"
16 #include "ui/base/events/event.h"
17 #include "ui/keyboard/keyboard_util.h"
18
19 namespace keyboard {
20
21 KeyboardUIHandler::KeyboardUIHandler() {
22 }
23
24 KeyboardUIHandler::~KeyboardUIHandler() {
25 }
26
27 void KeyboardUIHandler::RegisterMessages() {
28 web_ui()->RegisterMessageCallback(
29 "sendKeyEvent",
30 base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage,
31 base::Unretained(this)));
32 }
33
34 void KeyboardUIHandler::HandleSendKeyEventMessage(const base::ListValue* args) {
35 std::string error;
36 scoped_ptr<ui::KeyEvent> event(keyboard::KeyEventFromArgs(args, &error));
37 if (!event) {
38 LOG(ERROR) << "sendKeyEvent failed: " << error;
39 return;
40 }
41
42 aura::RootWindow* root_window =
43 web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow();
44 root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get());
45 }
46
47 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_ui_handler.h ('k') | ui/keyboard/keyboard_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698