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/wm/lock_state_controller.h" | 7 #include "ash/wm/lock_state_controller.h" |
8 #include "ash/wm/lock_state_observer.h" | 8 #include "ash/wm/lock_state_observer.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) | 61 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
62 : ScreenLockerDelegate(screen_locker), | 62 : ScreenLockerDelegate(screen_locker), |
63 lock_ready_(false), | 63 lock_ready_(false), |
64 webui_ready_(false), | 64 webui_ready_(false), |
65 network_state_helper_(new login::NetworkStateHelper), | 65 network_state_helper_(new login::NetworkStateHelper), |
66 is_observing_keyboard_(false), | 66 is_observing_keyboard_(false), |
67 weak_factory_(this) { | 67 weak_factory_(this) { |
68 set_should_emit_login_prompt_visible(false); | 68 set_should_emit_login_prompt_visible(false); |
69 ash::Shell::GetInstance()->lock_state_controller()->AddObserver(this); | 69 ash::Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
70 ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); | 70 ash::Shell::GetInstance()->delegate()->AddVirtualKeyboardStateObserver(this); |
| 71 ash::Shell::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 void WebUIScreenLocker::LockScreen() { | 80 void WebUIScreenLocker::LockScreen() { |
80 gfx::Rect bounds = | 81 gfx::Rect bounds = |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 149 |
149 void WebUIScreenLocker::FocusUserPod() { | 150 void WebUIScreenLocker::FocusUserPod() { |
150 if (!webui_ready_) | 151 if (!webui_ready_) |
151 return; | 152 return; |
152 webui_login_->RequestFocus(); | 153 webui_login_->RequestFocus(); |
153 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.forceLockedUserPodFocus"); | 154 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.forceLockedUserPodFocus"); |
154 } | 155 } |
155 | 156 |
156 WebUIScreenLocker::~WebUIScreenLocker() { | 157 WebUIScreenLocker::~WebUIScreenLocker() { |
157 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 158 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 159 ash::Shell::GetScreen()->RemoveObserver(this); |
158 ash::Shell::GetInstance()-> | 160 ash::Shell::GetInstance()-> |
159 lock_state_controller()->RemoveObserver(this); | 161 lock_state_controller()->RemoveObserver(this); |
160 | 162 |
161 ash::Shell::GetInstance()->delegate()-> | 163 ash::Shell::GetInstance()->delegate()-> |
162 RemoveVirtualKeyboardStateObserver(this); | 164 RemoveVirtualKeyboardStateObserver(this); |
163 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. | 165 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. |
164 if (lock_window_) { | 166 if (lock_window_) { |
165 lock_window_->RemoveObserver(this); | 167 lock_window_->RemoveObserver(this); |
166 lock_window_->Close(); | 168 lock_window_->Close(); |
167 } | 169 } |
(...skipping 24 matching lines...) Expand all Loading... |
192 void WebUIScreenLocker::OnLockBackgroundDisplayed() { | 194 void WebUIScreenLocker::OnLockBackgroundDisplayed() { |
193 UMA_HISTOGRAM_TIMES("LockScreen.BackgroundReady", | 195 UMA_HISTOGRAM_TIMES("LockScreen.BackgroundReady", |
194 base::TimeTicks::Now() - lock_time_); | 196 base::TimeTicks::Now() - lock_time_); |
195 } | 197 } |
196 | 198 |
197 OobeUI* WebUIScreenLocker::GetOobeUI() { | 199 OobeUI* WebUIScreenLocker::GetOobeUI() { |
198 return static_cast<OobeUI*>(GetWebUI()->GetController()); | 200 return static_cast<OobeUI*>(GetWebUI()->GetController()); |
199 } | 201 } |
200 | 202 |
201 //////////////////////////////////////////////////////////////////////////////// | 203 //////////////////////////////////////////////////////////////////////////////// |
202 // WebUIScreenLocker, LoginDisplay::Delegate implementation: | 204 // WebUIScreenLocker, LoginDisplay::Delegate: |
203 | 205 |
204 void WebUIScreenLocker::CancelPasswordChangedFlow() { | 206 void WebUIScreenLocker::CancelPasswordChangedFlow() { |
205 NOTREACHED(); | 207 NOTREACHED(); |
206 } | 208 } |
207 | 209 |
208 void WebUIScreenLocker::CreateAccount() { | 210 void WebUIScreenLocker::CreateAccount() { |
209 NOTREACHED(); | 211 NOTREACHED(); |
210 } | 212 } |
211 | 213 |
212 void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) { | 214 void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 266 |
265 void WebUIScreenLocker::SetDisplayEmail(const std::string& email) { | 267 void WebUIScreenLocker::SetDisplayEmail(const std::string& email) { |
266 NOTREACHED(); | 268 NOTREACHED(); |
267 } | 269 } |
268 | 270 |
269 void WebUIScreenLocker::Signout() { | 271 void WebUIScreenLocker::Signout() { |
270 chromeos::ScreenLocker::default_screen_locker()->Signout(); | 272 chromeos::ScreenLocker::default_screen_locker()->Signout(); |
271 } | 273 } |
272 | 274 |
273 //////////////////////////////////////////////////////////////////////////////// | 275 //////////////////////////////////////////////////////////////////////////////// |
274 // LockWindow::Observer implementation: | 276 // LockWindow::Observer: |
275 | 277 |
276 void WebUIScreenLocker::OnLockWindowReady() { | 278 void WebUIScreenLocker::OnLockWindowReady() { |
277 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not"); | 279 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not"); |
278 lock_ready_ = true; | 280 lock_ready_ = true; |
279 if (webui_ready_) | 281 if (webui_ready_) |
280 ScreenLockReady(); | 282 ScreenLockReady(); |
281 } | 283 } |
282 | 284 |
283 //////////////////////////////////////////////////////////////////////////////// | 285 //////////////////////////////////////////////////////////////////////////////// |
284 // SessionLockStateObserver override. | 286 // SessionLockStateObserver: |
285 | 287 |
286 void WebUIScreenLocker::OnLockStateEvent( | 288 void WebUIScreenLocker::OnLockStateEvent( |
287 ash::LockStateObserver::EventType event) { | 289 ash::LockStateObserver::EventType event) { |
288 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) { | 290 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) { |
289 // Release capture if any. | 291 // Release capture if any. |
290 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())-> | 292 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())-> |
291 SetCapture(NULL); | 293 SetCapture(NULL); |
292 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.animateOnceFullyDisplayed"); | 294 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.animateOnceFullyDisplayed"); |
293 } | 295 } |
294 } | 296 } |
295 | 297 |
296 //////////////////////////////////////////////////////////////////////////////// | 298 //////////////////////////////////////////////////////////////////////////////// |
297 // WidgetObserver override. | 299 // WidgetObserver: |
298 | 300 |
299 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { | 301 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { |
300 lock_window_->RemoveObserver(this); | 302 lock_window_->RemoveObserver(this); |
301 lock_window_ = NULL; | 303 lock_window_ = NULL; |
302 } | 304 } |
303 | 305 |
304 //////////////////////////////////////////////////////////////////////////////// | 306 //////////////////////////////////////////////////////////////////////////////// |
305 // PowerManagerClient::Observer overrides. | 307 // PowerManagerClient::Observer: |
306 | 308 |
307 void WebUIScreenLocker::LidEventReceived(bool open, | 309 void WebUIScreenLocker::LidEventReceived(bool open, |
308 const base::TimeTicks& time) { | 310 const base::TimeTicks& time) { |
309 content::BrowserThread::PostTask( | 311 content::BrowserThread::PostTask( |
310 content::BrowserThread::UI, | 312 content::BrowserThread::UI, |
311 FROM_HERE, | 313 FROM_HERE, |
312 base::Bind(&WebUIScreenLocker::FocusUserPod, weak_factory_.GetWeakPtr())); | 314 base::Bind(&WebUIScreenLocker::FocusUserPod, weak_factory_.GetWeakPtr())); |
313 } | 315 } |
314 | 316 |
315 void WebUIScreenLocker::SuspendDone(const base::TimeDelta& sleep_duration) { | 317 void WebUIScreenLocker::SuspendDone(const base::TimeDelta& sleep_duration) { |
(...skipping 22 matching lines...) Expand all Loading... |
338 is_observing_keyboard_ = true; | 340 is_observing_keyboard_ = true; |
339 } | 341 } |
340 } else { | 342 } else { |
341 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 343 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
342 is_observing_keyboard_ = false; | 344 is_observing_keyboard_ = false; |
343 } | 345 } |
344 } | 346 } |
345 } | 347 } |
346 | 348 |
347 //////////////////////////////////////////////////////////////////////////////// | 349 //////////////////////////////////////////////////////////////////////////////// |
348 // keyboard::KeyboardControllerObserver overrides. | 350 // keyboard::KeyboardControllerObserver: |
349 | 351 |
350 void WebUIScreenLocker::OnKeyboardBoundsChanging( | 352 void WebUIScreenLocker::OnKeyboardBoundsChanging( |
351 const gfx::Rect& new_bounds) { | 353 const gfx::Rect& new_bounds) { |
352 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { | 354 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { |
353 // Keyboard has been hidden. | 355 // Keyboard has been hidden. |
354 if (GetOobeUI()) { | 356 if (GetOobeUI()) { |
355 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true); | 357 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true); |
356 if (login::LoginScrollIntoViewEnabled()) | 358 if (login::LoginScrollIntoViewEnabled()) |
357 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds); | 359 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds); |
358 } | 360 } |
359 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { | 361 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { |
360 // Keyboard has been shown. | 362 // Keyboard has been shown. |
361 if (GetOobeUI()) { | 363 if (GetOobeUI()) { |
362 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); | 364 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); |
363 if (login::LoginScrollIntoViewEnabled()) | 365 if (login::LoginScrollIntoViewEnabled()) |
364 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); | 366 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); |
365 } | 367 } |
366 } | 368 } |
367 | 369 |
368 keyboard_bounds_ = new_bounds; | 370 keyboard_bounds_ = new_bounds; |
369 } | 371 } |
370 | 372 |
| 373 //////////////////////////////////////////////////////////////////////////////// |
| 374 // gfx::DisplayObserver: |
| 375 |
| 376 void WebUIScreenLocker::OnDisplayAdded(const gfx::Display& new_display) { |
| 377 } |
| 378 |
| 379 void WebUIScreenLocker::OnDisplayRemoved(const gfx::Display& old_display) { |
| 380 } |
| 381 |
| 382 void WebUIScreenLocker::OnDisplayMetricsChanged(const gfx::Display& display, |
| 383 uint32_t changed_metrics) { |
| 384 gfx::Display primary_display = |
| 385 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| 386 if (display.id() != primary_display.id() || |
| 387 !(changed_metrics & DISPLAY_METRIC_BOUNDS)) { |
| 388 return; |
| 389 } |
| 390 |
| 391 if (GetOobeUI()) { |
| 392 const gfx::Size& size = primary_display.size(); |
| 393 GetOobeUI()->GetCoreOobeActor()->SetClientAreaSize(size.width(), |
| 394 size.height()); |
| 395 } |
| 396 } |
| 397 |
371 } // namespace chromeos | 398 } // namespace chromeos |
OLD | NEW |