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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 #include "ui/gfx/size.h" | 89 #include "ui/gfx/size.h" |
90 #include "ui/gfx/transform.h" | 90 #include "ui/gfx/transform.h" |
91 #include "ui/keyboard/keyboard_controller.h" | 91 #include "ui/keyboard/keyboard_controller.h" |
92 #include "ui/keyboard/keyboard_util.h" | 92 #include "ui/keyboard/keyboard_util.h" |
93 #include "ui/views/focus/focus_manager.h" | 93 #include "ui/views/focus/focus_manager.h" |
94 #include "ui/views/widget/widget.h" | 94 #include "ui/views/widget/widget.h" |
95 #include "ui/views/widget/widget_delegate.h" | 95 #include "ui/views/widget/widget_delegate.h" |
96 #include "ui/wm/core/window_animations.h" | 96 #include "ui/wm/core/window_animations.h" |
97 #include "url/gurl.h" | 97 #include "url/gurl.h" |
98 | 98 |
| 99 #if defined(USE_ATHENA) |
| 100 #include "athena/screen/public/screen_manager.h" |
| 101 #include "athena/util/container_priorities.h" |
| 102 #endif |
| 103 |
99 namespace { | 104 namespace { |
100 | 105 |
101 // Maximum delay for startup sound after 'loginPromptVisible' signal. | 106 // Maximum delay for startup sound after 'loginPromptVisible' signal. |
102 const int kStartupSoundMaxDelayMs = 2000; | 107 const int kStartupSoundMaxDelayMs = 2000; |
103 | 108 |
104 // URL which corresponds to the login WebUI. | 109 // URL which corresponds to the login WebUI. |
105 const char kLoginURL[] = "chrome://oobe/login"; | 110 const char kLoginURL[] = "chrome://oobe/login"; |
106 | 111 |
107 // URL which corresponds to the OOBE WebUI. | 112 // URL which corresponds to the OOBE WebUI. |
108 const char kOobeURL[] = "chrome://oobe/oobe"; | 113 const char kOobeURL[] = "chrome://oobe/oobe"; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 startup_sound_played_(false), | 287 startup_sound_played_(false), |
283 startup_sound_honors_spoken_feedback_(false), | 288 startup_sound_honors_spoken_feedback_(false), |
284 is_observing_keyboard_(false) { | 289 is_observing_keyboard_(false) { |
285 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 290 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
286 CrasAudioHandler::Get()->AddAudioObserver(this); | 291 CrasAudioHandler::Get()->AddAudioObserver(this); |
287 if (keyboard::KeyboardController::GetInstance()) { | 292 if (keyboard::KeyboardController::GetInstance()) { |
288 keyboard::KeyboardController::GetInstance()->AddObserver(this); | 293 keyboard::KeyboardController::GetInstance()->AddObserver(this); |
289 is_observing_keyboard_ = true; | 294 is_observing_keyboard_ = true; |
290 } | 295 } |
291 | 296 |
| 297 #if !defined(USE_ATHENA) |
292 ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); | 298 ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); |
293 ash::Shell::GetScreen()->AddObserver(this); | 299 ash::Shell::GetScreen()->AddObserver(this); |
| 300 #endif |
294 | 301 |
295 // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING | 302 // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING |
296 // because/ APP_TERMINATING will never be fired as long as this keeps | 303 // because/ APP_TERMINATING will never be fired as long as this keeps |
297 // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no | 304 // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no |
298 // browser instance that will block the shutdown. | 305 // browser instance that will block the shutdown. |
299 registrar_.Add(this, | 306 registrar_.Add(this, |
300 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 307 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
301 content::NotificationService::AllSources()); | 308 content::NotificationService::AllSources()); |
302 | 309 |
303 // NOTIFICATION_BROWSER_OPENED is issued after browser is created, but | 310 // NOTIFICATION_BROWSER_OPENED is issued after browser is created, but |
(...skipping 15 matching lines...) Expand all Loading... |
319 chrome::IncrementKeepAliveCount(); | 326 chrome::IncrementKeepAliveCount(); |
320 | 327 |
321 bool is_registered = StartupUtils::IsDeviceRegistered(); | 328 bool is_registered = StartupUtils::IsDeviceRegistered(); |
322 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); | 329 bool zero_delay_enabled = WizardController::IsZeroDelayEnabled(); |
323 bool disable_boot_animation = CommandLine::ForCurrentProcess()->HasSwitch( | 330 bool disable_boot_animation = CommandLine::ForCurrentProcess()->HasSwitch( |
324 switches::kDisableBootAnimation); | 331 switches::kDisableBootAnimation); |
325 | 332 |
326 waiting_for_wallpaper_load_ = !zero_delay_enabled && | 333 waiting_for_wallpaper_load_ = !zero_delay_enabled && |
327 (!is_registered || !disable_boot_animation); | 334 (!is_registered || !disable_boot_animation); |
328 | 335 |
| 336 #if defined(USE_ATHENA) |
| 337 // TODO(dpolukhin): remove #ifdef when Athena supports wallpaper manager. |
| 338 // crbug.com/408734. |
| 339 waiting_for_wallpaper_load_ = false; |
| 340 #endif |
| 341 |
329 // For slower hardware we have boot animation disabled so | 342 // For slower hardware we have boot animation disabled so |
330 // we'll be initializing WebUI hidden, waiting for user pods to load and then | 343 // we'll be initializing WebUI hidden, waiting for user pods to load and then |
331 // show WebUI at once. | 344 // show WebUI at once. |
332 waiting_for_user_pods_ = !zero_delay_enabled && !waiting_for_wallpaper_load_; | 345 waiting_for_user_pods_ = !zero_delay_enabled && !waiting_for_wallpaper_load_; |
333 | 346 |
334 initialize_webui_hidden_ = | 347 initialize_webui_hidden_ = |
335 kHiddenWebUIInitializationDefault && !zero_delay_enabled; | 348 kHiddenWebUIInitializationDefault && !zero_delay_enabled; |
336 | 349 |
337 // Check if WebUI init type is overriden. | 350 // Check if WebUI init type is overriden. |
338 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) { | 351 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshWebUIInit)) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 397 } |
385 | 398 |
386 LoginDisplayHostImpl::~LoginDisplayHostImpl() { | 399 LoginDisplayHostImpl::~LoginDisplayHostImpl() { |
387 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 400 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
388 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 401 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
389 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | 402 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { |
390 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 403 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
391 is_observing_keyboard_ = false; | 404 is_observing_keyboard_ = false; |
392 } | 405 } |
393 | 406 |
| 407 #if !defined(USE_ATHENA) |
394 ash::Shell::GetInstance()->delegate()-> | 408 ash::Shell::GetInstance()->delegate()-> |
395 RemoveVirtualKeyboardStateObserver(this); | 409 RemoveVirtualKeyboardStateObserver(this); |
396 ash::Shell::GetScreen()->RemoveObserver(this); | 410 ash::Shell::GetScreen()->RemoveObserver(this); |
| 411 #endif |
397 | 412 |
398 if (login_view_ && login_window_) | 413 if (login_view_ && login_window_) |
399 login_window_->RemoveRemovalsObserver(this); | 414 login_window_->RemoveRemovalsObserver(this); |
400 | 415 |
401 if (login::LoginScrollIntoViewEnabled()) | 416 if (login::LoginScrollIntoViewEnabled()) |
402 ResetKeyboardOverscrollOverride(); | 417 ResetKeyboardOverscrollOverride(); |
403 | 418 |
404 views::FocusManager::set_arrow_key_traversal_enabled(false); | 419 views::FocusManager::set_arrow_key_traversal_enabled(false); |
405 ResetLoginWindowAndView(); | 420 ResetLoginWindowAndView(); |
406 | 421 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 // example) are ignored. | 787 // example) are ignored. |
773 OnBrowserCreated(); | 788 OnBrowserCreated(); |
774 registrar_.Remove(this, | 789 registrar_.Remove(this, |
775 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 790 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
776 content::NotificationService::AllSources()); | 791 content::NotificationService::AllSources()); |
777 registrar_.Remove(this, | 792 registrar_.Remove(this, |
778 chrome::NOTIFICATION_BROWSER_OPENED, | 793 chrome::NOTIFICATION_BROWSER_OPENED, |
779 content::NotificationService::AllSources()); | 794 content::NotificationService::AllSources()); |
780 } else if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED && | 795 } else if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED && |
781 user_manager::UserManager::Get()->IsCurrentUserNew()) { | 796 user_manager::UserManager::Get()->IsCurrentUserNew()) { |
| 797 #if !defined(USE_ATHENA) |
782 // For new user, move desktop to locker container so that windows created | 798 // For new user, move desktop to locker container so that windows created |
783 // during the user image picker step are below it. | 799 // during the user image picker step are below it. |
784 ash::Shell::GetInstance()-> | 800 ash::Shell::GetInstance()-> |
785 desktop_background_controller()->MoveDesktopToLockedContainer(); | 801 desktop_background_controller()->MoveDesktopToLockedContainer(); |
| 802 #endif |
786 registrar_.Remove(this, | 803 registrar_.Remove(this, |
787 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 804 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
788 content::NotificationService::AllSources()); | 805 content::NotificationService::AllSources()); |
789 } | 806 } |
790 } | 807 } |
791 | 808 |
792 //////////////////////////////////////////////////////////////////////////////// | 809 //////////////////////////////////////////////////////////////////////////////// |
793 // LoginDisplayHostImpl, WebContentsObserver implementation: | 810 // LoginDisplayHostImpl, WebContentsObserver implementation: |
794 | 811 |
795 void LoginDisplayHostImpl::RenderProcessGone(base::TerminationStatus status) { | 812 void LoginDisplayHostImpl::RenderProcessGone(base::TerminationStatus status) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 focus_ring_controller_->SetVisible(true); | 1050 focus_ring_controller_->SetVisible(true); |
1034 | 1051 |
1035 keyboard_driven_oobe_key_handler_.reset(new KeyboardDrivenOobeKeyHandler); | 1052 keyboard_driven_oobe_key_handler_.reset(new KeyboardDrivenOobeKeyHandler); |
1036 } | 1053 } |
1037 | 1054 |
1038 views::Widget::InitParams params( | 1055 views::Widget::InitParams params( |
1039 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 1056 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
1040 params.bounds = background_bounds(); | 1057 params.bounds = background_bounds(); |
1041 params.show_state = ui::SHOW_STATE_FULLSCREEN; | 1058 params.show_state = ui::SHOW_STATE_FULLSCREEN; |
1042 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 1059 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 1060 #if defined(USE_ATHENA) |
| 1061 athena::ScreenManager::ContainerParams container_params( |
| 1062 "LoginScreen", athena::CP_LOGIN_SCREEN); |
| 1063 container_params.can_activate_children = true; |
| 1064 login_screen_container_.reset( |
| 1065 athena::ScreenManager::Get()->CreateContainer(container_params)); |
| 1066 params.parent = login_screen_container_.get(); |
| 1067 #else |
1043 params.parent = | 1068 params.parent = |
1044 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 1069 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
1045 ash::kShellWindowId_LockScreenContainer); | 1070 ash::kShellWindowId_LockScreenContainer); |
1046 | 1071 #endif |
1047 login_window_ = new views::Widget; | 1072 login_window_ = new views::Widget; |
1048 params.delegate = new LoginWidgetDelegate(login_window_); | 1073 params.delegate = new LoginWidgetDelegate(login_window_); |
1049 login_window_->Init(params); | 1074 login_window_->Init(params); |
1050 | 1075 |
1051 login_view_ = new WebUILoginView(); | 1076 login_view_ = new WebUILoginView(); |
1052 login_view_->Init(); | 1077 login_view_->Init(); |
1053 if (login_view_->webui_visible()) | 1078 if (login_view_->webui_visible()) |
1054 OnLoginPromptVisible(); | 1079 OnLoginPromptVisible(); |
1055 | 1080 |
1056 wm::SetWindowVisibilityAnimationDuration( | 1081 wm::SetWindowVisibilityAnimationDuration( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 // external | 1163 // external |
1139 | 1164 |
1140 // Declared in login_wizard.h so that others don't need to depend on our .h. | 1165 // Declared in login_wizard.h so that others don't need to depend on our .h. |
1141 // TODO(nkostylev): Split this into a smaller functions. | 1166 // TODO(nkostylev): Split this into a smaller functions. |
1142 void ShowLoginWizard(const std::string& first_screen_name) { | 1167 void ShowLoginWizard(const std::string& first_screen_name) { |
1143 if (browser_shutdown::IsTryingToQuit()) | 1168 if (browser_shutdown::IsTryingToQuit()) |
1144 return; | 1169 return; |
1145 | 1170 |
1146 VLOG(1) << "Showing OOBE screen: " << first_screen_name; | 1171 VLOG(1) << "Showing OOBE screen: " << first_screen_name; |
1147 | 1172 |
| 1173 #if !defined(USE_ATHENA) |
| 1174 // TODO(dpolukhin): crbug.com/407579 |
1148 chromeos::input_method::InputMethodManager* manager = | 1175 chromeos::input_method::InputMethodManager* manager = |
1149 chromeos::input_method::InputMethodManager::Get(); | 1176 chromeos::input_method::InputMethodManager::Get(); |
1150 | 1177 |
1151 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty | 1178 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty |
1152 // and US dvorak keyboard layouts. | 1179 // and US dvorak keyboard layouts. |
1153 if (g_browser_process && g_browser_process->local_state()) { | 1180 if (g_browser_process && g_browser_process->local_state()) { |
1154 manager->GetActiveIMEState()->SetInputMethodLoginDefault(); | 1181 manager->GetActiveIMEState()->SetInputMethodLoginDefault(); |
1155 | 1182 |
1156 PrefService* prefs = g_browser_process->local_state(); | 1183 PrefService* prefs = g_browser_process->local_state(); |
1157 // Apply owner preferences for tap-to-click and mouse buttons swap for | 1184 // Apply owner preferences for tap-to-click and mouse buttons swap for |
1158 // login screen. | 1185 // login screen. |
1159 system::InputDeviceSettings::Get()->SetPrimaryButtonRight( | 1186 system::InputDeviceSettings::Get()->SetPrimaryButtonRight( |
1160 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); | 1187 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); |
1161 system::InputDeviceSettings::Get()->SetTapToClick( | 1188 system::InputDeviceSettings::Get()->SetTapToClick( |
1162 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); | 1189 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); |
1163 } | 1190 } |
1164 system::InputDeviceSettings::Get()->SetNaturalScroll( | 1191 system::InputDeviceSettings::Get()->SetNaturalScroll( |
1165 CommandLine::ForCurrentProcess()->HasSwitch( | 1192 CommandLine::ForCurrentProcess()->HasSwitch( |
1166 switches::kNaturalScrollDefault)); | 1193 switches::kNaturalScrollDefault)); |
| 1194 #endif |
1167 | 1195 |
1168 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | 1196 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); |
1169 | 1197 |
1170 g_browser_process->platform_part()->SessionManager()->SetSessionState( | 1198 g_browser_process->platform_part()->SessionManager()->SetSessionState( |
1171 StartupUtils::IsOobeCompleted() | 1199 StartupUtils::IsOobeCompleted() |
1172 ? session_manager::SESSION_STATE_LOGIN_PRIMARY | 1200 ? session_manager::SESSION_STATE_LOGIN_PRIMARY |
1173 : session_manager::SESSION_STATE_OOBE); | 1201 : session_manager::SESSION_STATE_OOBE); |
1174 | 1202 |
1175 LoginDisplayHost* display_host = new LoginDisplayHostImpl(screen_bounds); | 1203 LoginDisplayHost* display_host = new LoginDisplayHostImpl(screen_bounds); |
1176 | 1204 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 // EmitLoginPromptReady. | 1255 // EmitLoginPromptReady. |
1228 PrefService* prefs = g_browser_process->local_state(); | 1256 PrefService* prefs = g_browser_process->local_state(); |
1229 const std::string& current_locale = | 1257 const std::string& current_locale = |
1230 prefs->GetString(prefs::kApplicationLocale); | 1258 prefs->GetString(prefs::kApplicationLocale); |
1231 VLOG(1) << "Current locale: " << current_locale; | 1259 VLOG(1) << "Current locale: " << current_locale; |
1232 const std::string& locale = startup_manifest->initial_locale_default(); | 1260 const std::string& locale = startup_manifest->initial_locale_default(); |
1233 | 1261 |
1234 const std::string& layout = startup_manifest->keyboard_layout(); | 1262 const std::string& layout = startup_manifest->keyboard_layout(); |
1235 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; | 1263 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; |
1236 | 1264 |
| 1265 #if !defined(USE_ATHENA) |
1237 // Determine keyboard layout from OEM customization (if provided) or | 1266 // Determine keyboard layout from OEM customization (if provided) or |
1238 // initial locale and save it in preferences. | 1267 // initial locale and save it in preferences. |
1239 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale, | 1268 manager->GetActiveIMEState()->SetInputMethodLoginDefaultFromVPD(locale, |
1240 layout); | 1269 layout); |
| 1270 #endif |
1241 | 1271 |
1242 if (!current_locale.empty() || locale.empty()) { | 1272 if (!current_locale.empty() || locale.empty()) { |
1243 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); | 1273 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); |
1244 return; | 1274 return; |
1245 } | 1275 } |
1246 | 1276 |
1247 // Save initial locale from VPD/customization manifest as current | 1277 // Save initial locale from VPD/customization manifest as current |
1248 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 1278 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
1249 // Don't need to schedule pref save because setting initial local | 1279 // Don't need to schedule pref save because setting initial local |
1250 // will enforce preference saving. | 1280 // will enforce preference saving. |
1251 prefs->SetString(prefs::kApplicationLocale, locale); | 1281 prefs->SetString(prefs::kApplicationLocale, locale); |
1252 StartupUtils::SetInitialLocale(locale); | 1282 StartupUtils::SetInitialLocale(locale); |
1253 | 1283 |
1254 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( | 1284 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( |
1255 new ShowLoginWizardSwitchLanguageCallbackData( | 1285 new ShowLoginWizardSwitchLanguageCallbackData( |
1256 first_screen_name, startup_manifest, display_host)); | 1286 first_screen_name, startup_manifest, display_host)); |
1257 | 1287 |
1258 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 1288 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
1259 new locale_util::SwitchLanguageCallback( | 1289 new locale_util::SwitchLanguageCallback( |
1260 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); | 1290 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); |
1261 | 1291 |
1262 // Load locale keyboards here. Hardware layout would be automatically enabled. | 1292 // Load locale keyboards here. Hardware layout would be automatically enabled. |
1263 locale_util::SwitchLanguage( | 1293 locale_util::SwitchLanguage( |
1264 locale, true, true /* login_layouts_only */, callback.Pass()); | 1294 locale, true, true /* login_layouts_only */, callback.Pass()); |
1265 } | 1295 } |
1266 | 1296 |
1267 } // namespace chromeos | 1297 } // namespace chromeos |
OLD | NEW |