Index: chrome/browser/chromeos/event_rewriter.h |
diff --git a/chrome/browser/ui/ash/event_rewriter.h b/chrome/browser/chromeos/event_rewriter.h |
similarity index 70% |
rename from chrome/browser/ui/ash/event_rewriter.h |
rename to chrome/browser/chromeos/event_rewriter.h |
index f08507582a83135d4e6027e22b6762f449777bf4..396911a73ecf5e21f7cc3a54d22966932841aed2 100644 |
--- a/chrome/browser/ui/ash/event_rewriter.h |
+++ b/chrome/browser/chromeos/event_rewriter.h |
@@ -1,49 +1,39 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
-#define CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
+#ifndef CHROME_BROWSER_CHROMEOS_EVENT_REWRITER_H_ |
+#define CHROME_BROWSER_CHROMEOS_EVENT_REWRITER_H_ |
#include <map> |
#include <set> |
#include <string> |
-#include "ash/event_rewriter_delegate.h" |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
#include "base/containers/hash_tables.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/message_loop/message_pump_observer.h" |
+#include "chrome/browser/chromeos/device_hierarchy_observer.h" |
#include "ui/aura/root_window_observer.h" |
#include "ui/events/keycodes/keyboard_codes.h" |
-#if defined(OS_CHROMEOS) |
-#include "chrome/browser/chromeos/device_hierarchy_observer.h" |
-#endif |
- |
class PrefService; |
+typedef union _XEvent XEvent; |
namespace aura { |
class RootWindow; |
} |
-#if defined(OS_CHROMEOS) |
namespace chromeos { |
- |
class KeyboardDrivenEventRewriter; |
- |
namespace input_method { |
class XKeyboard; |
} |
-} |
-#endif |
- |
-class EventRewriter : public ash::EventRewriterDelegate, |
- public aura::RootWindowObserver |
-#if defined(OS_CHROMEOS) |
- , public chromeos::DeviceHierarchyObserver |
-#endif |
-{ |
+ |
+class EventRewriter : public aura::RootWindowObserver, |
+ public DeviceHierarchyObserver, |
+ public base::MessagePumpObserver { |
public: |
enum DeviceType { |
kDeviceUnknown = 0, |
@@ -57,7 +47,7 @@ class EventRewriter : public ash::EventRewriterDelegate, |
DeviceType DeviceAddedForTesting(int device_id, |
const std::string& device_name); |
// Calls Rewrite. |
- void RewriteForTesting(ui::KeyEvent* event); |
+ void RewriteForTesting(XEvent* event); |
const std::map<int, DeviceType>& device_id_to_type_for_testing() const { |
return device_id_to_type_; |
@@ -68,11 +58,9 @@ class EventRewriter : public ash::EventRewriterDelegate, |
void set_pref_service_for_testing(const PrefService* pref_service) { |
pref_service_for_testing_ = pref_service; |
} |
-#if defined(OS_CHROMEOS) |
- void set_xkeyboard_for_testing(chromeos::input_method::XKeyboard* xkeyboard) { |
+ void set_xkeyboard_for_testing(input_method::XKeyboard* xkeyboard) { |
xkeyboard_for_testing_ = xkeyboard; |
} |
-#endif |
// Gets DeviceType from the |device_name|. |
static DeviceType GetDeviceType(const std::string& device_name); |
@@ -81,17 +69,15 @@ class EventRewriter : public ash::EventRewriterDelegate, |
friend class EventRewriterAshTest; |
friend class EventRewriterTest; |
- // ash::EventRewriterDelegate overrides: |
- virtual ash::EventRewriterDelegate::Action RewriteOrFilterKeyEvent( |
- ui::KeyEvent* event) OVERRIDE; |
- virtual ash::EventRewriterDelegate::Action RewriteOrFilterLocatedEvent( |
- ui::LocatedEvent* event) OVERRIDE; |
- |
// aura::RootWindowObserver overrides: |
virtual void OnKeyboardMappingChanged(const aura::RootWindow* root) OVERRIDE; |
-#if defined(OS_CHROMEOS) |
- // chromeos::DeviceHierarchyObserver overrides: |
+ // base::MessagePumpObserver overrides: |
+ virtual base::EventStatus WillProcessEvent( |
+ const base::NativeEvent& event) OVERRIDE; |
+ virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; |
+ |
+ // DeviceHierarchyObserver overrides: |
virtual void DeviceHierarchyChanged() OVERRIDE {} |
virtual void DeviceAdded(int device_id) OVERRIDE; |
virtual void DeviceRemoved(int device_id) OVERRIDE; |
@@ -109,11 +95,8 @@ class EventRewriter : public ash::EventRewriterDelegate, |
struct KeyboardRemapping { |
KeySym input_keysym; |
- unsigned int input_mods; |
unsigned int input_native_mods; |
KeySym output_keysym; |
- ui::KeyboardCode output_keycode; |
- unsigned int output_mods; |
unsigned int output_native_mods; |
}; |
@@ -121,7 +104,7 @@ class EventRewriter : public ash::EventRewriterDelegate, |
// keys instead of having them rewritten into back, forward, brightness, |
// volume, etc. or if the user has specified that they desire top-row keys to |
// be treated as function keys globally. |
- bool TopRowKeysAreFunctionKeys(ui::KeyEvent* event) const; |
+ bool TopRowKeysAreFunctionKeys(XEvent* event) const; |
// Given a set of KeyboardRemapping structs, it finds a matching struct |
// if possible, and updates the remapped event values. Returns true if a |
@@ -131,11 +114,8 @@ class EventRewriter : public ash::EventRewriterDelegate, |
size_t num_remappings, |
KeySym keysym, |
unsigned int native_mods, |
- unsigned int mods, |
KeySym* remapped_native_keysym, |
- unsigned int* remapped_native_mods, |
- ui::KeyboardCode* remapped_keycode, |
- unsigned int* remapped_mods); |
+ unsigned int* remapped_native_mods); |
// Given a set of KeyboardRemapping structs, it finds a matching struct |
// if possible, and updates the remapped event values. This function converts |
@@ -147,31 +127,27 @@ class EventRewriter : public ash::EventRewriterDelegate, |
size_t num_remappings, |
KeyCode keycode, |
unsigned int native_mods, |
- unsigned int mods, |
KeySym* remapped_native_keysym, |
- unsigned int* remapped_native_mods, |
- ui::KeyboardCode* remapped_keycode, |
- unsigned int* remapped_mods); |
-#endif |
+ unsigned int* remapped_native_mods); |
// Returns the PrefService that should be used. |
const PrefService* GetPrefService() const; |
// Rewrites the |event| by applying all RewriteXXX functions as needed. |
- void Rewrite(ui::KeyEvent* event); |
+ void Rewrite(XEvent* event); |
// Rewrites a modifier key press/release following the current user |
// preferences. |
- bool RewriteModifiers(ui::KeyEvent* event); |
+ bool RewriteModifiers(XEvent* event); |
// Rewrites Fn key press/release to Control. In some cases, Fn key is not |
// intercepted by the EC, but generates a key event like "XK_F15 + Mod3Mask" |
// as shown in crosbug.com/p/14339. |
- bool RewriteFnKey(ui::KeyEvent* event); |
+ bool RewriteFnKey(XEvent* event); |
// Rewrites a NumPad key press/release without Num Lock to a corresponding key |
// press/release with the lock. Returns true when |event| is rewritten. |
- bool RewriteNumPadKeys(ui::KeyEvent* event); |
+ bool RewriteNumPadKeys(XEvent* event); |
// Rewrites Backspace and Arrow keys following the Chrome OS keyboard spec. |
// * Alt+Backspace -> Delete |
@@ -187,22 +163,20 @@ class EventRewriter : public ash::EventRewriterDelegate, |
// * Search+Right -> End |
// * Search+. -> Insert |
// Returns true when the |event| is rewritten. |
- bool RewriteExtendedKeys(ui::KeyEvent* event); |
+ bool RewriteExtendedKeys(XEvent* event); |
// When the Search key acts as a function key, it remaps Search+1 |
// through Search+= to F1 through F12. Returns true when the |event| is |
// rewritten. |
- bool RewriteFunctionKeys(ui::KeyEvent* event); |
+ bool RewriteFunctionKeys(XEvent* event); |
// Rewrites the located |event|. |
- void RewriteLocatedEvent(ui::LocatedEvent* event); |
+ void RewriteLocatedEvent(XEvent* event); |
// Overwrites |event| with the keycodes and flags. |
- void OverwriteEvent(ui::KeyEvent* event, |
+ void OverwriteEvent(XEvent* event, |
unsigned int new_native_keycode, |
- unsigned int new_native_state, |
- ui::KeyboardCode new_keycode, |
- int new_flags); |
+ unsigned int new_native_state); |
// Checks the type of the |device_name|, and inserts a new entry to |
// |device_id_to_type_|. |
@@ -211,32 +185,30 @@ class EventRewriter : public ash::EventRewriterDelegate, |
// Returns true if |last_device_id_| is Apple's. |
bool IsAppleKeyboard() const; |
- // Remaps |original_flags| to |remapped_flags| and |original_native_modifiers| |
- // to |remapped_native_modifiers| following the current user prefs. |
- void GetRemappedModifierMasks(int original_flags, |
- unsigned int original_native_modifiers, |
- int* remapped_flags, |
+ // Remaps |original_native_modifiers| to |remapped_native_modifiers| following |
+ // the current user prefs. |
+ void GetRemappedModifierMasks(unsigned int original_native_modifiers, |
unsigned int* remapped_native_modifiers) const; |
std::map<int, DeviceType> device_id_to_type_; |
int last_device_id_; |
-#if defined(OS_CHROMEOS) |
// A mapping from X11 KeySym keys to KeyCode values. |
base::hash_map<unsigned long, unsigned long> keysym_to_keycode_map_; |
// A set of device IDs whose press event has been rewritten. |
std::set<int> pressed_device_ids_; |
- chromeos::input_method::XKeyboard* xkeyboard_for_testing_; |
+ input_method::XKeyboard* xkeyboard_for_testing_; |
- scoped_ptr<chromeos::KeyboardDrivenEventRewriter> |
+ scoped_ptr<KeyboardDrivenEventRewriter> |
keyboard_driven_event_rewriter_; |
-#endif |
const PrefService* pref_service_for_testing_; |
DISALLOW_COPY_AND_ASSIGN(EventRewriter); |
}; |
-#endif // CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_EVENT_REWRITER_H_ |