Make chrome/browser/chromeos/accessibility compile on Athena with use_ash=0
[chromium-blink-merge.git] / ash / accelerators / spoken_feedback_toggler.cc
blob53f6e6ef95627eacb4918def8558b79c3dcb69de
1 // Copyright 2014 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.
5 #include "ash/accelerators/spoken_feedback_toggler.h"
7 #include "ash/accelerators/key_hold_detector.h"
8 #include "ash/accessibility_delegate.h"
9 #include "ash/shell.h"
11 namespace ash {
12 namespace {
13 bool speech_feedback_toggler_enabled = false;
16 // static
17 bool SpokenFeedbackToggler::IsEnabled() {
18 return speech_feedback_toggler_enabled;
21 // static
22 void SpokenFeedbackToggler::SetEnabled(bool enabled) {
23 speech_feedback_toggler_enabled = enabled;
26 // static
27 scoped_ptr<ui::EventHandler> SpokenFeedbackToggler::CreateHandler() {
28 scoped_ptr<KeyHoldDetector::Delegate> delegate(new SpokenFeedbackToggler());
29 return scoped_ptr<ui::EventHandler>(new KeyHoldDetector(delegate.Pass()));
32 bool SpokenFeedbackToggler::ShouldProcessEvent(
33 const ui::KeyEvent* event) const {
34 return IsEnabled() && event->key_code() == ui::VKEY_F6;
37 bool SpokenFeedbackToggler::IsStartEvent(const ui::KeyEvent* event) const {
38 return event->type() == ui::ET_KEY_PRESSED &&
39 event->flags() & ui::EF_SHIFT_DOWN;
42 void SpokenFeedbackToggler::OnKeyHold(const ui::KeyEvent* event) {
43 if (!toggled_) {
44 toggled_ = true;
45 Shell::GetInstance()->accessibility_delegate()->
46 ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_SHOW);
50 void SpokenFeedbackToggler::OnKeyUnhold(const ui::KeyEvent* event) {
51 toggled_ = false;
54 SpokenFeedbackToggler::SpokenFeedbackToggler() : toggled_(false) {}
56 SpokenFeedbackToggler::~SpokenFeedbackToggler() {}
58 } // namespace ash