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

Unified Diff: chrome/browser/chromeos/login/login_display_host_impl.cc

Issue 98583004: Added CrOS startup sound. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « chrome/browser/chromeos/login/login_display_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/login_display_host_impl.cc
diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc
index cc4355ccab6e2de001ea765d5888b42060b9567c..ef5f2b11714ca350ef2735a6d248125d0a5448da 100644
--- a/chrome/browser/chromeos/login/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/login_display_host_impl.cc
@@ -83,7 +83,10 @@
namespace {
-const int kStartupSoundInitialDelayMs = 500;
+// Following delays specify time window for startup sound.
+const int kMinDelayAfterLoginPromptVisibleMs = 500;
+
+const int kMaxDelayAfterLoginPromptVisibleMs = 2000;
dzhioev (left Google) 2013/12/03 08:28:32 Rename these constants to names containing 'Sound'
ygorshenin1 2013/12/03 09:03:28 Done.
// URL which corresponds to the login WebUI.
const char kLoginURL[] = "chrome://oobe/login";
@@ -264,10 +267,10 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds)
auto_enrollment_check_done_(false),
finalize_animation_type_(ANIMATION_WORKSPACE),
animation_weak_ptr_factory_(this),
- startup_sound_requested_(false),
startup_sound_played_(false),
startup_sound_honors_spoken_feedback_(false) {
DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
+ CrasAudioHandler::Get()->AddAudioObserver(this);
// We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING
// because/ APP_TERMINATING will never be fired as long as this keeps
@@ -353,10 +356,29 @@ 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_;
+
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ std::vector<base::StringPiece> sound_resources(
dzhioev (left Google) 2013/12/03 08:28:32 I think it's safer to use std::map instead of std:
ygorshenin1 2013/12/03 09:03:28 We have a separate issue for this: crbug.com/32133
+ 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] =
dzhioev (left Google) 2013/12/03 08:28:32 Do we need load all the sounds? We play only SOUND
ygorshenin1 2013/12/03 09:03:28 We have a separate issue for this: crbug.com/32133
+ bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV);
+ for (size_t i = 0; i < sound_resources.size(); ++i) {
+ DCHECK(!sound_resources[i].empty()) << "System sound " << i << " "
+ << "missing.";
+ }
+ if (!media::SoundsManager::Get()->Initialize(sound_resources))
dzhioev (left Google) 2013/12/03 08:28:32 Why SoundsManager can't initialize by itself? I me
ygorshenin1 2013/12/03 09:03:28 Because it lives in media/ and has no idea about r
+ LOG(ERROR) << "Failed to initialize SoundsManager.";
}
LoginDisplayHostImpl::~LoginDisplayHostImpl() {
DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
+ CrasAudioHandler::Get()->RemoveAudioObserver(this);
views::FocusManager::set_arrow_key_traversal_enabled(false);
ResetLoginWindowAndView();
@@ -488,7 +510,8 @@ void LoginDisplayHostImpl::GetAutoEnrollmentCheckResult(
void LoginDisplayHostImpl::StartWizard(
const std::string& first_screen_name,
scoped_ptr<DictionaryValue> screen_parameters) {
- TryToPlayStartupSound(false);
+ startup_sound_honors_spoken_feedback_ = false;
+ TryToPlayStartupSound();
// Keep parameters to restore if renderer crashes.
restore_path_ = RESTORE_WIZARD;
@@ -563,7 +586,8 @@ void LoginDisplayHostImpl::StartUserAdding(
void LoginDisplayHostImpl::StartSignInScreen(
const LoginScreenContext& context) {
- TryToPlayStartupSound(true);
+ startup_sound_honors_spoken_feedback_ = true;
+ TryToPlayStartupSound();
restore_path_ = RESTORE_SIGN_IN;
is_showing_login_ = true;
@@ -787,6 +811,10 @@ void LoginDisplayHostImpl::EmitLoginPromptVisibleCalled() {
OnLoginPromptVisible();
}
+void LoginDisplayHostImpl::OnActiveOutputNodeChanged() {
+ TryToPlayStartupSound();
+}
+
////////////////////////////////////////////////////////////////////////////////
// LoginDisplayHostImpl, private
@@ -1010,40 +1038,19 @@ void LoginDisplayHostImpl::NotifyAutoEnrollmentCheckResult(
callbacks[i].Run(should_auto_enroll);
}
-void LoginDisplayHostImpl::TryToPlayStartupSound(bool honor_spoken_feedback) {
- if (startup_sound_requested_)
+void LoginDisplayHostImpl::TryToPlayStartupSound() {
+ if (login_prompt_visible_time_.is_null())
return;
- startup_sound_requested_ = true;
- startup_sound_honors_spoken_feedback_ = honor_spoken_feedback;
- if (!login_prompt_visible_time_.is_null())
- PlayStartupSound();
+ if (!CrasAudioHandler::Get()->GetActiveOutputNode())
+ return;
+ PlayStartupSound();
}
void LoginDisplayHostImpl::OnLoginPromptVisible() {
if (!login_prompt_visible_time_.is_null())
return;
-
- 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);
- for (size_t i = 0; i < sound_resources.size(); ++i) {
- DCHECK(!sound_resources[i].empty()) << "System sound " << i << " "
- << "missing.";
- }
- if (!media::SoundsManager::Get()->Initialize(sound_resources))
- LOG(ERROR) << "Failed to initialize SoundsManager.";
-
login_prompt_visible_time_ = base::TimeTicks::Now();
- if (startup_sound_requested_ && !startup_sound_played_)
- PlayStartupSound();
+ TryToPlayStartupSound();
}
void LoginDisplayHostImpl::PlayStartupSound() {
dzhioev (left Google) 2013/12/03 08:28:32 Why it's called PlayStartupSound if it doesn't pla
ygorshenin1 2013/12/03 09:03:28 Good point, done.
@@ -1051,15 +1058,18 @@ void LoginDisplayHostImpl::PlayStartupSound() {
return;
startup_sound_played_ = true;
- // TODO (ygorshenin@): remove this as soon as crbug.com/315108 will
- // be fixed.
- return;
-
const base::TimeDelta delay =
- base::TimeDelta::FromMilliseconds(kStartupSoundInitialDelayMs);
+ base::TimeDelta::FromMilliseconds(kMinDelayAfterLoginPromptVisibleMs);
const base::TimeDelta delta =
dzhioev (left Google) 2013/12/03 08:28:32 Please rename delay and delta to something more me
ygorshenin1 2013/12/03 09:03:28 Done.
base::TimeTicks::Now() - login_prompt_visible_time_;
+ // Don't play startup sound if login prompt is already visible for a
+ // long time.
+ if (delta >
+ base::TimeDelta::FromMilliseconds(kMaxDelayAfterLoginPromptVisibleMs)) {
+ return;
+ }
+
// Cras audio server starts initialization after
// login-prompt-visible signal from session manager. Alas, but it
// doesn't send notifications after initialization. Thus, we're
« no previous file with comments | « chrome/browser/chromeos/login/login_display_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698