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 !g_browser_process->local_state()->GetBoolean( |
dmazzoni
2012/01/24 18:43:56
This is great, but I'm afraid the next person who
Yusuke Sato
2012/01/25 01:43:16
Done.
| |
45 // spoken feedback is enabled (crosbug.com/110127). | 48 prefs::kSpokenFeedbackEnabled)) { |
46 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_); | 49 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_); |
47 return true; // consume the shortcut key. | 50 return true; // consume the shortcut key. |
48 } | 51 } |
49 #else | 52 #else |
50 NOTIMPLEMENTED(); | 53 NOTIMPLEMENTED(); |
51 #endif | 54 #endif |
52 return false; | 55 return false; |
53 } | 56 } |
54 | 57 |
55 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
56 void CapsLockHandler::OnCapsLockChange(bool enabled) { | 59 void CapsLockHandler::OnCapsLockChange(bool enabled) { |
57 caps_lock_is_on_ = enabled; | 60 caps_lock_is_on_ = enabled; |
58 } | 61 } |
59 #endif | 62 #endif |
OLD | NEW |