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

Side by Side 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: review fix, 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 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/chromeos/input_method/xkeyboard.h"
12 #include "chrome/browser/chromeos/system/runtime_environment.h"
13 #endif
14
15 CapsLockHandler::CapsLockHandler()
16 : is_running_on_chromeos_(false),
17 caps_lock_is_on_(false) {
18 }
19
20 #if defined(OS_CHROMEOS)
21 CapsLockHandler::CapsLockHandler(chromeos::input_method::XKeyboard* xkeyboard)
22 : xkeyboard_(xkeyboard),
23 is_running_on_chromeos_(
24 chromeos::system::runtime_environment::IsRunningOnChromeOS()),
Daniel Erat 2012/01/23 16:42:43 nit: indent this four spaces beyond the previous l
Yusuke Sato 2012/01/24 09:03:19 Done.
25 caps_lock_is_on_(xkeyboard_->CapsLockIsEnabled())
26 {
Daniel Erat 2012/01/23 16:42:43 nit: opening brace should be at the end of the pre
Yusuke Sato 2012/01/24 09:03:19 Done.
27 chromeos::SystemKeyEventListener* system_event_listener =
28 chromeos::SystemKeyEventListener::GetInstance();
29 // SystemKeyEventListener should be instantiated when we're running on Chrome
30 // OS.
31 DCHECK(!is_running_on_chromeos_ || system_event_listener);
32 if (system_event_listener)
33 system_event_listener->AddCapsLockObserver(this);
34 }
35 #endif
36
37 CapsLockHandler::~CapsLockHandler() {
38 #if defined(OS_CHROMEOS)
39 chromeos::SystemKeyEventListener* system_event_listener =
40 chromeos::SystemKeyEventListener::GetInstance();
41 if (system_event_listener)
42 system_event_listener->RemoveCapsLockObserver(this);
43 #endif
44 }
45
46 bool CapsLockHandler::HandleToggleCapsLock() {
47 #if defined(OS_CHROMEOS)
48 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
49 if (is_running_on_chromeos_) {
50 // TODO(yusukes): Do not change Caps Lock status and just return false if
51 // spoken feedback is enabled (crosbug.com/110127).
52 xkeyboard_->SetCapsLockEnabled(!caps_lock_is_on_);
53 return true; // consume the short cut key.
54 }
55 #else
56 NOTIMPLEMENTED();
57 #endif
58 return false;
59 }
60
61 #if defined(OS_CHROMEOS)
62 void CapsLockHandler::OnCapsLockChange(bool enabled) {
63 caps_lock_is_on_ = enabled;
Daniel Erat 2012/01/23 16:42:43 it seems weird that this variable is defined on no
Yusuke Sato 2012/01/24 09:03:19 Done. Removed all member variables from !OS_CHROME
64 }
65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698