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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/audio/sounds.h" | 9 #include "ash/audio/sounds.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "chrome/common/pref_names.h" | 61 #include "chrome/common/pref_names.h" |
62 #include "chromeos/audio/chromeos_sounds.h" | 62 #include "chromeos/audio/chromeos_sounds.h" |
63 #include "chromeos/chromeos_constants.h" | 63 #include "chromeos/chromeos_constants.h" |
64 #include "chromeos/chromeos_switches.h" | 64 #include "chromeos/chromeos_switches.h" |
65 #include "chromeos/dbus/dbus_thread_manager.h" | 65 #include "chromeos/dbus/dbus_thread_manager.h" |
66 #include "chromeos/dbus/session_manager_client.h" | 66 #include "chromeos/dbus/session_manager_client.h" |
67 #include "chromeos/ime/extension_ime_util.h" | 67 #include "chromeos/ime/extension_ime_util.h" |
68 #include "chromeos/ime/input_method_manager.h" | 68 #include "chromeos/ime/input_method_manager.h" |
69 #include "chromeos/login/login_state.h" | 69 #include "chromeos/login/login_state.h" |
70 #include "chromeos/settings/timezone_settings.h" | 70 #include "chromeos/settings/timezone_settings.h" |
| 71 #include "components/session_manager/core/session_manager.h" |
71 #include "content/public/browser/notification_service.h" | 72 #include "content/public/browser/notification_service.h" |
72 #include "content/public/browser/notification_types.h" | 73 #include "content/public/browser/notification_types.h" |
73 #include "content/public/browser/render_frame_host.h" | 74 #include "content/public/browser/render_frame_host.h" |
74 #include "content/public/browser/web_contents.h" | 75 #include "content/public/browser/web_contents.h" |
75 #include "content/public/browser/web_ui.h" | 76 #include "content/public/browser/web_ui.h" |
76 #include "grit/browser_resources.h" | 77 #include "grit/browser_resources.h" |
77 #include "media/audio/sounds/sounds_manager.h" | 78 #include "media/audio/sounds/sounds_manager.h" |
78 #include "ui/aura/window.h" | 79 #include "ui/aura/window.h" |
79 #include "ui/base/resource/resource_bundle.h" | 80 #include "ui/base/resource/resource_bundle.h" |
80 #include "ui/base/ui_base_switches_util.h" | 81 #include "ui/base/ui_base_switches_util.h" |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); | 1176 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); |
1176 system::InputDeviceSettings::Get()->SetTapToClick( | 1177 system::InputDeviceSettings::Get()->SetTapToClick( |
1177 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); | 1178 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); |
1178 } | 1179 } |
1179 system::InputDeviceSettings::Get()->SetNaturalScroll( | 1180 system::InputDeviceSettings::Get()->SetNaturalScroll( |
1180 CommandLine::ForCurrentProcess()->HasSwitch( | 1181 CommandLine::ForCurrentProcess()->HasSwitch( |
1181 switches::kNaturalScrollDefault)); | 1182 switches::kNaturalScrollDefault)); |
1182 | 1183 |
1183 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | 1184 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); |
1184 | 1185 |
| 1186 g_browser_process->platform_part()->SessionManager()->SetSessionState( |
| 1187 StartupUtils::IsOobeCompleted() |
| 1188 ? session_manager::SESSION_STATE_LOGIN_PRIMARY |
| 1189 : session_manager::SESSION_STATE_OOBE); |
| 1190 |
1185 LoginDisplayHost* display_host = new LoginDisplayHostImpl(screen_bounds); | 1191 LoginDisplayHost* display_host = new LoginDisplayHostImpl(screen_bounds); |
1186 | 1192 |
1187 bool show_app_launch_splash_screen = (first_screen_name == | 1193 bool show_app_launch_splash_screen = |
1188 chromeos::WizardController::kAppLaunchSplashScreenName); | 1194 (first_screen_name == WizardController::kAppLaunchSplashScreenName); |
1189 if (show_app_launch_splash_screen) { | 1195 if (show_app_launch_splash_screen) { |
1190 const std::string& auto_launch_app_id = | 1196 const std::string& auto_launch_app_id = |
1191 chromeos::KioskAppManager::Get()->GetAutoLaunchApp(); | 1197 KioskAppManager::Get()->GetAutoLaunchApp(); |
1192 display_host->StartAppLaunch(auto_launch_app_id, | 1198 display_host->StartAppLaunch(auto_launch_app_id, |
1193 false /* diagnostic_mode */); | 1199 false /* diagnostic_mode */); |
1194 return; | 1200 return; |
1195 } | 1201 } |
1196 | 1202 |
1197 // Check whether we need to execute OOBE process. | 1203 // Check whether we need to execute OOBE flow. |
1198 bool oobe_complete = chromeos::StartupUtils::IsOobeCompleted(); | 1204 bool oobe_complete = StartupUtils::IsOobeCompleted(); |
1199 policy::BrowserPolicyConnectorChromeOS* connector = | 1205 policy::BrowserPolicyConnectorChromeOS* connector = |
1200 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1206 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1201 bool enrollment_screen_wanted = | 1207 bool enrollment_screen_wanted = |
1202 chromeos::WizardController::ShouldRecoverEnrollment() || | 1208 WizardController::ShouldRecoverEnrollment() || |
1203 (chromeos::WizardController::ShouldAutoStartEnrollment() && | 1209 (WizardController::ShouldAutoStartEnrollment() && oobe_complete && |
1204 oobe_complete && | |
1205 !connector->IsEnterpriseManaged()); | 1210 !connector->IsEnterpriseManaged()); |
1206 if (enrollment_screen_wanted && first_screen_name.empty()) { | 1211 if (enrollment_screen_wanted && first_screen_name.empty()) { |
1207 // Shows networks screen instead of enrollment screen to resume the | 1212 // Shows networks screen instead of enrollment screen to resume the |
1208 // interrupted auto start enrollment flow because enrollment screen does | 1213 // interrupted auto start enrollment flow because enrollment screen does |
1209 // not handle flaky network. See http://crbug.com/332572 | 1214 // not handle flaky network. See http://crbug.com/332572 |
1210 display_host->StartWizard(chromeos::WizardController::kNetworkScreenName, | 1215 display_host->StartWizard(WizardController::kNetworkScreenName, |
1211 scoped_ptr<base::DictionaryValue>()); | 1216 scoped_ptr<base::DictionaryValue>()); |
1212 return; | 1217 return; |
1213 } | 1218 } |
1214 | 1219 |
1215 if (StartupUtils::IsEulaAccepted()) { | 1220 if (StartupUtils::IsEulaAccepted()) { |
1216 DelayNetworkCall( | 1221 DelayNetworkCall( |
1217 ServicesCustomizationDocument::GetInstance() | 1222 ServicesCustomizationDocument::GetInstance() |
1218 ->EnsureCustomizationAppliedClosure(), | 1223 ->EnsureCustomizationAppliedClosure(), |
1219 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS)); | 1224 base::TimeDelta::FromMilliseconds(kDefaultNetworkRetryDelayMS)); |
1220 } | 1225 } |
1221 | 1226 |
1222 bool show_login_screen = | 1227 bool show_login_screen = |
1223 (first_screen_name.empty() && oobe_complete) || | 1228 (first_screen_name.empty() && oobe_complete) || |
1224 first_screen_name == chromeos::WizardController::kLoginScreenName; | 1229 first_screen_name == WizardController::kLoginScreenName; |
1225 | 1230 |
1226 if (show_login_screen) { | 1231 if (show_login_screen) { |
1227 display_host->StartSignInScreen(LoginScreenContext()); | 1232 display_host->StartSignInScreen(LoginScreenContext()); |
1228 return; | 1233 return; |
1229 } | 1234 } |
1230 | 1235 |
1231 // Load startup manifest. | 1236 // Load startup manifest. |
1232 const chromeos::StartupCustomizationDocument* startup_manifest = | 1237 const StartupCustomizationDocument* startup_manifest = |
1233 chromeos::StartupCustomizationDocument::GetInstance(); | 1238 StartupCustomizationDocument::GetInstance(); |
1234 | 1239 |
1235 // Switch to initial locale if specified by customization | 1240 // Switch to initial locale if specified by customization |
1236 // and has not been set yet. We cannot call | 1241 // and has not been set yet. We cannot call |
1237 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | 1242 // LanguageSwitchMenu::SwitchLanguage here before |
1238 // EmitLoginPromptReady. | 1243 // EmitLoginPromptReady. |
1239 PrefService* prefs = g_browser_process->local_state(); | 1244 PrefService* prefs = g_browser_process->local_state(); |
1240 const std::string& current_locale = | 1245 const std::string& current_locale = |
1241 prefs->GetString(prefs::kApplicationLocale); | 1246 prefs->GetString(prefs::kApplicationLocale); |
1242 VLOG(1) << "Current locale: " << current_locale; | 1247 VLOG(1) << "Current locale: " << current_locale; |
1243 const std::string& locale = startup_manifest->initial_locale_default(); | 1248 const std::string& locale = startup_manifest->initial_locale_default(); |
1244 | 1249 |
1245 const std::string& layout = startup_manifest->keyboard_layout(); | 1250 const std::string& layout = startup_manifest->keyboard_layout(); |
1246 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; | 1251 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; |
1247 | 1252 |
1248 // Determine keyboard layout from OEM customization (if provided) or | 1253 // Determine keyboard layout from OEM customization (if provided) or |
1249 // initial locale and save it in preferences. | 1254 // initial locale and save it in preferences. |
1250 manager->SetInputMethodLoginDefaultFromVPD(locale, layout); | 1255 manager->SetInputMethodLoginDefaultFromVPD(locale, layout); |
1251 | 1256 |
1252 if (!current_locale.empty() || locale.empty()) { | 1257 if (!current_locale.empty() || locale.empty()) { |
1253 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); | 1258 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); |
1254 return; | 1259 return; |
1255 } | 1260 } |
1256 | 1261 |
1257 // Save initial locale from VPD/customization manifest as current | 1262 // Save initial locale from VPD/customization manifest as current |
1258 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 1263 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
1259 // Don't need to schedule pref save because setting initial local | 1264 // Don't need to schedule pref save because setting initial local |
1260 // will enforce preference saving. | 1265 // will enforce preference saving. |
1261 prefs->SetString(prefs::kApplicationLocale, locale); | 1266 prefs->SetString(prefs::kApplicationLocale, locale); |
1262 chromeos::StartupUtils::SetInitialLocale(locale); | 1267 StartupUtils::SetInitialLocale(locale); |
1263 | 1268 |
1264 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( | 1269 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( |
1265 new ShowLoginWizardSwitchLanguageCallbackData( | 1270 new ShowLoginWizardSwitchLanguageCallbackData( |
1266 first_screen_name, startup_manifest, display_host)); | 1271 first_screen_name, startup_manifest, display_host)); |
1267 | 1272 |
1268 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 1273 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
1269 new locale_util::SwitchLanguageCallback( | 1274 new locale_util::SwitchLanguageCallback( |
1270 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); | 1275 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); |
1271 | 1276 |
1272 // Load locale keyboards here. Hardware layout would be automatically enabled. | 1277 // Load locale keyboards here. Hardware layout would be automatically enabled. |
1273 locale_util::SwitchLanguage( | 1278 locale_util::SwitchLanguage( |
1274 locale, true, true /* login_layouts_only */, callback.Pass()); | 1279 locale, true, true /* login_layouts_only */, callback.Pass()); |
1275 } | 1280 } |
1276 | 1281 |
1277 } // namespace chromeos | 1282 } // namespace chromeos |
OLD | NEW |