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

Side by Side Diff: ui/chromeos/touch_accessibility_enabler.cc

Issue 2504233004: Tweaks for: Toggle spoken feedback if two fingers are held down (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/chromeos/touch_accessibility_enabler.h" 5 #include "ui/chromeos/touch_accessibility_enabler.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/user_metrics.h"
12 #include "base/time/default_tick_clock.h" 13 #include "base/time/default_tick_clock.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
15 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
16 #include "ui/events/event.h" 17 #include "ui/events/event.h"
17 #include "ui/events/event_processor.h" 18 #include "ui/events/event_processor.h"
18 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
19 20
20 namespace ui { 21 namespace ui {
21 22
22 namespace { 23 namespace {
23 24
24 // Delay between timer callbacks. Each one plays a tick sound. 25 // Delay between timer callbacks. Each one plays a tick sound.
25 constexpr int kTimerDelayInMS = 500; 26 constexpr int kTimerDelayInMS = 500;
26 27
28 // The number of ticks of the timer before the first sound is generated.
29 constexpr int kTimerTicksOfFirstSoundFeedback = 6;
30
27 // The number of ticks of the timer before toggling spoken feedback. 31 // The number of ticks of the timer before toggling spoken feedback.
28 constexpr int kTimerTicksToToggleSpokenFeedback = 7; 32 constexpr int kTimerTicksToToggleSpokenFeedback = 10;
29 33
30 } // namespace 34 } // namespace
31 35
32 TouchAccessibilityEnabler::TouchAccessibilityEnabler( 36 TouchAccessibilityEnabler::TouchAccessibilityEnabler(
33 aura::Window* root_window, 37 aura::Window* root_window,
34 TouchAccessibilityEnablerDelegate* delegate) 38 TouchAccessibilityEnablerDelegate* delegate)
35 : root_window_(root_window), 39 : root_window_(root_window),
36 delegate_(delegate), 40 delegate_(delegate),
37 state_(NO_FINGERS_DOWN), 41 state_(NO_FINGERS_DOWN),
38 tick_clock_(NULL) { 42 tick_clock_(NULL) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void TouchAccessibilityEnabler::CancelTimer() { 132 void TouchAccessibilityEnabler::CancelTimer() {
129 if (timer_.IsRunning()) 133 if (timer_.IsRunning())
130 timer_.Stop(); 134 timer_.Stop();
131 } 135 }
132 136
133 void TouchAccessibilityEnabler::OnTimer() { 137 void TouchAccessibilityEnabler::OnTimer() {
134 base::TimeTicks now = Now(); 138 base::TimeTicks now = Now();
135 double tick_count_f = 139 double tick_count_f =
136 (now - two_finger_start_time_).InMillisecondsF() / kTimerDelayInMS; 140 (now - two_finger_start_time_).InMillisecondsF() / kTimerDelayInMS;
137 int tick_count = roundf(tick_count_f); 141 int tick_count = roundf(tick_count_f);
138 if (tick_count >= 1 && tick_count < kTimerTicksToToggleSpokenFeedback) { 142
143 if (tick_count == kTimerTicksOfFirstSoundFeedback)
Ilya Sherman 2016/11/16 23:11:33 nit: Please add curly braces, since the body of th
oshima 2016/11/22 21:57:38 +1
dmazzoni 2016/11/22 22:31:55 Done.
144 base::RecordAction(
145 base::UserMetricsAction("Accessibility.TwoFingersHeldDown"));
146
147 if (tick_count >= kTimerTicksOfFirstSoundFeedback &&
148 tick_count < kTimerTicksToToggleSpokenFeedback) {
139 delegate_->PlaySpokenFeedbackToggleCountdown(tick_count); 149 delegate_->PlaySpokenFeedbackToggleCountdown(tick_count);
140 } 150 }
141 if (tick_count == kTimerTicksToToggleSpokenFeedback) { 151 if (tick_count == kTimerTicksToToggleSpokenFeedback) {
142 delegate_->ToggleSpokenFeedback(); 152 delegate_->ToggleSpokenFeedback();
143 state_ = WAIT_FOR_NO_FINGERS; 153 state_ = WAIT_FOR_NO_FINGERS;
144 } 154 }
145 } 155 }
146 156
147 } // namespace ui 157 } // namespace ui
OLDNEW
« tools/metrics/actions/actions.xml ('K') | « tools/metrics/actions/actions.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698