summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/ash/caps_lock_delegate_chromeos.h
blob: 8c8e8d8c1cd7c83f12d8d32f9d8aee56d8ed781b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 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_CAPS_LOCK_DELEGATE_CHROMEOS_H_
#define CHROME_BROWSER_UI_ASH_CAPS_LOCK_DELEGATE_CHROMEOS_H_

#include "ash/caps_lock_delegate.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/events/system_key_event_listener.h"

namespace chromeos {
namespace input_method {
class XKeyboard;
}  // namespace input_method
}  // namespace chromeos

// A class which toggles Caps Lock state when the hotkey for Caps Lock
// is pressed.
class CapsLockDelegate
    : public ash::CapsLockDelegate,
      public chromeos::SystemKeyEventListener::CapsLockObserver {
 public:
  explicit CapsLockDelegate(chromeos::input_method::XKeyboard* xkeyboard);
  virtual ~CapsLockDelegate();

  // Overridden from ash::CapsLockDelegate:
  virtual bool IsCapsLockEnabled() const OVERRIDE;
  virtual void SetCapsLockEnabled(bool enabled) OVERRIDE;
  virtual void ToggleCapsLock() OVERRIDE;

  // Overridden from chromeos::SystemKeyEventListener::CapsLockObserver:
  virtual void OnCapsLockChange(bool enabled) OVERRIDE;

  void set_is_running_on_chromeos_for_test(bool is_running_on_chromeos) {
    is_running_on_chromeos_ = is_running_on_chromeos;
  }

  bool caps_lock_is_on_for_test() const { return caps_lock_is_on_; }

 private:
  chromeos::input_method::XKeyboard* xkeyboard_;
  bool is_running_on_chromeos_;
  bool caps_lock_is_on_;

  DISALLOW_COPY_AND_ASSIGN(CapsLockDelegate);
};

#endif  // CHROME_BROWSER_UI_ASH_CAPS_LOCK_DELEGATE_CHROMEOS_H_