cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / accelerators / spoken_feedback_toggler.cc
blob5cd9ebaffa56b3336e5bc24eb43f81a998dbd5b1
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"
10 #include "ui/events/event.h"
12 namespace ash {
13 namespace {
14 bool speech_feedback_toggler_enabled = false;
17 // static
18 bool SpokenFeedbackToggler::IsEnabled() {
19 return speech_feedback_toggler_enabled;
22 // static
23 void SpokenFeedbackToggler::SetEnabled(bool enabled) {
24 speech_feedback_toggler_enabled = enabled;
27 // static
28 scoped_ptr<ui::EventHandler> SpokenFeedbackToggler::CreateHandler() {
29 scoped_ptr<KeyHoldDetector::Delegate> delegate(new SpokenFeedbackToggler());
30 return scoped_ptr<ui::EventHandler>(new KeyHoldDetector(delegate.Pass()));
33 bool SpokenFeedbackToggler::ShouldProcessEvent(
34 const ui::KeyEvent* event) const {
35 return IsEnabled() && event->key_code() == ui::VKEY_F6;
38 bool SpokenFeedbackToggler::IsStartEvent(const ui::KeyEvent* event) const {
39 return event->type() == ui::ET_KEY_PRESSED &&
40 event->flags() & ui::EF_SHIFT_DOWN;
43 bool SpokenFeedbackToggler::ShouldStopEventPropagation() const {
44 // Let hotkey events pass through. See http://crbug.com/526729
45 return false;
48 void SpokenFeedbackToggler::OnKeyHold(const ui::KeyEvent* event) {
49 if (!toggled_) {
50 toggled_ = true;
51 Shell::GetInstance()->accessibility_delegate()->
52 ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_SHOW);
56 void SpokenFeedbackToggler::OnKeyUnhold(const ui::KeyEvent* event) {
57 toggled_ = false;
60 SpokenFeedbackToggler::SpokenFeedbackToggler() : toggled_(false) {}
62 SpokenFeedbackToggler::~SpokenFeedbackToggler() {}
64 } // namespace ash