| Index: chrome/browser/ui/ash/caps_lock_handler.cc
|
| diff --git a/chrome/browser/ui/ash/caps_lock_handler.cc b/chrome/browser/ui/ash/caps_lock_handler.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1533d55090ed47a68706434109d7675a877a72fd
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/ash/caps_lock_handler.cc
|
| @@ -0,0 +1,64 @@
|
| +// 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.
|
| +
|
| +#include "chrome/browser/ui/ash/caps_lock_handler.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +
|
| +// TODO(yusukes): Support Ash on Windows.
|
| +#if defined(OS_CHROMEOS)
|
| +#include "base/chromeos/chromeos_version.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/chromeos/input_method/xkeyboard.h"
|
| +#include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#endif
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard)
|
| + : xkeyboard_(xkeyboard),
|
| + is_running_on_chromeos_(base::chromeos::IsRunningOnChromeOS()),
|
| + caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled()) {
|
| + chromeos::SystemKeyEventListener* system_event_listener =
|
| + chromeos::SystemKeyEventListener::GetInstance();
|
| + // SystemKeyEventListener should be instantiated when we're running on Chrome
|
| + // OS.
|
| + DCHECK(!is_running_on_chromeos_ || system_event_listener);
|
| + if (system_event_listener)
|
| + system_event_listener->AddCapsLockObserver(this);
|
| +}
|
| +#endif
|
| +
|
| +CapsLockHandler::~CapsLockHandler() {
|
| +#if defined(OS_CHROMEOS)
|
| + chromeos::SystemKeyEventListener* system_event_listener =
|
| + chromeos::SystemKeyEventListener::GetInstance();
|
| + if (system_event_listener)
|
| + system_event_listener->RemoveCapsLockObserver(this);
|
| +#endif
|
| +}
|
| +
|
| +bool CapsLockHandler::HandleToggleCapsLock() {
|
| +#if defined(OS_CHROMEOS)
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| + if (is_running_on_chromeos_ &&
|
| + // When spoken feedback is enabled, the Search key is used as an
|
| + // accessibility modifier key.
|
| + !g_browser_process->local_state()->GetBoolean(
|
| + prefs::kSpokenFeedbackEnabled)) {
|
| + xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_);
|
| + return true; // consume the shortcut key.
|
| + }
|
| +#else
|
| + NOTIMPLEMENTED();
|
| +#endif
|
| + return false;
|
| +}
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +void CapsLockHandler::OnCapsLockChange(bool enabled) {
|
| + caps_lock_is_on_ = enabled;
|
| +}
|
| +#endif
|
|
|