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

Unified Diff: ash/ash_touch_exploration_manager_chromeos.cc

Issue 385073009: Side Slide Gestures for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separated CrosAcessibilityObserver into own files Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ash/ash_touch_exploration_manager_chromeos.cc
diff --git a/ash/ash_touch_exploration_manager_chromeos.cc b/ash/ash_touch_exploration_manager_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6891173c9fdcad2991296ce8363043b187de5693
--- /dev/null
+++ b/ash/ash_touch_exploration_manager_chromeos.cc
@@ -0,0 +1,79 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/ash_touch_exploration_manager_chromeos.h"
+
+#include "ash/audio/sounds.h"
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
James Cook 2014/07/15 18:21:57 Do you need this include? Or ash/accessibility_de
lisayin 2014/07/15 21:46:44 Done.
+#include "ash/system/tray/system_tray_notifier.h"
+#include "base/command_line.h"
+#include "chromeos/audio/chromeos_sounds.h"
+#include "chromeos/chromeos_switches.h"
+#include "ui/chromeos/touch_exploration_controller.h"
+
+namespace ash {
+
+CrosAccessibilityObserver::CrosAccessibilityObserver(
+ RootWindowController* root_window_controller)
+ : root_window_controller_(root_window_controller),
+ audio_handler_(chromeos::CrasAudioHandler::Get()) {
+ Shell::GetInstance()->system_tray_notifier()->
+ AddAccessibilityObserver(this);
+ UpdateTouchExplorationState();
+}
+
+CrosAccessibilityObserver::~CrosAccessibilityObserver() {
+ SystemTrayNotifier* system_tray_notifier =
+ Shell::GetInstance()->system_tray_notifier();
+ if (system_tray_notifier)
James Cook 2014/07/15 18:21:56 Is this NULL in normal operation, in tests, in bot
+ system_tray_notifier->RemoveAccessibilityObserver(this);
+
James Cook 2014/07/15 18:21:57 no blank line
lisayin 2014/07/15 21:46:44 Done.
+}
+
+bool CrosAccessibilityObserver::VolumeAdjustSoundEnabled() {
+ return !CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kDisableVolumeAdjustSound);
+}
+
+void const CrosAccessibilityObserver::PlayVolumeAdjustSound() {
+ if (!VolumeAdjustSoundEnabled())
+ return;
+ if (!audio_handler_->IsOutputMuted() ||
+ !audio_handler_->GetOutputVolumePercent() == 100)
+ PlaySystemSoundIfSpokenFeedback(chromeos::SOUND_VOLUME_ADJUST);
+}
+
+void CrosAccessibilityObserver::AdjustSound(float volume) {
James Cook 2014/07/15 18:21:56 Please add a unit test for this functionality. (In
+ if (volume > 0) {
+ if (audio_handler_->IsOutputMuted()) {
+ audio_handler_->SetOutputMute(false);
+ }
+ }
+ audio_handler_->SetOutputVolumePercent(volume);
+ // Avoid negative volume.
+ if (audio_handler_->IsOutputVolumeBelowDefaultMuteLevel())
+ audio_handler_->SetOutputMute(true);
+}
+
+void CrosAccessibilityObserver::UpdateTouchExplorationState() {
+ AccessibilityDelegate* delegate =
+ Shell::GetInstance()->accessibility_delegate();
+ bool enabled = delegate->IsSpokenFeedbackEnabled();
+
+ if (enabled && !touch_exploration_controller_.get()) {
+ touch_exploration_controller_.reset(new ui::TouchExplorationController(
+ root_window_controller_->GetRootWindow(), this));
+ } else if (!enabled) {
+ touch_exploration_controller_.reset();
+ }
+}
+
+// Overridden from AccessibilityObserver.
+void CrosAccessibilityObserver::OnAccessibilityModeChanged(
+ AccessibilityNotificationVisibility notify) {
+ UpdateTouchExplorationState();
+}
+
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698