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

Side by Side Diff: chrome/renderer/mock_keyboard.cc

Issue 92122: Implements keyboard events for RenderViewTest.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « chrome/renderer/mock_keyboard.h ('k') | chrome/renderer/mock_keyboard_driver_win.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) 2009 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 "chrome/renderer/mock_keyboard.h"
6
7 #include "base/logging.h"
8
9 MockKeyboard::MockKeyboard()
10 : keyboard_layout_(LAYOUT_NULL),
11 keyboard_modifiers_(INVALID) {
12 }
13
14 MockKeyboard::~MockKeyboard() {
15 }
16
17 int MockKeyboard::GetCharacters(Layout layout,
18 int key_code,
19 Modifiers modifiers,
20 std::wstring* output) {
21 #if defined(OS_WIN)
22 CHECK(output);
23 // Change the keyboard layout only when we have to because it takes a lot of
24 // time to load a keyboard-layout driver.
25 // When we change the layout, we reset the modifier status to force updating
26 // the keyboard status.
27 if (layout != keyboard_layout_) {
28 if (!driver_.SetLayout(layout))
29 return -1;
30 keyboard_layout_ = layout;
31 keyboard_modifiers_ = INVALID;
32 }
33
34 // Update the keyboard states.
35 if (modifiers != keyboard_modifiers_) {
36 if (!driver_.SetModifiers(modifiers))
37 return -1;
38 keyboard_modifiers_ = modifiers;
39 }
40
41 // Retrieve Unicode characters associate with the key code.
42 return driver_.GetCharacters(key_code, output);
43 #else
44 NOTIMPLEMENTED();
45 return -1;
46 #endif
47 }
OLDNEW
« no previous file with comments | « chrome/renderer/mock_keyboard.h ('k') | chrome/renderer/mock_keyboard_driver_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698