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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_port.h" | |
| 9 #include "ash/system/power/power_event_observer.h" | 8 #include "ash/system/power/power_event_observer.h" |
| 10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 11 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 12 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 13 #include "base/values.h" |
| 15 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 18 #include "chrome/browser/chromeos/login/helper.h" | 17 #include "chrome/browser/chromeos/login/helper.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 | 116 |
| 118 //////////////////////////////////////////////////////////////////////////////// | 117 //////////////////////////////////////////////////////////////////////////////// |
| 119 // WebUIScreenLocker implementation. | 118 // WebUIScreenLocker implementation. |
| 120 | 119 |
| 121 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) | 120 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
| 122 : WebUILoginView(BuildConfigSettings()), | 121 : WebUILoginView(BuildConfigSettings()), |
| 123 screen_locker_(screen_locker), | 122 screen_locker_(screen_locker), |
| 124 network_state_helper_(new login::NetworkStateHelper), | 123 network_state_helper_(new login::NetworkStateHelper), |
| 125 weak_factory_(this) { | 124 weak_factory_(this) { |
| 126 set_should_emit_login_prompt_visible(false); | 125 set_should_emit_login_prompt_visible(false); |
| 127 ash::ShellPort::Get()->AddLockStateObserver(this); | |
| 128 display::Screen::GetScreen()->AddObserver(this); | 126 display::Screen::GetScreen()->AddObserver(this); |
| 129 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 127 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 130 } | 128 } |
| 131 | 129 |
| 132 WebUIScreenLocker::~WebUIScreenLocker() { | 130 WebUIScreenLocker::~WebUIScreenLocker() { |
| 133 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 131 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 134 display::Screen::GetScreen()->RemoveObserver(this); | 132 display::Screen::GetScreen()->RemoveObserver(this); |
| 135 ash::ShellPort::Get()->RemoveLockStateObserver(this); | |
| 136 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. | 133 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. |
| 137 if (lock_window_) { | 134 if (lock_window_) { |
| 138 lock_window_->RemoveObserver(this); | 135 lock_window_->RemoveObserver(this); |
| 139 lock_window_->Close(); | 136 lock_window_->Close(); |
| 140 } | 137 } |
| 141 // If LockScreen() was called, we need to clear the signin screen handler | 138 // If LockScreen() was called, we need to clear the signin screen handler |
| 142 // delegate set in ShowSigninScreen so that it no longer points to us. | 139 // delegate set in ShowSigninScreen so that it no longer points to us. |
| 143 if (login_display_.get() && GetOobeUI()) | 140 if (login_display_.get() && GetOobeUI()) |
| 144 GetOobeUI()->ResetSigninScreenHandlerDelegate(); | 141 GetOobeUI()->ResetSigninScreenHandlerDelegate(); |
| 145 | 142 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 UMA_HISTOGRAM_TIMES("LockScreen.BackgroundReady", | 251 UMA_HISTOGRAM_TIMES("LockScreen.BackgroundReady", |
| 255 base::TimeTicks::Now() - lock_time_); | 252 base::TimeTicks::Now() - lock_time_); |
| 256 } | 253 } |
| 257 | 254 |
| 258 void WebUIScreenLocker::OnHeaderBarVisible() { | 255 void WebUIScreenLocker::OnHeaderBarVisible() { |
| 259 DCHECK(ash::Shell::HasInstance()); | 256 DCHECK(ash::Shell::HasInstance()); |
| 260 | 257 |
| 261 ash::Shell::Get()->power_event_observer()->OnLockAnimationsComplete(); | 258 ash::Shell::Get()->power_event_observer()->OnLockAnimationsComplete(); |
| 262 } | 259 } |
| 263 | 260 |
| 261 void WebUIScreenLocker::OnLockAnimationFinished() { | |
| 262 // Release capture if any. | |
| 263 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow()) | |
| 264 ->SetCapture(NULL); | |
|
James Cook
2017/04/19 23:13:12
nit: nullptr
xiyuan
2017/04/20 18:23:59
Done.
| |
| 265 GetWebUI()->CallJavascriptFunctionUnsafe( | |
| 266 "cr.ui.Oobe.animateOnceFullyDisplayed"); | |
| 267 } | |
| 268 | |
| 264 //////////////////////////////////////////////////////////////////////////////// | 269 //////////////////////////////////////////////////////////////////////////////// |
| 265 // WebUIScreenLocker, LoginDisplay::Delegate: | 270 // WebUIScreenLocker, LoginDisplay::Delegate: |
| 266 | 271 |
| 267 void WebUIScreenLocker::CancelPasswordChangedFlow() { | 272 void WebUIScreenLocker::CancelPasswordChangedFlow() { |
| 268 NOTREACHED(); | 273 NOTREACHED(); |
| 269 } | 274 } |
| 270 | 275 |
| 271 void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) { | 276 void WebUIScreenLocker::CompleteLogin(const UserContext& user_context) { |
| 272 NOTREACHED(); | 277 NOTREACHED(); |
| 273 } | 278 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 void WebUIScreenLocker::Signout() { | 342 void WebUIScreenLocker::Signout() { |
| 338 chromeos::ScreenLocker::default_screen_locker()->Signout(); | 343 chromeos::ScreenLocker::default_screen_locker()->Signout(); |
| 339 } | 344 } |
| 340 | 345 |
| 341 bool WebUIScreenLocker::IsUserWhitelisted(const AccountId& account_id) { | 346 bool WebUIScreenLocker::IsUserWhitelisted(const AccountId& account_id) { |
| 342 NOTREACHED(); | 347 NOTREACHED(); |
| 343 return true; | 348 return true; |
| 344 } | 349 } |
| 345 | 350 |
| 346 //////////////////////////////////////////////////////////////////////////////// | 351 //////////////////////////////////////////////////////////////////////////////// |
| 347 // SessionLockStateObserver: | |
| 348 | |
| 349 void WebUIScreenLocker::OnLockStateEvent( | |
| 350 ash::LockStateObserver::EventType event) { | |
| 351 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) { | |
| 352 // Release capture if any. | |
| 353 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())-> | |
| 354 SetCapture(NULL); | |
| 355 GetWebUI()->CallJavascriptFunctionUnsafe( | |
| 356 "cr.ui.Oobe.animateOnceFullyDisplayed"); | |
| 357 } | |
| 358 } | |
| 359 | |
| 360 //////////////////////////////////////////////////////////////////////////////// | |
| 361 // WidgetObserver: | 352 // WidgetObserver: |
| 362 | 353 |
| 363 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { | 354 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { |
| 364 lock_window_->RemoveObserver(this); | 355 lock_window_->RemoveObserver(this); |
| 365 lock_window_ = NULL; | 356 lock_window_ = NULL; |
| 366 } | 357 } |
| 367 | 358 |
| 368 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
| 369 // PowerManagerClient::Observer: | 360 // PowerManagerClient::Observer: |
| 370 | 361 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 } | 408 } |
| 418 | 409 |
| 419 if (GetOobeUI()) { | 410 if (GetOobeUI()) { |
| 420 const gfx::Size& size = primary_display.size(); | 411 const gfx::Size& size = primary_display.size(); |
| 421 GetOobeUI()->GetCoreOobeView()->SetClientAreaSize(size.width(), | 412 GetOobeUI()->GetCoreOobeView()->SetClientAreaSize(size.width(), |
| 422 size.height()); | 413 size.height()); |
| 423 } | 414 } |
| 424 } | 415 } |
| 425 | 416 |
| 426 } // namespace chromeos | 417 } // namespace chromeos |
| OLD | NEW |