diff options
Diffstat (limited to 'chrome/browser/chromeos')
4 files changed, 103 insertions, 44 deletions
diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_manager.cc index 74b4eff..b981919 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.cc +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.cc @@ -37,6 +37,7 @@ #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" #include "chrome/common/pref_names.h" +#include "chromeos/audio/chromeos_sounds.h" #include "chromeos/login/login_state.h" #include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_thread.h" @@ -290,7 +291,8 @@ AccessibilityManager::AccessibilityManager() autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), weak_ptr_factory_(this), - should_speak_chrome_vox_announcements_on_user_screen_(true) { + should_speak_chrome_vox_announcements_on_user_screen_(true), + system_sounds_enabled_(false) { notification_registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, content::NotificationService::AllSources()); @@ -312,21 +314,15 @@ AccessibilityManager::AccessibilityManager() GetBrailleController()->AddObserver(this); ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); - std::vector<base::StringPiece> sound_resources( - media::SoundsManager::SOUND_COUNT); - sound_resources[media::SoundsManager::SOUND_STARTUP] = - bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV); - sound_resources[media::SoundsManager::SOUND_LOCK] = - bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV); - sound_resources[media::SoundsManager::SOUND_UNLOCK] = - bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV); - sound_resources[media::SoundsManager::SOUND_SHUTDOWN] = - bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV); - sound_resources[media::SoundsManager::SOUND_SPOKEN_FEEDBACK_ENABLED] = - bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV); - sound_resources[media::SoundsManager::SOUND_SPOKEN_FEEDBACK_DISABLED] = - bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV); - media::SoundsManager::Get()->Initialize(sound_resources); + media::SoundsManager* manager = media::SoundsManager::Get(); + manager->Initialize(SOUND_SHUTDOWN, + bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); + manager->Initialize( + SOUND_SPOKEN_FEEDBACK_ENABLED, + bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); + manager->Initialize( + SOUND_SPOKEN_FEEDBACK_DISABLED, + bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV)); } AccessibilityManager::~AccessibilityManager() { @@ -512,8 +508,7 @@ void AccessibilityManager::LoadChromeVoxToLockScreen() { } void AccessibilityManager::UnloadChromeVox() { - media::SoundsManager::Get()->Play( - media::SoundsManager::SOUND_SPOKEN_FEEDBACK_DISABLED); + PlaySound(SOUND_SPOKEN_FEEDBACK_DISABLED); if (chrome_vox_loaded_on_lock_screen_) UnloadChromeVoxFromLockScreen(); @@ -738,6 +733,19 @@ void AccessibilityManager::SetBrailleControllerForTest( g_braille_controller_for_test = controller; } +void AccessibilityManager::EnableSystemSounds(bool system_sounds_enabled) { + system_sounds_enabled_ = system_sounds_enabled; +} + +base::TimeDelta AccessibilityManager::PlayShutdownSound() { + if (!IsSpokenFeedbackEnabled() || !system_sounds_enabled_) + return base::TimeDelta(); + system_sounds_enabled_ = false; + media::SoundsManager* manager = media::SoundsManager::Get(); + manager->Play(SOUND_SHUTDOWN); + return manager->GetDuration(SOUND_SHUTDOWN); +} + void AccessibilityManager::UpdateChromeOSAccessibilityHistograms() { UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", IsSpokenFeedbackEnabled()); @@ -882,8 +890,7 @@ void AccessibilityManager::OnListenerRemoved( void AccessibilityManager::SetUpPreLoadChromeVox(Profile* profile) { // Do any setup work needed immediately before ChromeVox actually loads. - media::SoundsManager::Get()->Play( - media::SoundsManager::SOUND_SPOKEN_FEEDBACK_ENABLED); + PlaySound(SOUND_SPOKEN_FEEDBACK_ENABLED); if (profile) { extensions::ExtensionSystem::Get(profile)-> @@ -901,4 +908,9 @@ void AccessibilityManager::TearDownPostUnloadChromeVox(Profile* profile) { } } +void AccessibilityManager::PlaySound(int sound_key) const { + if (system_sounds_enabled_) + media::SoundsManager::Get()->Play(sound_key); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h index d7d4f6d..e6dadbe 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.h +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h @@ -8,6 +8,7 @@ #include "ash/accessibility_delegate.h" #include "base/memory/weak_ptr.h" #include "base/prefs/pref_change_registrar.h" +#include "base/time/time.h" #include "chrome/browser/chromeos/accessibility/accessibility_util.h" #include "chrome/browser/extensions/api/braille_display_private/braille_controller.h" #include "chrome/browser/extensions/extension_system.h" @@ -114,6 +115,12 @@ class AccessibilityManager : public content::NotificationObserver, static void SetBrailleControllerForTest( extensions::api::braille_display_private::BrailleController* controller); + // Enables/disables system sounds. + void EnableSystemSounds(bool system_sounds_enabled); + + // Initiates play of shutdown sound and returns it's duration. + base::TimeDelta PlayShutdownSound(); + protected: AccessibilityManager(); virtual ~AccessibilityManager(); @@ -161,6 +168,12 @@ class AccessibilityManager : public content::NotificationObserver, virtual void OnListenerRemoved( const extensions::EventListenerInfo& details) OVERRIDE; + // Plays sound identified by |sound_key| if |system_sounds_enabled_|. + // |sound_key| must be an ID for sound registered by + // AccessibilityManager. If there is no such sound or + // !|system_sounds_enabled_|, sound isn't played. + void PlaySound(int sound_key) const; + // Profile which has the current a11y context. Profile* profile_; @@ -192,6 +205,8 @@ class AccessibilityManager : public content::NotificationObserver, bool should_speak_chrome_vox_announcements_on_user_screen_; + bool system_sounds_enabled_; + DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); }; diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc index 648bb67..3b4148d 100644 --- a/chrome/browser/chromeos/login/login_display_host_impl.cc +++ b/chrome/browser/chromeos/login/login_display_host_impl.cc @@ -55,6 +55,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chromeos/audio/chromeos_sounds.h" #include "chromeos/chromeos_constants.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -228,6 +229,10 @@ void OnLanguageSwitchedCallback( self->first_screen_name, self->startup_manifest, self->display_host); } +void EnableSystemSoundsForAccessibility() { + chromeos::AccessibilityManager::Get()->EnableSystemSounds(true); +} + } // namespace namespace chromeos { @@ -291,15 +296,14 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds) bool is_registered = StartupUtils::IsDeviceRegistered(); bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); - bool disable_boot_animation = CommandLine::ForCurrentProcess()-> - HasSwitch(switches::kDisableBootAnimation); - bool disable_oobe_animation = CommandLine::ForCurrentProcess()-> - HasSwitch(switches::kDisableOobeAnimation); + bool disable_boot_animation = CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableBootAnimation); + bool disable_oobe_animation = CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableOobeAnimation); - waiting_for_wallpaper_load_ = - !zero_delay_enabled && - (is_registered || !disable_oobe_animation) && - (!is_registered || !disable_boot_animation); + waiting_for_wallpaper_load_ = !zero_delay_enabled && + (is_registered || !disable_oobe_animation) && + (!is_registered || !disable_boot_animation); // For slower hardware we have boot animation disabled so // we'll be initializing WebUI hidden, waiting for user pods to load and then @@ -311,8 +315,9 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds) // Check if WebUI init type is overriden. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) { - const std::string override_type = CommandLine::ForCurrentProcess()-> - GetSwitchValueASCII(switches::kAshWebUIInit); + const std::string override_type = + CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kAshWebUIInit); if (override_type == kWebUIInitParallel) initialize_webui_hidden_ = true; else if (override_type == kWebUIInitPostpone) @@ -329,17 +334,20 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds) initialize_webui_hidden_ = false; if (waiting_for_wallpaper_load_) { - registrar_.Add(this, chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, + registrar_.Add(this, + chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, content::NotificationService::AllSources()); } // When we wait for WebUI to be initialized we wait for one of // these notifications. - if ((waiting_for_user_pods_ || waiting_for_wallpaper_load_) - && initialize_webui_hidden_) { - registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, + if ((waiting_for_user_pods_ || waiting_for_wallpaper_load_) && + initialize_webui_hidden_) { + registrar_.Add(this, + chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, content::NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, + registrar_.Add(this, + chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, content::NotificationService::AllSources()); } LOG(WARNING) << "Login WebUI >> " @@ -347,6 +355,11 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds) << " wait_for_wp_load_: " << waiting_for_wallpaper_load_ << " wait_for_pods_: " << waiting_for_user_pods_ << " init_webui_hidden_: " << initialize_webui_hidden_; + + media::SoundsManager* manager = media::SoundsManager::Get(); + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); + manager->Initialize(chromeos::SOUND_STARTUP, + bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV)); } LoginDisplayHostImpl::~LoginDisplayHostImpl() { @@ -373,7 +386,7 @@ LoginDisplayHostImpl::~LoginDisplayHostImpl() { // TODO(tengs): This should be refactored together with the first run UI. // See crbug.com/314934. if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableDriveOfflineFirstRun)) { + switches::kEnableDriveOfflineFirstRun)) { if (UserManager::Get()->IsCurrentUserNew()) { // DriveOptInController will delete itself when finished. (new DriveFirstRunController())->EnableOfflineMode(); @@ -1024,10 +1037,18 @@ void LoginDisplayHostImpl::TryToPlayStartupSound() { return; } + AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); + media::SoundsManager* sounds_manager = media::SoundsManager::Get(); + startup_sound_played_ = true; if (!startup_sound_honors_spoken_feedback_ || - chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { - startup_sound_played_ = true; - media::SoundsManager::Get()->Play(media::SoundsManager::SOUND_STARTUP); + accessibility_manager->IsSpokenFeedbackEnabled()) { + sounds_manager->Play(SOUND_STARTUP); + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&EnableSystemSoundsForAccessibility), + sounds_manager->GetDuration(SOUND_STARTUP)); + } else { + accessibility_manager->EnableSystemSounds(true); } } diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index 77eee09..6397050 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -37,14 +37,17 @@ #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/chrome_switches.h" +#include "chromeos/audio/chromeos_sounds.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/session_manager_client.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/user_metrics.h" +#include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "media/audio/sounds/sounds_manager.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" #include "url/gurl.h" using content::BrowserThread; @@ -133,9 +136,9 @@ class ScreenLockObserver : public chromeos::SessionManagerClient::Observer, DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); }; -void PlaySound(media::SoundsManager::Sound sound) { +void PlaySound(int sound_key) { if (chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) - media::SoundsManager::Get()->Play(sound); + media::SoundsManager::Get()->Play(sound_key); } static base::LazyInstance<ScreenLockObserver> g_screen_lock_observer = @@ -161,9 +164,17 @@ ScreenLocker::ScreenLocker(const UserList& users) DCHECK(!screen_locker_); screen_locker_ = this; - ash::Shell::GetInstance()->lock_state_controller()-> + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); + media::SoundsManager* manager = media::SoundsManager::Get(); + manager->Initialize(SOUND_LOCK, + bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV)); + manager->Initialize(SOUND_UNLOCK, + bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV)); + + ash::Shell::GetInstance()-> + lock_state_controller()-> SetLockScreenDisplayedCallback( - base::Bind(&PlaySound, media::SoundsManager::SOUND_LOCK)); + base::Bind(&PlaySound, static_cast<int>(chromeos::SOUND_LOCK))); } void ScreenLocker::Init() { @@ -383,7 +394,7 @@ void ScreenLocker::ScheduleDeletion() { return; VLOG(1) << "Deleting ScreenLocker " << screen_locker_; - PlaySound(media::SoundsManager::SOUND_UNLOCK); + PlaySound(SOUND_UNLOCK); delete screen_locker_; screen_locker_ = NULL; |