OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/login/login_display_host_impl.h" | 5 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/desktop_background/desktop_background_controller.h" | 9 #include "ash/desktop_background/desktop_background_controller.h" |
10 #include "ash/desktop_background/user_wallpaper_delegate.h" | 10 #include "ash/desktop_background/user_wallpaper_delegate.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "ui/compositor/scoped_layer_animation_settings.h" | 76 #include "ui/compositor/scoped_layer_animation_settings.h" |
77 #include "ui/events/event_utils.h" | 77 #include "ui/events/event_utils.h" |
78 #include "ui/gfx/rect.h" | 78 #include "ui/gfx/rect.h" |
79 #include "ui/gfx/transform.h" | 79 #include "ui/gfx/transform.h" |
80 #include "ui/views/focus/focus_manager.h" | 80 #include "ui/views/focus/focus_manager.h" |
81 #include "ui/views/widget/widget.h" | 81 #include "ui/views/widget/widget.h" |
82 #include "url/gurl.h" | 82 #include "url/gurl.h" |
83 | 83 |
84 namespace { | 84 namespace { |
85 | 85 |
86 const int kStartupSoundInitialDelayMs = 500; | 86 // Maximum delay for startup sound after 'loginPromptVisible' signal. |
| 87 const int kStartupSoundMaxDelayMs = 2000; |
87 | 88 |
88 // URL which corresponds to the login WebUI. | 89 // URL which corresponds to the login WebUI. |
89 const char kLoginURL[] = "chrome://oobe/login"; | 90 const char kLoginURL[] = "chrome://oobe/login"; |
90 | 91 |
91 // URL which corresponds to the OOBE WebUI. | 92 // URL which corresponds to the OOBE WebUI. |
92 const char kOobeURL[] = "chrome://oobe/oobe"; | 93 const char kOobeURL[] = "chrome://oobe/oobe"; |
93 | 94 |
94 // URL which corresponds to the user adding WebUI. | 95 // URL which corresponds to the user adding WebUI. |
95 const char kUserAddingURL[] = "chrome://oobe/user-adding"; | 96 const char kUserAddingURL[] = "chrome://oobe/user-adding"; |
96 | 97 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 166 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
166 callback_.Run(); | 167 callback_.Run(); |
167 delete this; | 168 delete this; |
168 } | 169 } |
169 | 170 |
170 base::Closure callback_; | 171 base::Closure callback_; |
171 | 172 |
172 DISALLOW_COPY_AND_ASSIGN(AnimationObserver); | 173 DISALLOW_COPY_AND_ASSIGN(AnimationObserver); |
173 }; | 174 }; |
174 | 175 |
175 void PlayStartupSoundHelper(bool startup_sound_honors_spoken_feedback) { | |
176 if (!startup_sound_honors_spoken_feedback || | |
177 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { | |
178 media::SoundsManager::Get()->Play(media::SoundsManager::SOUND_STARTUP); | |
179 } | |
180 } | |
181 | |
182 // ShowLoginWizard is split into two parts. This function is sometimes called | 176 // ShowLoginWizard is split into two parts. This function is sometimes called |
183 // from ShowLoginWizard(), and sometimes from OnLanguageSwitchedCallback() | 177 // from ShowLoginWizard(), and sometimes from OnLanguageSwitchedCallback() |
184 // (if locale was updated). | 178 // (if locale was updated). |
185 void ShowLoginWizardFinish( | 179 void ShowLoginWizardFinish( |
186 const std::string& first_screen_name, | 180 const std::string& first_screen_name, |
187 const chromeos::StartupCustomizationDocument* startup_manifest, | 181 const chromeos::StartupCustomizationDocument* startup_manifest, |
188 chromeos::LoginDisplayHost* display_host) { | 182 chromeos::LoginDisplayHost* display_host) { |
189 scoped_ptr<DictionaryValue> params; | 183 scoped_ptr<DictionaryValue> params; |
190 display_host->StartWizard(first_screen_name, params.Pass()); | 184 display_host->StartWizard(first_screen_name, params.Pass()); |
191 | 185 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 login_view_(NULL), | 251 login_view_(NULL), |
258 webui_login_display_(NULL), | 252 webui_login_display_(NULL), |
259 is_showing_login_(false), | 253 is_showing_login_(false), |
260 is_wallpaper_loaded_(false), | 254 is_wallpaper_loaded_(false), |
261 status_area_saved_visibility_(false), | 255 status_area_saved_visibility_(false), |
262 crash_count_(0), | 256 crash_count_(0), |
263 restore_path_(RESTORE_UNKNOWN), | 257 restore_path_(RESTORE_UNKNOWN), |
264 auto_enrollment_check_done_(false), | 258 auto_enrollment_check_done_(false), |
265 finalize_animation_type_(ANIMATION_WORKSPACE), | 259 finalize_animation_type_(ANIMATION_WORKSPACE), |
266 animation_weak_ptr_factory_(this), | 260 animation_weak_ptr_factory_(this), |
267 startup_sound_requested_(false), | |
268 startup_sound_played_(false), | 261 startup_sound_played_(false), |
269 startup_sound_honors_spoken_feedback_(false) { | 262 startup_sound_honors_spoken_feedback_(false) { |
270 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 263 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 264 CrasAudioHandler::Get()->AddAudioObserver(this); |
271 | 265 |
272 // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING | 266 // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING |
273 // because/ APP_TERMINATING will never be fired as long as this keeps | 267 // because/ APP_TERMINATING will never be fired as long as this keeps |
274 // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no | 268 // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no |
275 // browser instance that will block the shutdown. | 269 // browser instance that will block the shutdown. |
276 registrar_.Add(this, | 270 registrar_.Add(this, |
277 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 271 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
278 content::NotificationService::AllSources()); | 272 content::NotificationService::AllSources()); |
279 | 273 |
280 // NOTIFICATION_BROWSER_OPENED is issued after browser is created, but | 274 // NOTIFICATION_BROWSER_OPENED is issued after browser is created, but |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 340 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
347 content::NotificationService::AllSources()); | 341 content::NotificationService::AllSources()); |
348 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | 342 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, |
349 content::NotificationService::AllSources()); | 343 content::NotificationService::AllSources()); |
350 } | 344 } |
351 LOG(WARNING) << "Login WebUI >> " | 345 LOG(WARNING) << "Login WebUI >> " |
352 << "zero_delay: " << zero_delay_enabled | 346 << "zero_delay: " << zero_delay_enabled |
353 << " wait_for_wp_load_: " << waiting_for_wallpaper_load_ | 347 << " wait_for_wp_load_: " << waiting_for_wallpaper_load_ |
354 << " wait_for_pods_: " << waiting_for_user_pods_ | 348 << " wait_for_pods_: " << waiting_for_user_pods_ |
355 << " init_webui_hidden_: " << initialize_webui_hidden_; | 349 << " init_webui_hidden_: " << initialize_webui_hidden_; |
| 350 |
| 351 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 352 std::vector<base::StringPiece> sound_resources( |
| 353 media::SoundsManager::SOUND_COUNT); |
| 354 sound_resources[media::SoundsManager::SOUND_STARTUP] = |
| 355 bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV); |
| 356 sound_resources[media::SoundsManager::SOUND_LOCK] = |
| 357 bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV); |
| 358 sound_resources[media::SoundsManager::SOUND_UNLOCK] = |
| 359 bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV); |
| 360 sound_resources[media::SoundsManager::SOUND_SHUTDOWN] = |
| 361 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV); |
| 362 for (size_t i = 0; i < sound_resources.size(); ++i) { |
| 363 DCHECK(!sound_resources[i].empty()) << "System sound " << i << " " |
| 364 << "missing."; |
| 365 } |
| 366 if (!media::SoundsManager::Get()->Initialize(sound_resources)) |
| 367 LOG(ERROR) << "Failed to initialize SoundsManager."; |
356 } | 368 } |
357 | 369 |
358 LoginDisplayHostImpl::~LoginDisplayHostImpl() { | 370 LoginDisplayHostImpl::~LoginDisplayHostImpl() { |
359 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 371 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 372 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
360 | 373 |
361 views::FocusManager::set_arrow_key_traversal_enabled(false); | 374 views::FocusManager::set_arrow_key_traversal_enabled(false); |
362 ResetLoginWindowAndView(); | 375 ResetLoginWindowAndView(); |
363 | 376 |
364 // Let chrome process exit after login/oobe screen if needed. | 377 // Let chrome process exit after login/oobe screen if needed. |
365 chrome::EndKeepAlive(); | 378 chrome::EndKeepAlive(); |
366 | 379 |
367 default_host_ = NULL; | 380 default_host_ = NULL; |
368 // TODO(dzhioev): find better place for starting tutorial. | 381 // TODO(dzhioev): find better place for starting tutorial. |
369 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 382 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 auto_enrollment_client_->should_auto_enroll()); | 494 auto_enrollment_client_->should_auto_enroll()); |
482 return; | 495 return; |
483 } | 496 } |
484 | 497 |
485 get_auto_enrollment_result_callbacks_.push_back(callback); | 498 get_auto_enrollment_result_callbacks_.push_back(callback); |
486 } | 499 } |
487 | 500 |
488 void LoginDisplayHostImpl::StartWizard( | 501 void LoginDisplayHostImpl::StartWizard( |
489 const std::string& first_screen_name, | 502 const std::string& first_screen_name, |
490 scoped_ptr<DictionaryValue> screen_parameters) { | 503 scoped_ptr<DictionaryValue> screen_parameters) { |
491 TryToPlayStartupSound(false); | 504 startup_sound_honors_spoken_feedback_ = false; |
| 505 TryToPlayStartupSound(); |
492 | 506 |
493 // Keep parameters to restore if renderer crashes. | 507 // Keep parameters to restore if renderer crashes. |
494 restore_path_ = RESTORE_WIZARD; | 508 restore_path_ = RESTORE_WIZARD; |
495 wizard_first_screen_name_ = first_screen_name; | 509 wizard_first_screen_name_ = first_screen_name; |
496 if (screen_parameters.get()) | 510 if (screen_parameters.get()) |
497 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); | 511 wizard_screen_parameters_.reset(screen_parameters->DeepCopy()); |
498 else | 512 else |
499 wizard_screen_parameters_.reset(); | 513 wizard_screen_parameters_.reset(); |
500 is_showing_login_ = false; | 514 is_showing_login_ = false; |
501 | 515 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 sign_in_controller_->Init( | 570 sign_in_controller_->Init( |
557 chromeos::UserManager::Get()->GetUsersAdmittedForMultiProfile()); | 571 chromeos::UserManager::Get()->GetUsersAdmittedForMultiProfile()); |
558 CHECK(webui_login_display_); | 572 CHECK(webui_login_display_); |
559 GetOobeUI()->ShowSigninScreen(LoginScreenContext(), | 573 GetOobeUI()->ShowSigninScreen(LoginScreenContext(), |
560 webui_login_display_, | 574 webui_login_display_, |
561 webui_login_display_); | 575 webui_login_display_); |
562 } | 576 } |
563 | 577 |
564 void LoginDisplayHostImpl::StartSignInScreen( | 578 void LoginDisplayHostImpl::StartSignInScreen( |
565 const LoginScreenContext& context) { | 579 const LoginScreenContext& context) { |
566 TryToPlayStartupSound(true); | 580 startup_sound_honors_spoken_feedback_ = true; |
| 581 TryToPlayStartupSound(); |
567 | 582 |
568 restore_path_ = RESTORE_SIGN_IN; | 583 restore_path_ = RESTORE_SIGN_IN; |
569 is_showing_login_ = true; | 584 is_showing_login_ = true; |
570 finalize_animation_type_ = ANIMATION_WORKSPACE; | 585 finalize_animation_type_ = ANIMATION_WORKSPACE; |
571 | 586 |
572 PrewarmAuthentication(); | 587 PrewarmAuthentication(); |
573 | 588 |
574 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { | 589 if (waiting_for_wallpaper_load_ && !initialize_webui_hidden_) { |
575 LOG(WARNING) << "Login WebUI >> sign in postponed"; | 590 LOG(WARNING) << "Login WebUI >> sign in postponed"; |
576 return; | 591 return; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 795 } |
781 | 796 |
782 //////////////////////////////////////////////////////////////////////////////// | 797 //////////////////////////////////////////////////////////////////////////////// |
783 // LoginDisplayHostImpl, chromeos::SessionManagerClient::Observer | 798 // LoginDisplayHostImpl, chromeos::SessionManagerClient::Observer |
784 // implementation: | 799 // implementation: |
785 | 800 |
786 void LoginDisplayHostImpl::EmitLoginPromptVisibleCalled() { | 801 void LoginDisplayHostImpl::EmitLoginPromptVisibleCalled() { |
787 OnLoginPromptVisible(); | 802 OnLoginPromptVisible(); |
788 } | 803 } |
789 | 804 |
| 805 void LoginDisplayHostImpl::OnActiveOutputNodeChanged() { |
| 806 TryToPlayStartupSound(); |
| 807 } |
| 808 |
790 //////////////////////////////////////////////////////////////////////////////// | 809 //////////////////////////////////////////////////////////////////////////////// |
791 // LoginDisplayHostImpl, private | 810 // LoginDisplayHostImpl, private |
792 | 811 |
793 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { | 812 void LoginDisplayHostImpl::ShutdownDisplayHost(bool post_quit_task) { |
794 if (shutting_down_) | 813 if (shutting_down_) |
795 return; | 814 return; |
796 | 815 |
797 shutting_down_ = true; | 816 shutting_down_ = true; |
798 registrar_.RemoveAll(); | 817 registrar_.RemoveAll(); |
799 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 818 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 } | 1022 } |
1004 | 1023 |
1005 void LoginDisplayHostImpl::NotifyAutoEnrollmentCheckResult( | 1024 void LoginDisplayHostImpl::NotifyAutoEnrollmentCheckResult( |
1006 bool should_auto_enroll) { | 1025 bool should_auto_enroll) { |
1007 std::vector<GetAutoEnrollmentCheckResultCallback> callbacks; | 1026 std::vector<GetAutoEnrollmentCheckResultCallback> callbacks; |
1008 callbacks.swap(get_auto_enrollment_result_callbacks_); | 1027 callbacks.swap(get_auto_enrollment_result_callbacks_); |
1009 for (size_t i = 0; i < callbacks.size(); ++i) | 1028 for (size_t i = 0; i < callbacks.size(); ++i) |
1010 callbacks[i].Run(should_auto_enroll); | 1029 callbacks[i].Run(should_auto_enroll); |
1011 } | 1030 } |
1012 | 1031 |
1013 void LoginDisplayHostImpl::TryToPlayStartupSound(bool honor_spoken_feedback) { | 1032 void LoginDisplayHostImpl::TryToPlayStartupSound() { |
1014 if (startup_sound_requested_) | 1033 if (startup_sound_played_ || login_prompt_visible_time_.is_null() || |
| 1034 !CrasAudioHandler::Get()->GetActiveOutputNode()) { |
1015 return; | 1035 return; |
1016 startup_sound_requested_ = true; | 1036 } |
1017 startup_sound_honors_spoken_feedback_ = honor_spoken_feedback; | 1037 |
1018 if (!login_prompt_visible_time_.is_null()) | 1038 // Don't play startup sound if login prompt is already visible for a |
1019 PlayStartupSound(); | 1039 // long time. |
| 1040 if (base::TimeTicks::Now() - login_prompt_visible_time_ > |
| 1041 base::TimeDelta::FromMilliseconds(kStartupSoundMaxDelayMs)) { |
| 1042 return; |
| 1043 } |
| 1044 |
| 1045 if (!startup_sound_honors_spoken_feedback_ || |
| 1046 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 1047 startup_sound_played_ = true; |
| 1048 media::SoundsManager::Get()->Play(media::SoundsManager::SOUND_STARTUP); |
| 1049 } |
1020 } | 1050 } |
1021 | 1051 |
1022 void LoginDisplayHostImpl::OnLoginPromptVisible() { | 1052 void LoginDisplayHostImpl::OnLoginPromptVisible() { |
1023 if (!login_prompt_visible_time_.is_null()) | 1053 if (!login_prompt_visible_time_.is_null()) |
1024 return; | 1054 return; |
1025 | |
1026 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | |
1027 std::vector<base::StringPiece> sound_resources( | |
1028 media::SoundsManager::SOUND_COUNT); | |
1029 sound_resources[media::SoundsManager::SOUND_STARTUP] = | |
1030 bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV); | |
1031 sound_resources[media::SoundsManager::SOUND_LOCK] = | |
1032 bundle.GetRawDataResource(IDR_SOUND_LOCK_WAV); | |
1033 sound_resources[media::SoundsManager::SOUND_UNLOCK] = | |
1034 bundle.GetRawDataResource(IDR_SOUND_UNLOCK_WAV); | |
1035 sound_resources[media::SoundsManager::SOUND_SHUTDOWN] = | |
1036 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV); | |
1037 for (size_t i = 0; i < sound_resources.size(); ++i) { | |
1038 DCHECK(!sound_resources[i].empty()) << "System sound " << i << " " | |
1039 << "missing."; | |
1040 } | |
1041 if (!media::SoundsManager::Get()->Initialize(sound_resources)) | |
1042 LOG(ERROR) << "Failed to initialize SoundsManager."; | |
1043 | |
1044 login_prompt_visible_time_ = base::TimeTicks::Now(); | 1055 login_prompt_visible_time_ = base::TimeTicks::Now(); |
1045 if (startup_sound_requested_ && !startup_sound_played_) | 1056 TryToPlayStartupSound(); |
1046 PlayStartupSound(); | |
1047 } | |
1048 | |
1049 void LoginDisplayHostImpl::PlayStartupSound() { | |
1050 if (startup_sound_played_) | |
1051 return; | |
1052 startup_sound_played_ = true; | |
1053 | |
1054 // TODO (ygorshenin@): remove this as soon as crbug.com/315108 will | |
1055 // be fixed. | |
1056 return; | |
1057 | |
1058 const base::TimeDelta delay = | |
1059 base::TimeDelta::FromMilliseconds(kStartupSoundInitialDelayMs); | |
1060 const base::TimeDelta delta = | |
1061 base::TimeTicks::Now() - login_prompt_visible_time_; | |
1062 | |
1063 // Cras audio server starts initialization after | |
1064 // login-prompt-visible signal from session manager. Alas, but it | |
1065 // doesn't send notifications after initialization. Thus, we're | |
1066 // trying to play startup sound after some delay. | |
1067 if (delta > delay) { | |
1068 PlayStartupSoundHelper(startup_sound_honors_spoken_feedback_); | |
1069 } else { | |
1070 base::MessageLoop::current()->PostDelayedTask( | |
1071 FROM_HERE, | |
1072 base::Bind(&PlayStartupSoundHelper, | |
1073 startup_sound_honors_spoken_feedback_), | |
1074 delay - delta); | |
1075 } | |
1076 } | 1057 } |
1077 | 1058 |
1078 //////////////////////////////////////////////////////////////////////////////// | 1059 //////////////////////////////////////////////////////////////////////////////// |
1079 // external | 1060 // external |
1080 | 1061 |
1081 // Declared in login_wizard.h so that others don't need to depend on our .h. | 1062 // Declared in login_wizard.h so that others don't need to depend on our .h. |
1082 // TODO(nkostylev): Split this into a smaller functions. | 1063 // TODO(nkostylev): Split this into a smaller functions. |
1083 void ShowLoginWizard(const std::string& first_screen_name) { | 1064 void ShowLoginWizard(const std::string& first_screen_name) { |
1084 if (browser_shutdown::IsTryingToQuit()) | 1065 if (browser_shutdown::IsTryingToQuit()) |
1085 return; | 1066 return; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 | 1188 |
1208 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 1189 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
1209 new locale_util::SwitchLanguageCallback( | 1190 new locale_util::SwitchLanguageCallback( |
1210 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); | 1191 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); |
1211 | 1192 |
1212 // Do not load locale keyboards here. | 1193 // Do not load locale keyboards here. |
1213 locale_util::SwitchLanguage(locale, false, callback.Pass()); | 1194 locale_util::SwitchLanguage(locale, false, callback.Pass()); |
1214 } | 1195 } |
1215 | 1196 |
1216 } // namespace chromeos | 1197 } // namespace chromeos |
OLD | NEW |