| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 namespace chromeos { | 58 namespace chromeos { |
| 59 | 59 |
| 60 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
| 61 // WebUIScreenLocker implementation. | 61 // WebUIScreenLocker implementation. |
| 62 | 62 |
| 63 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) | 63 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
| 64 : screen_locker_(screen_locker), | 64 : WebUILoginView(WebViewSettings()), |
| 65 screen_locker_(screen_locker), |
| 65 network_state_helper_(new login::NetworkStateHelper), | 66 network_state_helper_(new login::NetworkStateHelper), |
| 66 weak_factory_(this) { | 67 weak_factory_(this) { |
| 67 set_should_emit_login_prompt_visible(false); | 68 set_should_emit_login_prompt_visible(false); |
| 68 ash::WmShell::Get()->AddLockStateObserver(this); | 69 ash::WmShell::Get()->AddLockStateObserver(this); |
| 69 ash::WmShell::Get()->AddShellObserver(this); | 70 ash::WmShell::Get()->AddShellObserver(this); |
| 70 display::Screen::GetScreen()->AddObserver(this); | 71 display::Screen::GetScreen()->AddObserver(this); |
| 71 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 72 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 72 | 73 |
| 73 if (keyboard::KeyboardController::GetInstance()) { | 74 if (keyboard::KeyboardController::GetInstance()) { |
| 74 keyboard::KeyboardController::GetInstance()->AddObserver(this); | 75 keyboard::KeyboardController::GetInstance()->AddObserver(this); |
| 75 is_observing_keyboard_ = true; | 76 is_observing_keyboard_ = true; |
| 76 } | 77 } |
| 77 } | 78 } |
| 78 | 79 |
| 79 WebUIScreenLocker::~WebUIScreenLocker() { | 80 WebUIScreenLocker::~WebUIScreenLocker() { |
| 80 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 81 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 81 display::Screen::GetScreen()->RemoveObserver(this); | 82 display::Screen::GetScreen()->RemoveObserver(this); |
| 82 ash::WmShell::Get()->RemoveLockStateObserver(this); | 83 ash::WmShell::Get()->RemoveLockStateObserver(this); |
| 83 ash::WmShell::Get()->RemoveShellObserver(this); | 84 ash::WmShell::Get()->RemoveShellObserver(this); |
| 84 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. | 85 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. |
| 85 if (lock_window_) { | 86 if (lock_window_) { |
| 86 lock_window_->RemoveObserver(this); | 87 lock_window_->RemoveObserver(this); |
| 87 lock_window_->Close(); | 88 lock_window_->Close(); |
| 88 } | 89 } |
| 89 // If LockScreen() was called, we need to clear the signin screen handler | 90 // If LockScreen() was called, we need to clear the signin screen handler |
| 90 // delegate set in ShowSigninScreen so that it no longer points to us. | 91 // delegate set in ShowSigninScreen so that it no longer points to us. |
| 91 if (login_display_.get()) | 92 if (login_display_.get() && GetOobeUI()) |
| 92 GetOobeUI()->ResetSigninScreenHandlerDelegate(); | 93 GetOobeUI()->ResetSigninScreenHandlerDelegate(); |
| 93 | 94 |
| 94 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | 95 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { |
| 95 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 96 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
| 96 is_observing_keyboard_ = false; | 97 is_observing_keyboard_ = false; |
| 97 } | 98 } |
| 98 | 99 |
| 99 ResetKeyboardOverscrollOverride(); | 100 ResetKeyboardOverscrollOverride(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void WebUIScreenLocker::LockScreen() { | 103 void WebUIScreenLocker::LockScreen() { |
| 103 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 104 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 104 | 105 |
| 105 lock_time_ = base::TimeTicks::Now(); | 106 lock_time_ = base::TimeTicks::Now(); |
| 106 lock_window_ = new LockWindow(this); | 107 lock_window_ = new LockWindow(this); |
| 107 lock_window_->AddObserver(this); | 108 lock_window_->AddObserver(this); |
| 108 | 109 |
| 109 Init(); | 110 Init(); |
| 110 content::WebContentsObserver::Observe(webui_login_->GetWebContents()); | 111 content::WebContentsObserver::Observe(web_view()->GetWebContents()); |
| 111 | 112 |
| 112 lock_window_->SetContentsView(this); | 113 lock_window_->SetContentsView(this); |
| 113 lock_window_->SetBounds(bounds); | 114 lock_window_->SetBounds(bounds); |
| 114 lock_window_->Show(); | 115 lock_window_->Show(); |
| 115 LoadURL(GURL(kLoginURL)); | 116 LoadURL(GURL(kLoginURL)); |
| 116 OnLockWindowReady(); | 117 OnLockWindowReady(); |
| 117 | 118 |
| 118 signin_screen_controller_.reset( | 119 signin_screen_controller_.reset( |
| 119 new SignInScreenController(GetOobeUI(), this)); | 120 new SignInScreenController(GetOobeUI(), this)); |
| 120 | 121 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 ScreenLockReady(); | 165 ScreenLockReady(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 gfx::NativeWindow WebUIScreenLocker::GetNativeWindow() const { | 168 gfx::NativeWindow WebUIScreenLocker::GetNativeWindow() const { |
| 168 return lock_window_->GetNativeWindow(); | 169 return lock_window_->GetNativeWindow(); |
| 169 } | 170 } |
| 170 | 171 |
| 171 void WebUIScreenLocker::FocusUserPod() { | 172 void WebUIScreenLocker::FocusUserPod() { |
| 172 if (!webui_ready_) | 173 if (!webui_ready_) |
| 173 return; | 174 return; |
| 174 webui_login_->RequestFocus(); | 175 web_view()->RequestFocus(); |
| 175 GetWebUI()->CallJavascriptFunctionUnsafe( | 176 GetWebUI()->CallJavascriptFunctionUnsafe( |
| 176 "cr.ui.Oobe.forceLockedUserPodFocus"); | 177 "cr.ui.Oobe.forceLockedUserPodFocus"); |
| 177 } | 178 } |
| 178 | 179 |
| 179 void WebUIScreenLocker::ResetAndFocusUserPod() { | 180 void WebUIScreenLocker::ResetAndFocusUserPod() { |
| 180 if (!webui_ready_) | 181 if (!webui_ready_) |
| 181 return; | 182 return; |
| 182 GetWebUI()->CallJavascriptFunctionUnsafe("cr.ui.Oobe.clearUserPodPassword"); | 183 GetWebUI()->CallJavascriptFunctionUnsafe("cr.ui.Oobe.clearUserPodPassword"); |
| 183 FocusUserPod(); | 184 FocusUserPod(); |
| 184 } | 185 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 393 } |
| 393 | 394 |
| 394 if (GetOobeUI()) { | 395 if (GetOobeUI()) { |
| 395 const gfx::Size& size = primary_display.size(); | 396 const gfx::Size& size = primary_display.size(); |
| 396 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), | 397 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), |
| 397 size.height()); | 398 size.height()); |
| 398 } | 399 } |
| 399 } | 400 } |
| 400 | 401 |
| 401 } // namespace chromeos | 402 } // namespace chromeos |
| OLD | NEW |