| 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/lock/webui_screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
| 6 | 6 |
| 7 #include "ash/common/wm_shell.h" | 7 #include "ash/common/wm_shell.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/chromeos/power/power_event_observer.h" | 9 #include "ash/system/chromeos/power/power_event_observer.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 VLOG(1) << "Preloading lock screen"; | 75 VLOG(1) << "Preloading lock screen"; |
| 76 PreloadedWebView* preloaded_web_view = | 76 PreloadedWebView* preloaded_web_view = |
| 77 PreloadedWebViewFactory::GetForProfile(ProfileHelper::GetSigninProfile()); | 77 PreloadedWebViewFactory::GetForProfile(ProfileHelper::GetSigninProfile()); |
| 78 preloaded_web_view->PreloadOnIdle( | 78 preloaded_web_view->PreloadOnIdle( |
| 79 base::BindOnce(&WebUIScreenLocker::DoPreload)); | 79 base::BindOnce(&WebUIScreenLocker::DoPreload)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 bool WebUIScreenLocker::ShouldPreloadLockScreen() { | 83 bool WebUIScreenLocker::ShouldPreloadLockScreen() { |
| 84 Profile* profile = ProfileHelper::Get()->GetProfileByUser( | 84 return true; |
| 85 user_manager::UserManager::Get()->GetActiveUser()); | |
| 86 | |
| 87 // We only want to preload the lock screen if the user is likely to see the | |
| 88 // lock screen (since caching the lock screen uses memory). Without | |
| 89 // preloading, showing the lock screen can take so long we will timeout and | |
| 90 // crash the browser process (which currently takes down all of Chrome). See | |
| 91 // crbug.com/452599 for more context. | |
| 92 // | |
| 93 // prefs::kEnableAutoScreenLock controls if the lock screen is shown on | |
| 94 // suspend, so that is our primary hueristic. | |
| 95 | |
| 96 // Note that |profile| can be null in tests. | |
| 97 return base::FeatureList::IsEnabled(features::kPreloadLockScreen) && | |
| 98 profile && | |
| 99 profile->GetPrefs()->GetBoolean(prefs::kEnableAutoScreenLock); | |
| 100 } | 85 } |
| 101 | 86 |
| 102 // static | 87 // static |
| 103 std::unique_ptr<views::WebView> WebUIScreenLocker::DoPreload(Profile* profile) { | 88 std::unique_ptr<views::WebView> WebUIScreenLocker::DoPreload(Profile* profile) { |
| 104 auto web_view = base::MakeUnique<views::WebView>(profile); | 89 auto web_view = base::MakeUnique<views::WebView>(profile); |
| 105 web_view->set_owned_by_client(); | 90 web_view->set_owned_by_client(); |
| 106 web_view->LoadInitialURL(GURL(kLoginURL)); | 91 web_view->LoadInitialURL(GURL(kLoginURL)); |
| 107 InitializeWebView(web_view.get(), l10n_util::GetStringUTF16( | 92 InitializeWebView(web_view.get(), l10n_util::GetStringUTF16( |
| 108 IDS_LOCK_SCREEN_TASK_MANAGER_NAME)); | 93 IDS_LOCK_SCREEN_TASK_MANAGER_NAME)); |
| 109 return web_view; | 94 return web_view; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 442 } |
| 458 | 443 |
| 459 if (GetOobeUI()) { | 444 if (GetOobeUI()) { |
| 460 const gfx::Size& size = primary_display.size(); | 445 const gfx::Size& size = primary_display.size(); |
| 461 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), | 446 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), |
| 462 size.height()); | 447 size.height()); |
| 463 } | 448 } |
| 464 } | 449 } |
| 465 | 450 |
| 466 } // namespace chromeos | 451 } // namespace chromeos |
| OLD | NEW |