Chromium Code Reviews| 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/ash/caps_lock_handler.h" | 5 #include "chrome/browser/ui/ash/caps_lock_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 // TODO(yusukes): Support Ash on Windows. | 10 // TODO(yusukes): Support Ash on Windows. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 CapsLockHandler::~CapsLockHandler() { | 31 CapsLockHandler::~CapsLockHandler() { |
| 32 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
| 33 chromeos::SystemKeyEventListener* system_event_listener = | 33 chromeos::SystemKeyEventListener* system_event_listener = |
| 34 chromeos::SystemKeyEventListener::GetInstance(); | 34 chromeos::SystemKeyEventListener::GetInstance(); |
| 35 if (system_event_listener) | 35 if (system_event_listener) |
| 36 system_event_listener->RemoveCapsLockObserver(this); | 36 system_event_listener->RemoveCapsLockObserver(this); |
| 37 #endif | 37 #endif |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool CapsLockHandler::HandleToggleCapsLock() { | 40 bool CapsLockHandler::IsCapsLockEnabled() { |
| 41 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 43 if (is_running_on_chromeos_) { | 43 if (is_running_on_chromeos_) { |
| 44 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_); | 44 return xkeyboard_->CapsLockIsEnabled(); |
|
Daniel Erat
2012/08/26 22:32:47
should you just be returning caps_lock_is_on_ here
mazda
2012/08/27 16:06:40
It seems better. Thanks.
| |
| 45 return true; // consume the shortcut key. | |
| 46 } | 45 } |
| 47 #else | 46 #else |
| 48 NOTIMPLEMENTED(); | 47 NOTIMPLEMENTED(); |
| 49 #endif | 48 #endif |
| 50 return false; | 49 return false; |
| 51 } | 50 } |
| 52 | 51 |
| 52 void CapsLockHandler::SetCapsLockEnabled(bool enabled) { | |
| 53 #if defined(OS_CHROMEOS) | |
| 54 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 55 if (is_running_on_chromeos_) { | |
| 56 xkeyboard_->SetCapsLockEnabled(enabled); | |
| 57 return; | |
| 58 } | |
| 59 #else | |
| 60 NOTIMPLEMENTED(); | |
| 61 #endif | |
| 62 } | |
| 63 | |
| 64 void CapsLockHandler::ToggleCapsLock() { | |
| 65 #if defined(OS_CHROMEOS) | |
| 66 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 67 if (is_running_on_chromeos_) { | |
| 68 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_); | |
| 69 return; | |
| 70 } | |
| 71 #else | |
| 72 NOTIMPLEMENTED(); | |
| 73 #endif | |
| 74 } | |
| 75 | |
| 53 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
| 54 void CapsLockHandler::OnCapsLockChange(bool enabled) { | 77 void CapsLockHandler::OnCapsLockChange(bool enabled) { |
| 55 caps_lock_is_on_ = enabled; | 78 caps_lock_is_on_ = enabled; |
| 56 } | 79 } |
| 57 #endif | 80 #endif |
| OLD | NEW |