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_ASH_CAPS_LOCK_DELEGATE_CHROMEOS_H_ 6 #define CHROME_BROWSER_UI_ASH_CAPS_LOCK_DELEGATE_CHROMEOS_H_ 7 8 #include "ash/caps_lock_delegate.h" 9 #include "base/basictypes.h" 10 #include "base/compiler_specific.h" 11 #include "chrome/browser/chromeos/system_key_event_listener.h" 12 13 namespace chromeos { 14 namespace input_method { 15 class XKeyboard; 16 } // namespace input_method 17 } // namespace chromeos 18 19 // A class which toggles Caps Lock state when the hotkey for Caps Lock 20 // is pressed. 21 class CapsLockDelegate 22 : public ash::CapsLockDelegate, 23 public chromeos::SystemKeyEventListener::CapsLockObserver { 24 public: 25 explicit CapsLockDelegate(chromeos::input_method::XKeyboard* xkeyboard); 26 virtual ~CapsLockDelegate(); 27 28 // Overridden from ash::CapsLockDelegate: 29 virtual bool IsCapsLockEnabled() const OVERRIDE; 30 virtual void SetCapsLockEnabled(bool enabled) OVERRIDE; 31 virtual void ToggleCapsLock() OVERRIDE; 32 33 // Overridden from chromeos::SystemKeyEventListener::CapsLockObserver: 34 virtual void OnCapsLockChange(bool enabled) OVERRIDE; 35 36 void set_is_running_on_chromeos_for_test(bool is_running_on_chromeos) { 37 is_running_on_chromeos_ = is_running_on_chromeos; 38 } 39 40 bool caps_lock_is_on_for_test() const { return caps_lock_is_on_; } 41 42 private: 43 chromeos::input_method::XKeyboard* xkeyboard_; 44 bool is_running_on_chromeos_; 45 bool caps_lock_is_on_; 46 47 DISALLOW_COPY_AND_ASSIGN(CapsLockDelegate); 48 }; 49 50 #endif // CHROME_BROWSER_UI_ASH_CAPS_LOCK_DELEGATE_CHROMEOS_H_ 51