| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/login_display_host_impl.h" | 5 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/wallpaper/wallpaper_controller.h" | 10 #include "ash/common/wallpaper/wallpaper_controller.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #include "content/public/browser/notification_service.h" | 87 #include "content/public/browser/notification_service.h" |
| 88 #include "content/public/browser/notification_types.h" | 88 #include "content/public/browser/notification_types.h" |
| 89 #include "content/public/browser/web_contents.h" | 89 #include "content/public/browser/web_contents.h" |
| 90 #include "content/public/browser/web_ui.h" | 90 #include "content/public/browser/web_ui.h" |
| 91 #include "media/audio/sounds/sounds_manager.h" | 91 #include "media/audio/sounds/sounds_manager.h" |
| 92 #include "services/ui/public/cpp/property_type_converters.h" | 92 #include "services/ui/public/cpp/property_type_converters.h" |
| 93 #include "services/ui/public/interfaces/window_manager.mojom.h" | 93 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 94 #include "ui/aura/window.h" | 94 #include "ui/aura/window.h" |
| 95 #include "ui/base/ime/chromeos/extension_ime_util.h" | 95 #include "ui/base/ime/chromeos/extension_ime_util.h" |
| 96 #include "ui/base/ime/chromeos/input_method_manager.h" | 96 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 97 #include "ui/base/l10n/l10n_util.h" |
| 97 #include "ui/base/resource/resource_bundle.h" | 98 #include "ui/base/resource/resource_bundle.h" |
| 98 #include "ui/compositor/layer.h" | 99 #include "ui/compositor/layer.h" |
| 99 #include "ui/compositor/layer_animation_observer.h" | 100 #include "ui/compositor/layer_animation_observer.h" |
| 100 #include "ui/compositor/scoped_layer_animation_settings.h" | 101 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 101 #include "ui/display/display.h" | 102 #include "ui/display/display.h" |
| 102 #include "ui/display/screen.h" | 103 #include "ui/display/screen.h" |
| 103 #include "ui/events/event_utils.h" | 104 #include "ui/events/event_utils.h" |
| 104 #include "ui/gfx/geometry/rect.h" | 105 #include "ui/gfx/geometry/rect.h" |
| 105 #include "ui/gfx/geometry/size.h" | 106 #include "ui/gfx/geometry/size.h" |
| 106 #include "ui/gfx/transform.h" | 107 #include "ui/gfx/transform.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void OnImplicitAnimationsCompleted() override { | 167 void OnImplicitAnimationsCompleted() override { |
| 167 callback_.Run(); | 168 callback_.Run(); |
| 168 delete this; | 169 delete this; |
| 169 } | 170 } |
| 170 | 171 |
| 171 base::Closure callback_; | 172 base::Closure callback_; |
| 172 | 173 |
| 173 DISALLOW_COPY_AND_ASSIGN(AnimationObserver); | 174 DISALLOW_COPY_AND_ASSIGN(AnimationObserver); |
| 174 }; | 175 }; |
| 175 | 176 |
| 177 bool ShouldShowSigninScreen(chromeos::OobeScreen first_screen) { |
| 178 return (first_screen == chromeos::OobeScreen::SCREEN_UNKNOWN && |
| 179 chromeos::StartupUtils::IsOobeCompleted()) || |
| 180 first_screen == chromeos::OobeScreen::SCREEN_SPECIAL_LOGIN; |
| 181 } |
| 182 |
| 176 // ShowLoginWizard is split into two parts. This function is sometimes called | 183 // ShowLoginWizard is split into two parts. This function is sometimes called |
| 177 // from ShowLoginWizard(), and sometimes from OnLanguageSwitchedCallback() | 184 // from TriggerShowLoginWizardFinish() directly, and sometimes from |
| 185 // OnLanguageSwitchedCallback() |
| 178 // (if locale was updated). | 186 // (if locale was updated). |
| 179 void ShowLoginWizardFinish( | 187 void ShowLoginWizardFinish( |
| 180 chromeos::OobeScreen first_screen, | 188 chromeos::OobeScreen first_screen, |
| 181 const chromeos::StartupCustomizationDocument* startup_manifest, | 189 const chromeos::StartupCustomizationDocument* startup_manifest, |
| 182 chromeos::LoginDisplayHost* display_host) { | 190 chromeos::LoginDisplayHost* display_host) { |
| 183 TRACE_EVENT0("chromeos", "ShowLoginWizard::ShowLoginWizardFinish"); | 191 TRACE_EVENT0("chromeos", "ShowLoginWizard::ShowLoginWizardFinish"); |
| 184 | 192 |
| 185 display_host->StartWizard(first_screen); | 193 if (ShouldShowSigninScreen(first_screen)) { |
| 194 display_host->StartSignInScreen(chromeos::LoginScreenContext()); |
| 195 } else { |
| 196 display_host->StartWizard(first_screen); |
| 186 | 197 |
| 187 // Set initial timezone if specified by customization. | 198 // Set initial timezone if specified by customization. |
| 188 const std::string timezone_name = startup_manifest->initial_timezone(); | 199 const std::string timezone_name = startup_manifest->initial_timezone(); |
| 189 VLOG(1) << "Initial time zone: " << timezone_name; | 200 VLOG(1) << "Initial time zone: " << timezone_name; |
| 190 // Apply locale customizations only once to preserve whatever locale | 201 // Apply locale customizations only once to preserve whatever locale |
| 191 // user has changed to during OOBE. | 202 // user has changed to during OOBE. |
| 192 if (!timezone_name.empty()) { | 203 if (!timezone_name.empty()) { |
| 193 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 204 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 194 base::UTF8ToUTF16(timezone_name)); | 205 base::UTF8ToUTF16(timezone_name)); |
| 206 } |
| 195 } | 207 } |
| 196 } | 208 } |
| 197 | 209 |
| 198 struct ShowLoginWizardSwitchLanguageCallbackData { | 210 struct ShowLoginWizardSwitchLanguageCallbackData { |
| 199 explicit ShowLoginWizardSwitchLanguageCallbackData( | 211 explicit ShowLoginWizardSwitchLanguageCallbackData( |
| 200 chromeos::OobeScreen first_screen, | 212 chromeos::OobeScreen first_screen, |
| 201 const chromeos::StartupCustomizationDocument* startup_manifest, | 213 const chromeos::StartupCustomizationDocument* startup_manifest, |
| 202 chromeos::LoginDisplayHost* display_host) | 214 chromeos::LoginDisplayHost* display_host) |
| 203 : first_screen(first_screen), | 215 : first_screen(first_screen), |
| 204 startup_manifest(startup_manifest), | 216 startup_manifest(startup_manifest), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 216 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> self, | 228 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> self, |
| 217 const chromeos::locale_util::LanguageSwitchResult& result) { | 229 const chromeos::locale_util::LanguageSwitchResult& result) { |
| 218 if (!result.success) | 230 if (!result.success) |
| 219 LOG(WARNING) << "Locale could not be found for '" << result.requested_locale | 231 LOG(WARNING) << "Locale could not be found for '" << result.requested_locale |
| 220 << "'"; | 232 << "'"; |
| 221 | 233 |
| 222 ShowLoginWizardFinish(self->first_screen, self->startup_manifest, | 234 ShowLoginWizardFinish(self->first_screen, self->startup_manifest, |
| 223 self->display_host); | 235 self->display_host); |
| 224 } | 236 } |
| 225 | 237 |
| 238 // Triggers ShowLoginWizardFinish directly if no locale switch is required |
| 239 // (|switch_locale| is empty) or after a locale switch otherwise. |
| 240 void TriggerShowLoginWizardFinish( |
| 241 std::string switch_locale, |
| 242 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data) { |
| 243 if (switch_locale.empty()) { |
| 244 ShowLoginWizardFinish(data->first_screen, data->startup_manifest, |
| 245 data->display_host); |
| 246 } else { |
| 247 chromeos::locale_util::SwitchLanguageCallback callback( |
| 248 base::Bind(&OnLanguageSwitchedCallback, base::Passed(std::move(data)))); |
| 249 |
| 250 // Load locale keyboards here. Hardware layout would be automatically |
| 251 // enabled. |
| 252 chromeos::locale_util::SwitchLanguage( |
| 253 switch_locale, true, true /* login_layouts_only */, callback, |
| 254 ProfileManager::GetActiveUserProfile()); |
| 255 } |
| 256 } |
| 257 |
| 258 // Returns the login screen locale mandated by device policy, or an empty string |
| 259 // if no policy-specified locale is set. |
| 260 std::string GetManagedLoginScreenLocale() { |
| 261 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); |
| 262 const base::ListValue* login_screen_locales = nullptr; |
| 263 if (!cros_settings->GetList(chromeos::kDeviceLoginScreenLocales, |
| 264 &login_screen_locales)) |
| 265 return std::string(); |
| 266 |
| 267 // Currently, only the first element is used. The setting is a list for future |
| 268 // compatibility, if dynamically switching locales on the login screen will be |
| 269 // implemented. |
| 270 std::string login_screen_locale; |
| 271 if (login_screen_locales->empty() || |
| 272 !login_screen_locales->GetString(0, &login_screen_locale)) |
| 273 return std::string(); |
| 274 |
| 275 return login_screen_locale; |
| 276 } |
| 277 |
| 226 void EnableSystemSoundsForAccessibility() { | 278 void EnableSystemSoundsForAccessibility() { |
| 227 chromeos::AccessibilityManager::Get()->EnableSystemSounds(true); | 279 chromeos::AccessibilityManager::Get()->EnableSystemSounds(true); |
| 228 } | 280 } |
| 229 | 281 |
| 230 // A login implementation of WidgetDelegate. | 282 // A login implementation of WidgetDelegate. |
| 231 class LoginWidgetDelegate : public views::WidgetDelegate { | 283 class LoginWidgetDelegate : public views::WidgetDelegate { |
| 232 public: | 284 public: |
| 233 explicit LoginWidgetDelegate(views::Widget* widget) : widget_(widget) { | 285 explicit LoginWidgetDelegate(views::Widget* widget) : widget_(widget) { |
| 234 } | 286 } |
| 235 ~LoginWidgetDelegate() override {} | 287 ~LoginWidgetDelegate() override {} |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 ->wallpaper_delegate() | 922 ->wallpaper_delegate() |
| 871 ->OnWallpaperBootAnimationFinished(); | 923 ->OnWallpaperBootAnimationFinished(); |
| 872 } else { | 924 } else { |
| 873 NOTIMPLEMENTED(); | 925 NOTIMPLEMENTED(); |
| 874 } | 926 } |
| 875 if (waiting_for_wallpaper_load_) { | 927 if (waiting_for_wallpaper_load_) { |
| 876 // StartWizard / StartSignInScreen could be called multiple times through | 928 // StartWizard / StartSignInScreen could be called multiple times through |
| 877 // the lifetime of host. | 929 // the lifetime of host. |
| 878 // Make sure that subsequent calls are not postponed. | 930 // Make sure that subsequent calls are not postponed. |
| 879 waiting_for_wallpaper_load_ = false; | 931 waiting_for_wallpaper_load_ = false; |
| 880 if (initialize_webui_hidden_) | 932 if (initialize_webui_hidden_) { |
| 881 ShowWebUI(); | 933 // If we're in the process of switching locale, the wallpaper might |
| 882 else | 934 // have finished loading before the locale switch was completed. |
| 935 // Only show the UI if it already exists. |
| 936 if (login_window_ && login_view_) |
| 937 ShowWebUI(); |
| 938 } else { |
| 883 StartPostponedWebUI(); | 939 StartPostponedWebUI(); |
| 940 } |
| 884 } | 941 } |
| 885 registrar_.Remove(this, | 942 registrar_.Remove(this, |
| 886 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, | 943 chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, |
| 887 content::NotificationService::AllSources()); | 944 content::NotificationService::AllSources()); |
| 888 } | 945 } |
| 889 } | 946 } |
| 890 | 947 |
| 891 //////////////////////////////////////////////////////////////////////////////// | 948 //////////////////////////////////////////////////////////////////////////////// |
| 892 // LoginDisplayHostImpl, WebContentsObserver: | 949 // LoginDisplayHostImpl, WebContentsObserver: |
| 893 | 950 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 DelayNetworkCall( | 1383 DelayNetworkCall( |
| 1327 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS), | 1384 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS), |
| 1328 ServicesCustomizationDocument::GetInstance() | 1385 ServicesCustomizationDocument::GetInstance() |
| 1329 ->EnsureCustomizationAppliedClosure()); | 1386 ->EnsureCustomizationAppliedClosure()); |
| 1330 | 1387 |
| 1331 g_browser_process->platform_part() | 1388 g_browser_process->platform_part() |
| 1332 ->GetTimezoneResolverManager() | 1389 ->GetTimezoneResolverManager() |
| 1333 ->UpdateTimezoneResolver(); | 1390 ->UpdateTimezoneResolver(); |
| 1334 } | 1391 } |
| 1335 | 1392 |
| 1336 bool show_login_screen = (first_screen == OobeScreen::SCREEN_UNKNOWN && | 1393 PrefService* prefs = g_browser_process->local_state(); |
| 1337 StartupUtils::IsOobeCompleted()) || | 1394 const std::string& current_locale = |
| 1338 first_screen == OobeScreen::SCREEN_SPECIAL_LOGIN; | 1395 prefs->GetString(prefs::kApplicationLocale); |
| 1396 VLOG(1) << "Current locale: " << current_locale; |
| 1339 | 1397 |
| 1340 if (show_login_screen) { | 1398 if (ShouldShowSigninScreen(first_screen)) { |
| 1341 display_host->StartSignInScreen(LoginScreenContext()); | 1399 std::string switch_locale = GetManagedLoginScreenLocale(); |
| 1400 if (switch_locale == current_locale) |
| 1401 switch_locale.clear(); |
| 1402 |
| 1403 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data = |
| 1404 base::MakeUnique<ShowLoginWizardSwitchLanguageCallbackData>( |
| 1405 first_screen, nullptr, display_host); |
| 1406 TriggerShowLoginWizardFinish(switch_locale, std::move(data)); |
| 1342 return; | 1407 return; |
| 1343 } | 1408 } |
| 1344 | 1409 |
| 1345 // Load startup manifest. | 1410 // Load startup manifest. |
| 1346 const StartupCustomizationDocument* startup_manifest = | 1411 const StartupCustomizationDocument* startup_manifest = |
| 1347 StartupCustomizationDocument::GetInstance(); | 1412 StartupCustomizationDocument::GetInstance(); |
| 1348 | 1413 |
| 1349 // Switch to initial locale if specified by customization | 1414 // Switch to initial locale if specified by customization |
| 1350 // and has not been set yet. We cannot call | 1415 // and has not been set yet. We cannot call |
| 1351 // LanguageSwitchMenu::SwitchLanguage here before | 1416 // LanguageSwitchMenu::SwitchLanguage here before |
| 1352 // EmitLoginPromptReady. | 1417 // EmitLoginPromptReady. |
| 1353 PrefService* prefs = g_browser_process->local_state(); | |
| 1354 const std::string& current_locale = | |
| 1355 prefs->GetString(prefs::kApplicationLocale); | |
| 1356 VLOG(1) << "Current locale: " << current_locale; | |
| 1357 const std::string& locale = startup_manifest->initial_locale_default(); | 1418 const std::string& locale = startup_manifest->initial_locale_default(); |
| 1358 | 1419 |
| 1359 const std::string& layout = startup_manifest->keyboard_layout(); | 1420 const std::string& layout = startup_manifest->keyboard_layout(); |
| 1360 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; | 1421 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; |
| 1361 | 1422 |
| 1362 // Determine keyboard layout from OEM customization (if provided) or | 1423 // Determine keyboard layout from OEM customization (if provided) or |
| 1363 // initial locale and save it in preferences. | 1424 // initial locale and save it in preferences. |
| 1364 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale, | 1425 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale, |
| 1365 layout); | 1426 layout); |
| 1366 | 1427 |
| 1428 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( |
| 1429 new ShowLoginWizardSwitchLanguageCallbackData( |
| 1430 first_screen, startup_manifest, display_host)); |
| 1431 |
| 1367 if (!current_locale.empty() || locale.empty()) { | 1432 if (!current_locale.empty() || locale.empty()) { |
| 1368 ShowLoginWizardFinish(first_screen, startup_manifest, display_host); | 1433 TriggerShowLoginWizardFinish(std::string(), std::move(data)); |
| 1369 return; | 1434 return; |
| 1370 } | 1435 } |
| 1371 | 1436 |
| 1372 // Save initial locale from VPD/customization manifest as current | 1437 // Save initial locale from VPD/customization manifest as current |
| 1373 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 1438 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
| 1374 // Don't need to schedule pref save because setting initial local | 1439 // Don't need to schedule pref save because setting initial local |
| 1375 // will enforce preference saving. | 1440 // will enforce preference saving. |
| 1376 prefs->SetString(prefs::kApplicationLocale, locale); | 1441 prefs->SetString(prefs::kApplicationLocale, locale); |
| 1377 StartupUtils::SetInitialLocale(locale); | 1442 StartupUtils::SetInitialLocale(locale); |
| 1378 | 1443 |
| 1379 std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( | 1444 TriggerShowLoginWizardFinish(locale, std::move(data)); |
| 1380 new ShowLoginWizardSwitchLanguageCallbackData( | |
| 1381 first_screen, startup_manifest, display_host)); | |
| 1382 | |
| 1383 locale_util::SwitchLanguageCallback callback( | |
| 1384 base::Bind(&OnLanguageSwitchedCallback, base::Passed(std::move(data)))); | |
| 1385 | |
| 1386 // Load locale keyboards here. Hardware layout would be automatically enabled. | |
| 1387 locale_util::SwitchLanguage(locale, true, true /* login_layouts_only */, | |
| 1388 callback, ProfileManager::GetActiveUserProfile()); | |
| 1389 } | 1445 } |
| 1390 | 1446 |
| 1391 } // namespace chromeos | 1447 } // namespace chromeos |
| OLD | NEW |