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

Side by Side Diff: chrome/browser/ui/views/aura/caps_lock_handler.cc

Issue 9570044: Rename chrome/browser/ui/views/{aura => ash}/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/aura/caps_lock_handler.h"
6
7 #include "content/public/browser/browser_thread.h"
8
9 // TODO(yusukes): Support Ash on Windows.
10 #if defined(OS_CHROMEOS)
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/input_method/xkeyboard.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"
16 #endif
17
18 #if defined(OS_CHROMEOS)
19 CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard)
20 : xkeyboard_(xkeyboard),
21 is_running_on_chromeos_(
22 chromeos::system::runtime_environment::IsRunningOnChromeOS()),
23 caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled()) {
24 chromeos::SystemKeyEventListener* system_event_listener =
25 chromeos::SystemKeyEventListener::GetInstance();
26 // SystemKeyEventListener should be instantiated when we're running on Chrome
27 // OS.
28 DCHECK(!is_running_on_chromeos_ || system_event_listener);
29 if (system_event_listener)
30 system_event_listener->AddCapsLockObserver(this);
31 }
32 #endif
33
34 CapsLockHandler::~CapsLockHandler() {
35 #if defined(OS_CHROMEOS)
36 chromeos::SystemKeyEventListener* system_event_listener =
37 chromeos::SystemKeyEventListener::GetInstance();
38 if (system_event_listener)
39 system_event_listener->RemoveCapsLockObserver(this);
40 #endif
41 }
42
43 bool CapsLockHandler::HandleToggleCapsLock() {
44 #if defined(OS_CHROMEOS)
45 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
46 if (is_running_on_chromeos_ &&
47 // When spoken feedback is enabled, the Search key is used as an
48 // accessibility modifier key.
49 !g_browser_process->local_state()->GetBoolean(
50 prefs::kSpokenFeedbackEnabled)) {
51 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_);
52 return true; // consume the shortcut key.
53 }
54 #else
55 NOTIMPLEMENTED();
56 #endif
57 return false;
58 }
59
60 #if defined(OS_CHROMEOS)
61 void CapsLockHandler::OnCapsLockChange(bool enabled) {
62 caps_lock_is_on_ = enabled;
63 }
64 #endif
OLDNEW
« 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