Chromium Code Reviews| 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" |
| 11 #include "base/feature_list.h" | |
| 11 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 17 #include "chrome/browser/chromeos/login/helper.h" | 18 #include "chrome/browser/chromeos/login/helper.h" |
| 18 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 19 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 20 #include "chrome/browser/chromeos/login/ui/shared_web_view.h" | |
| 21 #include "chrome/browser/chromeos/login/ui/shared_web_view_factory.h" | |
| 19 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 22 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 23 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 20 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 24 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 25 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 26 #include "chrome/common/chrome_features.h" | |
| 27 #include "chrome/common/pref_names.h" | |
| 22 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "chrome/grit/generated_resources.h" | |
| 23 #include "chromeos/dbus/dbus_thread_manager.h" | 30 #include "chromeos/dbus/dbus_thread_manager.h" |
| 31 #include "components/prefs/pref_service.h" | |
| 24 #include "components/user_manager/user.h" | 32 #include "components/user_manager/user.h" |
| 25 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/notification_types.h" | 35 #include "content/public/browser/notification_types.h" |
| 28 #include "content/public/browser/render_widget_host_view.h" | 36 #include "content/public/browser/render_widget_host_view.h" |
| 37 #include "content/public/browser/web_contents.h" | |
| 29 #include "content/public/browser/web_ui.h" | 38 #include "content/public/browser/web_ui.h" |
| 30 #include "ui/aura/client/capture_client.h" | 39 #include "ui/aura/client/capture_client.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 40 #include "ui/aura/window_event_dispatcher.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | |
| 32 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
| 33 #include "ui/display/display.h" | 43 #include "ui/display/display.h" |
| 34 #include "ui/display/screen.h" | 44 #include "ui/display/screen.h" |
| 35 #include "ui/keyboard/keyboard_controller.h" | 45 #include "ui/keyboard/keyboard_controller.h" |
| 36 #include "ui/keyboard/keyboard_util.h" | 46 #include "ui/keyboard/keyboard_util.h" |
| 37 #include "ui/views/controls/webview/webview.h" | 47 #include "ui/views/controls/webview/webview.h" |
| 38 | 48 |
| 39 namespace { | 49 namespace { |
| 40 | 50 |
| 41 // URL which corresponds to the login WebUI. | 51 // URL which corresponds to the login WebUI. |
| 42 const char kLoginURL[] = "chrome://oobe/lock"; | 52 const char kLoginURL[] = "chrome://oobe/lock"; |
| 43 | 53 |
| 44 // Disables virtual keyboard overscroll. Login UI will scroll user pods | 54 // Disables virtual keyboard overscroll. Login UI will scroll user pods |
| 45 // into view on JS side when virtual keyboard is shown. | 55 // into view on JS side when virtual keyboard is shown. |
| 46 void DisableKeyboardOverscroll() { | 56 void DisableKeyboardOverscroll() { |
| 47 keyboard::SetKeyboardOverscrollOverride( | 57 keyboard::SetKeyboardOverscrollOverride( |
| 48 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 58 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
| 49 } | 59 } |
| 50 | 60 |
| 51 void ResetKeyboardOverscrollOverride() { | 61 void ResetKeyboardOverscrollOverride() { |
| 52 keyboard::SetKeyboardOverscrollOverride( | 62 keyboard::SetKeyboardOverscrollOverride( |
| 53 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); | 63 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); |
| 54 } | 64 } |
| 55 | 65 |
| 66 chromeos::WebUILoginView::WebViewSettings BuildSettings() { | |
| 67 chromeos::WebUILoginView::WebViewSettings settings; | |
| 68 if (chromeos::WebUIScreenLocker::ShouldShareLockScreen()) { | |
| 69 settings.preloaded_url = GURL(kLoginURL); | |
| 70 settings.web_view_title = | |
| 71 l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_TASK_MANAGER_NAME); | |
| 72 } | |
| 73 return settings; | |
| 74 } | |
| 75 | |
| 56 } // namespace | 76 } // namespace |
| 57 | 77 |
| 58 namespace chromeos { | 78 namespace chromeos { |
| 59 | 79 |
| 80 // static | |
| 81 bool WebUIScreenLocker::ShouldShareLockScreen() { | |
| 82 Profile* profile = ProfileHelper::Get()->GetProfileByUser( | |
| 83 user_manager::UserManager::Get()->GetActiveUser()); | |
| 84 | |
| 85 // Note that |profile| can be null in tests. | |
| 86 return base::FeatureList::IsEnabled(features::kSharedLockScreen) && profile && | |
| 87 profile->GetPrefs()->GetBoolean(prefs::kEnableAutoScreenLock); | |
|
xiyuan
2016/12/09 22:59:55
Why do we need to associate with kEnableAutoScreen
jdufault
2016/12/12 20:08:27
It is the primary heuristic to try and figure out
xiyuan
2016/12/12 20:33:19
How about using the following:
https://cs.chromiu
xiyuan
2016/12/12 20:43:36
On a second thought, the problem we are trying to
jdufault
2016/12/12 21:06:27
I've added a comment.
| |
| 88 } | |
| 89 | |
| 90 // static | |
| 91 void WebUIScreenLocker::Preload() { | |
| 92 DCHECK(ShouldShareLockScreen()); | |
| 93 VLOG(1) << "Preloading lock screen"; | |
| 94 | |
| 95 SharedWebView* shared_web_view = | |
| 96 SharedWebViewFactory::GetForProfile(ProfileHelper::GetSigninProfile()); | |
| 97 | |
| 98 views::WebView* web_view; | |
| 99 if (!shared_web_view->Get(GURL(kLoginURL), &web_view)) { | |
| 100 web_view->LoadInitialURL(GURL(kLoginURL)); | |
| 101 InitializeWebView( | |
| 102 web_view, l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_TASK_MANAGER_NAME)); | |
| 103 } | |
| 104 } | |
| 105 | |
| 60 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
| 61 // WebUIScreenLocker implementation. | 107 // WebUIScreenLocker implementation. |
| 62 | 108 |
| 63 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) | 109 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
| 64 : WebUILoginView(WebViewSettings()), | 110 : WebUILoginView(BuildSettings()), |
| 65 screen_locker_(screen_locker), | 111 screen_locker_(screen_locker), |
| 66 network_state_helper_(new login::NetworkStateHelper), | 112 network_state_helper_(new login::NetworkStateHelper), |
| 67 weak_factory_(this) { | 113 weak_factory_(this) { |
| 68 set_should_emit_login_prompt_visible(false); | 114 set_should_emit_login_prompt_visible(false); |
| 69 ash::WmShell::Get()->AddLockStateObserver(this); | 115 ash::WmShell::Get()->AddLockStateObserver(this); |
| 70 ash::WmShell::Get()->AddShellObserver(this); | 116 ash::WmShell::Get()->AddShellObserver(this); |
| 71 display::Screen::GetScreen()->AddObserver(this); | 117 display::Screen::GetScreen()->AddObserver(this); |
| 72 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 118 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 73 | 119 |
| 74 if (keyboard::KeyboardController::GetInstance()) { | 120 if (keyboard::KeyboardController::GetInstance()) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 } | 439 } |
| 394 | 440 |
| 395 if (GetOobeUI()) { | 441 if (GetOobeUI()) { |
| 396 const gfx::Size& size = primary_display.size(); | 442 const gfx::Size& size = primary_display.size(); |
| 397 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), | 443 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), |
| 398 size.height()); | 444 size.height()); |
| 399 } | 445 } |
| 400 } | 446 } |
| 401 | 447 |
| 402 } // namespace chromeos | 448 } // namespace chromeos |
| OLD | NEW |