| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/aura/caps_lock_handler.h" | 5 #include "chrome/browser/ui/views/aura/caps_lock_handler.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 | 8 |
| 9 // TODO(yusukes): Support Ash on Windows. | 9 // TODO(yusukes): Support Ash on Windows. |
| 10 #if defined(OS_CHROMEOS) | 10 #if defined(OS_CHROMEOS) |
| 11 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 12 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 12 #include "chrome/browser/chromeos/system/runtime_environment.h" | 13 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/common/pref_names.h" |
| 13 #endif | 16 #endif |
| 14 | 17 |
| 15 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 16 CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard) | 19 CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard) |
| 17 : xkeyboard_(xkeyboard), | 20 : xkeyboard_(xkeyboard), |
| 18 is_running_on_chromeos_( | 21 is_running_on_chromeos_( |
| 19 chromeos::system::runtime_environment::IsRunningOnChromeOS()), | 22 chromeos::system::runtime_environment::IsRunningOnChromeOS()), |
| 20 caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled()) { | 23 caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled()) { |
| 21 chromeos::SystemKeyEventListener* system_event_listener = | 24 chromeos::SystemKeyEventListener* system_event_listener = |
| 22 chromeos::SystemKeyEventListener::GetInstance(); | 25 chromeos::SystemKeyEventListener::GetInstance(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 chromeos::SystemKeyEventListener* system_event_listener = | 36 chromeos::SystemKeyEventListener* system_event_listener = |
| 34 chromeos::SystemKeyEventListener::GetInstance(); | 37 chromeos::SystemKeyEventListener::GetInstance(); |
| 35 if (system_event_listener) | 38 if (system_event_listener) |
| 36 system_event_listener->RemoveCapsLockObserver(this); | 39 system_event_listener->RemoveCapsLockObserver(this); |
| 37 #endif | 40 #endif |
| 38 } | 41 } |
| 39 | 42 |
| 40 bool CapsLockHandler::HandleToggleCapsLock() { | 43 bool CapsLockHandler::HandleToggleCapsLock() { |
| 41 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 45 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 43 if (is_running_on_chromeos_) { | 46 if (is_running_on_chromeos_ && |
| 44 // TODO(yusukes): Do not change Caps Lock status and just return false if | 47 // When spoken feedback is enabled, the Search key is used as an |
| 45 // spoken feedback is enabled (crosbug.com/110127). | 48 // accessibility modifier key. |
| 49 !g_browser_process->local_state()->GetBoolean( |
| 50 prefs::kSpokenFeedbackEnabled)) { |
| 46 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_); | 51 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_); |
| 47 return true; // consume the shortcut key. | 52 return true; // consume the shortcut key. |
| 48 } | 53 } |
| 49 #else | 54 #else |
| 50 NOTIMPLEMENTED(); | 55 NOTIMPLEMENTED(); |
| 51 #endif | 56 #endif |
| 52 return false; | 57 return false; |
| 53 } | 58 } |
| 54 | 59 |
| 55 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
| 56 void CapsLockHandler::OnCapsLockChange(bool enabled) { | 61 void CapsLockHandler::OnCapsLockChange(bool enabled) { |
| 57 caps_lock_is_on_ = enabled; | 62 caps_lock_is_on_ = enabled; |
| 58 } | 63 } |
| 59 #endif | 64 #endif |
| OLD | NEW |