| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 !login_screen_locales->GetString(0, &login_screen_locale)) | 272 !login_screen_locales->GetString(0, &login_screen_locale)) |
| 273 return std::string(); | 273 return std::string(); |
| 274 | 274 |
| 275 return login_screen_locale; | 275 return login_screen_locale; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void EnableSystemSoundsForAccessibility() { | 278 void EnableSystemSoundsForAccessibility() { |
| 279 chromeos::AccessibilityManager::Get()->EnableSystemSounds(true); | 279 chromeos::AccessibilityManager::Get()->EnableSystemSounds(true); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // A login implementation of WidgetDelegate. | |
| 283 class LoginWidgetDelegate : public views::WidgetDelegate { | |
| 284 public: | |
| 285 explicit LoginWidgetDelegate(views::Widget* widget) : widget_(widget) { | |
| 286 } | |
| 287 ~LoginWidgetDelegate() override {} | |
| 288 | |
| 289 // Overridden from WidgetDelegate: | |
| 290 void DeleteDelegate() override { delete this; } | |
| 291 views::Widget* GetWidget() override { return widget_; } | |
| 292 const views::Widget* GetWidget() const override { return widget_; } | |
| 293 bool CanActivate() const override { return true; } | |
| 294 bool ShouldAdvanceFocusToTopLevelWidget() const override { return true; } | |
| 295 | |
| 296 private: | |
| 297 views::Widget* widget_; | |
| 298 | |
| 299 DISALLOW_COPY_AND_ASSIGN(LoginWidgetDelegate); | |
| 300 }; | |
| 301 | |
| 302 // Disables virtual keyboard overscroll. Login UI will scroll user pods | 282 // Disables virtual keyboard overscroll. Login UI will scroll user pods |
| 303 // into view on JS side when virtual keyboard is shown. | 283 // into view on JS side when virtual keyboard is shown. |
| 304 void DisableKeyboardOverscroll() { | 284 void DisableKeyboardOverscroll() { |
| 305 keyboard::SetKeyboardOverscrollOverride( | 285 keyboard::SetKeyboardOverscrollOverride( |
| 306 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 286 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
| 307 } | 287 } |
| 308 | 288 |
| 309 void ResetKeyboardOverscrollOverride() { | 289 void ResetKeyboardOverscrollOverride() { |
| 310 keyboard::SetKeyboardOverscrollOverride( | 290 keyboard::SetKeyboardOverscrollOverride( |
| 311 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); | 291 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); |
| 312 } | 292 } |
| 313 | 293 |
| 314 } // namespace | 294 } // namespace |
| 315 | 295 |
| 316 namespace chromeos { | 296 namespace chromeos { |
| 317 | 297 |
| 318 // static | 298 // static |
| 319 const int LoginDisplayHostImpl::kShowLoginWebUIid = 0x1111; | 299 const int LoginDisplayHostImpl::kShowLoginWebUIid = 0x1111; |
| 320 | 300 |
| 301 // A login implementation of WidgetDelegate. |
| 302 class LoginDisplayHostImpl::LoginWidgetDelegate : public views::WidgetDelegate { |
| 303 public: |
| 304 LoginWidgetDelegate(views::Widget* widget, LoginDisplayHostImpl* host) |
| 305 : widget_(widget), login_display_host_(host) { |
| 306 DCHECK(widget_); |
| 307 DCHECK(login_display_host_); |
| 308 } |
| 309 ~LoginWidgetDelegate() override {} |
| 310 |
| 311 // Overridden from WidgetDelegate: |
| 312 void WindowClosing() override { |
| 313 // Reset the cached Widget and View pointers. The Widget may close due to: |
| 314 // * Login completion |
| 315 // * Ash crash at the login screen on mustash |
| 316 // In the latter case the mash root process will trigger a clean restart |
| 317 // of content_browser. |
| 318 if (chrome::IsRunningInMash()) |
| 319 login_display_host_->ResetLoginWindowAndView(); |
| 320 } |
| 321 void DeleteDelegate() override { delete this; } |
| 322 views::Widget* GetWidget() override { return widget_; } |
| 323 const views::Widget* GetWidget() const override { return widget_; } |
| 324 bool CanActivate() const override { return true; } |
| 325 bool ShouldAdvanceFocusToTopLevelWidget() const override { return true; } |
| 326 |
| 327 private: |
| 328 views::Widget* widget_; |
| 329 LoginDisplayHostImpl* login_display_host_; |
| 330 |
| 331 DISALLOW_COPY_AND_ASSIGN(LoginWidgetDelegate); |
| 332 }; |
| 333 |
| 321 //////////////////////////////////////////////////////////////////////////////// | 334 //////////////////////////////////////////////////////////////////////////////// |
| 322 // LoginDisplayHostImpl, public | 335 // LoginDisplayHostImpl, public |
| 323 | 336 |
| 324 LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& wallpaper_bounds) | 337 LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& wallpaper_bounds) |
| 325 : wallpaper_bounds_(wallpaper_bounds), | 338 : wallpaper_bounds_(wallpaper_bounds), |
| 326 pointer_factory_(this), | 339 pointer_factory_(this), |
| 327 animation_weak_ptr_factory_(this) { | 340 animation_weak_ptr_factory_(this) { |
| 328 if (chrome::IsRunningInMash()) { | 341 if (chrome::IsRunningInMash()) { |
| 329 // Animation, and initializing hidden, are not currently supported for Mash. | 342 // Animation, and initializing hidden, are not currently supported for Mash. |
| 330 finalize_animation_type_ = ANIMATION_NONE; | 343 finalize_animation_type_ = ANIMATION_NONE; |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 params.parent = | 1212 params.parent = |
| 1200 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 1213 ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
| 1201 ash::kShellWindowId_LockScreenContainer); | 1214 ash::kShellWindowId_LockScreenContainer); |
| 1202 } else { | 1215 } else { |
| 1203 using ui::mojom::WindowManager; | 1216 using ui::mojom::WindowManager; |
| 1204 params.mus_properties[WindowManager::kContainerId_InitProperty] = | 1217 params.mus_properties[WindowManager::kContainerId_InitProperty] = |
| 1205 mojo::ConvertTo<std::vector<uint8_t>>( | 1218 mojo::ConvertTo<std::vector<uint8_t>>( |
| 1206 ash::kShellWindowId_LockScreenContainer); | 1219 ash::kShellWindowId_LockScreenContainer); |
| 1207 } | 1220 } |
| 1208 login_window_ = new views::Widget; | 1221 login_window_ = new views::Widget; |
| 1209 params.delegate = new LoginWidgetDelegate(login_window_); | 1222 params.delegate = new LoginWidgetDelegate(login_window_, this); |
| 1210 login_window_->Init(params); | 1223 login_window_->Init(params); |
| 1211 | 1224 |
| 1212 login_view_ = new WebUILoginView(WebUILoginView::WebViewSettings()); | 1225 login_view_ = new WebUILoginView(WebUILoginView::WebViewSettings()); |
| 1213 login_view_->Init(); | 1226 login_view_->Init(); |
| 1214 if (login_view_->webui_visible()) | 1227 if (login_view_->webui_visible()) |
| 1215 OnLoginPromptVisible(); | 1228 OnLoginPromptVisible(); |
| 1216 | 1229 |
| 1217 // Animations are not available in Mash | 1230 // Animations are not available in Mash |
| 1218 if (!chrome::IsRunningInMash()) { | 1231 if (!chrome::IsRunningInMash()) { |
| 1219 login_window_->SetVisibilityAnimationDuration( | 1232 login_window_->SetVisibilityAnimationDuration( |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1356 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1344 switches::kNaturalScrollDefault)); | 1357 switches::kNaturalScrollDefault)); |
| 1345 | 1358 |
| 1346 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | 1359 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); |
| 1347 | 1360 |
| 1348 session_manager::SessionManager::Get()->SetSessionState( | 1361 session_manager::SessionManager::Get()->SetSessionState( |
| 1349 StartupUtils::IsOobeCompleted() | 1362 StartupUtils::IsOobeCompleted() |
| 1350 ? session_manager::SessionState::LOGIN_PRIMARY | 1363 ? session_manager::SessionState::LOGIN_PRIMARY |
| 1351 : session_manager::SessionState::OOBE); | 1364 : session_manager::SessionState::OOBE); |
| 1352 | 1365 |
| 1366 // Manages its own lifetime. See ShutdownDisplayHost(). |
| 1353 LoginDisplayHostImpl* display_host = new LoginDisplayHostImpl(screen_bounds); | 1367 LoginDisplayHostImpl* display_host = new LoginDisplayHostImpl(screen_bounds); |
| 1354 | 1368 |
| 1355 bool show_app_launch_splash_screen = | 1369 bool show_app_launch_splash_screen = |
| 1356 (first_screen == OobeScreen::SCREEN_APP_LAUNCH_SPLASH); | 1370 (first_screen == OobeScreen::SCREEN_APP_LAUNCH_SPLASH); |
| 1357 if (show_app_launch_splash_screen) { | 1371 if (show_app_launch_splash_screen) { |
| 1358 const std::string& auto_launch_app_id = | 1372 const std::string& auto_launch_app_id = |
| 1359 KioskAppManager::Get()->GetAutoLaunchApp(); | 1373 KioskAppManager::Get()->GetAutoLaunchApp(); |
| 1360 const bool diagnostic_mode = false; | 1374 const bool diagnostic_mode = false; |
| 1361 const bool auto_launch = true; | 1375 const bool auto_launch = true; |
| 1362 display_host->StartAppLaunch(auto_launch_app_id, | 1376 display_host->StartAppLaunch(auto_launch_app_id, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 1452 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
| 1439 // Don't need to schedule pref save because setting initial local | 1453 // Don't need to schedule pref save because setting initial local |
| 1440 // will enforce preference saving. | 1454 // will enforce preference saving. |
| 1441 prefs->SetString(prefs::kApplicationLocale, locale); | 1455 prefs->SetString(prefs::kApplicationLocale, locale); |
| 1442 StartupUtils::SetInitialLocale(locale); | 1456 StartupUtils::SetInitialLocale(locale); |
| 1443 | 1457 |
| 1444 TriggerShowLoginWizardFinish(locale, std::move(data)); | 1458 TriggerShowLoginWizardFinish(locale, std::move(data)); |
| 1445 } | 1459 } |
| 1446 | 1460 |
| 1447 } // namespace chromeos | 1461 } // namespace chromeos |
| OLD | NEW |