| 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. |
| 11 #if defined(OS_CHROMEOS) | 11 #if defined(OS_CHROMEOS) |
| 12 #include "base/chromeos/chromeos_version.h" | 12 #include "base/chromeos/chromeos_version.h" |
| 13 #include "base/command_line.h" |
| 14 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 15 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 14 #endif | 16 #endif |
| 15 | 17 |
| 16 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 17 CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard) | 19 CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard) |
| 18 : xkeyboard_(xkeyboard), | 20 : xkeyboard_(xkeyboard), |
| 19 is_running_on_chromeos_(base::chromeos::IsRunningOnChromeOS()), | 21 is_running_on_chromeos_(base::chromeos::IsRunningOnChromeOS()), |
| 20 caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled()) { | 22 caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled()) { |
| 21 chromeos::SystemKeyEventListener* system_event_listener = | 23 chromeos::SystemKeyEventListener* system_event_listener = |
| 22 chromeos::SystemKeyEventListener::GetInstance(); | 24 chromeos::SystemKeyEventListener::GetInstance(); |
| 23 // SystemKeyEventListener should be instantiated when we're running on Chrome | 25 // SystemKeyEventListener should be instantiated when we're running production |
| 24 // OS. | 26 // code on Chrome OS. |
| 25 DCHECK(!is_running_on_chromeos_ || system_event_listener); | 27 DCHECK(!is_running_on_chromeos_ || system_event_listener || |
| 28 CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)); |
| 26 if (system_event_listener) | 29 if (system_event_listener) |
| 27 system_event_listener->AddCapsLockObserver(this); | 30 system_event_listener->AddCapsLockObserver(this); |
| 28 } | 31 } |
| 29 #endif | 32 #endif |
| 30 | 33 |
| 31 CapsLockHandler::~CapsLockHandler() { | 34 CapsLockHandler::~CapsLockHandler() { |
| 32 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
| 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) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #else | 71 #else |
| 69 NOTIMPLEMENTED(); | 72 NOTIMPLEMENTED(); |
| 70 #endif | 73 #endif |
| 71 } | 74 } |
| 72 | 75 |
| 73 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
| 74 void CapsLockHandler::OnCapsLockChange(bool enabled) { | 77 void CapsLockHandler::OnCapsLockChange(bool enabled) { |
| 75 caps_lock_is_on_ = enabled; | 78 caps_lock_is_on_ = enabled; |
| 76 } | 79 } |
| 77 #endif | 80 #endif |
| OLD | NEW |