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

Side by Side Diff: chrome/browser/ui/views/ash/key_rewriter.h

Issue 9854025: Automatically remap Command key on an Apple keyboard to Control [part 2 of 2 - Chrome part] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_
6 #define CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11
12 #include "ash/key_rewriter_delegate.h"
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15
16 #if defined(OS_CHROMEOS)
17 #include "chrome/browser/chromeos/device_hierarchy_observer.h"
18 #endif
19
20 class KeyRewriter : public ash::KeyRewriterDelegate
21 #if defined(OS_CHROMEOS)
22 , public chromeos::DeviceHierarchyObserver
23 #endif
24 {
25 public:
26 enum DeviceType {
27 kDevicePcKeyboard = 0,
28 kDeviceAppleKeyboard,
29 };
30
31 KeyRewriter();
32 virtual ~KeyRewriter();
33
34 // Calls DeviceAddedInternal.
35 DeviceType DeviceAddedForTesting(int device_id,
36 const std::string& device_name);
37 // Calls RewriteCommandToControl.
38 void RewriteCommandToControlForTesting(aura::KeyEvent* event);
39
40 const std::map<int, DeviceType>& device_id_to_type_for_testing() const {
41 return device_id_to_type_;
42 }
43 void set_last_device_id_for_testing(int device_id) {
44 last_device_id_ = device_id;
45 }
46
47 // Gets DeviceType from the |device_name|.
48 static DeviceType GetDeviceType(const std::string& device_name);
49
50 private:
51 // ash::KeyRewriterDelegate overrides:
52 virtual ash::KeyRewriterDelegate::Action RewriteOrFilterKeyEvent(
53 aura::KeyEvent* event) OVERRIDE;
54
55 #if defined(OS_CHROMEOS)
56 // chromeos::DeviceHierarchyObserver overrides:
57 virtual void DeviceHierarchyChanged() OVERRIDE {}
58 virtual void DeviceAdded(int device_id) OVERRIDE;
59 virtual void KeyPressedOrReleased(int device_id) OVERRIDE;
60 #endif
61
62 // Rewrites Comment-L/R key presses on an Apple keyboard to Control-L/R. Only
63 // OS_CHROMEOS implementation is available at this point.
64 void RewriteCommandToControl(aura::KeyEvent* event);
65
66 // Checks the type of the |device_name|, and inserts a new entry to
67 // |device_id_to_type_|.
68 DeviceType DeviceAddedInternal(int device_id, const std::string& device_name);
69
70 std::map<int, DeviceType> device_id_to_type_;
71 int last_device_id_;
72
73 DISALLOW_COPY_AND_ASSIGN(KeyRewriter);
74 };
75
76 #endif // CHROME_BROWSER_UI_VIEWS_ASH_KEY_REWRITER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc ('k') | chrome/browser/ui/views/ash/key_rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698