Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: chrome/browser/ui/views/aura/caps_lock_handler.cc

Issue 9225004: Handle Caps Lock short cut (Shift+Search) in ash [part 2 of 2]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/aura/caps_lock_handler.cc
diff --git a/chrome/browser/ui/views/aura/caps_lock_handler.cc b/chrome/browser/ui/views/aura/caps_lock_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fccd62b6ec656595eb3ab37240100e1fc7be3ec1
--- /dev/null
+++ b/chrome/browser/ui/views/aura/caps_lock_handler.cc
@@ -0,0 +1,59 @@
+// 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/views/aura/caps_lock_handler.h"
+
+#include "content/public/browser/browser_thread.h"
+
+// TODO(yusukes): Support Ash on Windows.
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/input_method/xkeyboard.h"
+#include "chrome/browser/chromeos/system/runtime_environment.h"
+#endif
+
+#if defined(OS_CHROMEOS)
+CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard)
+ : xkeyboard_(xkeyboard),
+ is_running_on_chromeos_(
+ chromeos::system::runtime_environment::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_) {
+ // TODO(yusukes): Do not change Caps Lock status and just return false if
+ // spoken feedback is enabled (crosbug.com/110127).
+ 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
« no previous file with comments | « chrome/browser/ui/views/aura/caps_lock_handler.h ('k') | chrome/browser/ui/views/aura/caps_lock_handler_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698