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