diff options
author | ygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-27 13:21:24 +0000 |
---|---|---|
committer | ygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-27 13:21:24 +0000 |
commit | f6cd449c2df2d6806e156ac6c56df0385b36b191 (patch) | |
tree | a1d6012b4ef32b7e14ae0504b5f545145448ce72 | |
parent | 7e6a0ee95b30cadef76758361c021c4d40b764e7 (diff) | |
download | chromium_src-f6cd449c2df2d6806e156ac6c56df0385b36b191.zip chromium_src-f6cd449c2df2d6806e156ac6c56df0385b36b191.tar.gz chromium_src-f6cd449c2df2d6806e156ac6c56df0385b36b191.tar.bz2 |
Audio is unmuted iff ChromeVox is enabled during OOBE.
BUG=328187
TEST=browser_tests:WizardControllerTest.Volume*
Review URL: https://codereview.chromium.org/138903010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247223 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.cc | 31 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller.h | 15 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_controller_browsertest.cc | 53 |
3 files changed, 98 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index e9fb052..341fdb5 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -21,6 +21,7 @@ #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" +#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/customization_document.h" #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" @@ -53,6 +54,7 @@ #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/pref_names.h" +#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/chromeos_constants.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/session_manager_client.h" @@ -60,6 +62,7 @@ #include "chromeos/settings/cros_settings_names.h" #include "components/breakpad/app/breakpad_linux.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/notification_types.h" #include "ui/base/accelerators/accelerator.h" #include "ui/base/l10n/l10n_util.h" @@ -90,6 +93,9 @@ const char WizardController::kLocallyManagedUserCreationScreenName[] = const char WizardController::kAppLaunchSplashScreenName[] = "app-launch-splash"; +// static +const int WizardController::kMinAudibleOutputVolumePercent = 10; + // Passing this parameter as a "first screen" initiates full OOBE flow. const char WizardController::kOutOfBoxScreenName[] = "oobe"; @@ -130,6 +136,11 @@ WizardController::WizardController(chromeos::LoginDisplayHost* host, weak_factory_(this) { DCHECK(default_controller_ == NULL); default_controller_ = this; + + registrar_.Add( + this, + chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, + content::NotificationService::AllSources()); } WizardController::~WizardController() { @@ -815,6 +826,26 @@ void WizardController::HideErrorScreen(WizardScreen* parent_screen) { SetCurrentScreen(parent_screen); } +void WizardController::Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + if (type != chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { + NOTREACHED(); + return; + } + const AccessibilityStatusEventDetails* a11y_details = + content::Details<const AccessibilityStatusEventDetails>(details).ptr(); + CrasAudioHandler* cras = CrasAudioHandler::Get(); + if (!a11y_details->enabled) + return; + if (cras->IsOutputMuted()) { + cras->SetOutputMute(false); + cras->SetOutputVolumePercent(kMinAudibleOutputVolumePercent); + } else if (cras->GetOutputVolumePercent() < kMinAudibleOutputVolumePercent) { + cras->SetOutputVolumePercent(kMinAudibleOutputVolumePercent); + } +} + void WizardController::AutoLaunchKioskApp() { KioskAppManager::App app_data; std::string app_id = KioskAppManager::Get()->GetAutoLaunchApp(); diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 3226f22..b4140df 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h @@ -16,6 +16,8 @@ #include "base/timer/timer.h" #include "chrome/browser/chromeos/login/screens/screen_observer.h" #include "chrome/browser/chromeos/login/screens/wizard_screen.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" #include "ui/gfx/rect.h" #include "url/gurl.h" @@ -47,7 +49,8 @@ class WrongHWIDScreen; // Class that manages control flow between wizard screens. Wizard controller // interacts with screen controllers to move the user between screens. -class WizardController : public ScreenObserver { +class WizardController : public ScreenObserver, + public content::NotificationObserver { public: // Observes screen changes. class Observer { @@ -153,6 +156,9 @@ class WizardController : public ScreenObserver { static const char kLocallyManagedUserCreationScreenName[]; static const char kAppLaunchSplashScreenName[]; + // Volume percent at which spoken feedback is still audible. + static const int kMinAudibleOutputVolumePercent; + private: // Show specific screen. void ShowNetworkScreen(); @@ -221,6 +227,11 @@ class WizardController : public ScreenObserver { virtual void ShowErrorScreen() OVERRIDE; virtual void HideErrorScreen(WizardScreen* parent_screen) OVERRIDE; + // Overridden from content::NotificationObserver: + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + // Switches from one screen to another. void SetCurrentScreen(WizardScreen* screen); @@ -333,6 +344,8 @@ class WizardController : public ScreenObserver { base::WeakPtrFactory<WizardController> weak_factory_; + content::NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(WizardController); }; diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc index d0f1856..55fbe07 100644 --- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc +++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc @@ -15,6 +15,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/chrome_notification_types.h" +#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/base/locale_util.h" #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" #include "chrome/browser/chromeos/login/enrollment/mock_enrollment_screen.h" @@ -35,11 +36,13 @@ #include "chrome/browser/chromeos/login/webui_login_view.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/ui_test_utils.h" +#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_test_utils.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -119,6 +122,21 @@ void RunSwitchLanguageTest(const std::string& locale, EXPECT_EQ(data.success, expect_success); } +void SetUpCrasAndEnableChromeVox(int volume_percent, bool mute_on) { + AccessibilityManager* a11y = AccessibilityManager::Get(); + CrasAudioHandler* cras = CrasAudioHandler::Get(); + + // Audio output is at |volume_percent| and |mute_on|. Spoken feedback + // is disabled. + cras->SetOutputVolumePercent(volume_percent); + cras->SetOutputMute(mute_on); + a11y->EnableSpokenFeedback(false, ash::A11Y_NOTIFICATION_NONE); + + // Spoken feedback is enabled. + a11y->EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_NONE); + base::RunLoop().RunUntilIdle(); +} + } // namespace using ::testing::_; @@ -152,6 +170,12 @@ class WizardControllerTest : public WizardInProcessBrowserTest { WizardController::kTestNoScreenName) {} virtual ~WizardControllerTest() {} + virtual void SetUpOnMainThread() OVERRIDE { + AccessibilityManager::Get()-> + SetProfileForTest(ProfileHelper::GetSigninProfile()); + WizardInProcessBrowserTest::SetUpOnMainThread(); + } + private: DISALLOW_COPY_AND_ASSIGN(WizardControllerTest); }; @@ -187,6 +211,35 @@ IN_PROC_BROWSER_TEST_F(WizardControllerTest, SwitchLanguage) { EXPECT_NE(fr_str, ar_str); } +IN_PROC_BROWSER_TEST_F(WizardControllerTest, VolumeIsChangedForChromeVox) { + SetUpCrasAndEnableChromeVox(75 /* volume_percent */, true /* mute_on */); + + // Check that output is unmuted now and at some level. + CrasAudioHandler* cras = CrasAudioHandler::Get(); + ASSERT_FALSE(cras->IsOutputMuted()); + ASSERT_EQ(WizardController::kMinAudibleOutputVolumePercent, + cras->GetOutputVolumePercent()); +} + +IN_PROC_BROWSER_TEST_F(WizardControllerTest, VolumeIsUnchangedForChromeVox) { + SetUpCrasAndEnableChromeVox(75 /* volume_percent */, false /* mute_on */); + + // Check that output is unmuted now and at some level. + CrasAudioHandler* cras = CrasAudioHandler::Get(); + ASSERT_FALSE(cras->IsOutputMuted()); + ASSERT_EQ(75, cras->GetOutputVolumePercent()); +} + +IN_PROC_BROWSER_TEST_F(WizardControllerTest, VolumeIsAdjustedForChromeVox) { + SetUpCrasAndEnableChromeVox(5 /* volume_percent */, false /* mute_on */); + + // Check that output is unmuted now and at some level. + CrasAudioHandler* cras = CrasAudioHandler::Get(); + ASSERT_FALSE(cras->IsOutputMuted()); + ASSERT_EQ(WizardController::kMinAudibleOutputVolumePercent, + cras->GetOutputVolumePercent()); +} + class WizardControllerFlowTest : public WizardControllerTest { protected: WizardControllerFlowTest() {} |