Index: ash/login/ui/lock_screen.cc |
diff --git a/ash/login/ui/lock_screen.cc b/ash/login/ui/lock_screen.cc |
index baaf5bfd80b602c59fc51ead9cfa6aae0027c8f9..49c27d4fbfb966d153210d8a610a980a74096298 100644 |
--- a/ash/login/ui/lock_screen.cc |
+++ b/ash/login/ui/lock_screen.cc |
@@ -12,15 +12,29 @@ |
namespace ash { |
+namespace { |
+// Reference to global lock screen instance. There can only ever be one lock |
+// screen display at the same time. |
+LockWindow* window_ = nullptr; |
xiyuan
2017/06/06 22:37:52
Just call it |window| or |g_window|. No trailing "
jdufault
2017/06/07 18:58:35
Done.
|
+} // namespace |
+ |
bool ShowLockScreen() { |
- LockWindow* window = new LockWindow(); |
- window->SetBounds(display::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
+ CHECK(!window_); |
+ window_ = new LockWindow(); |
+ window_->SetBounds( |
+ display::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
- views::View* contents = new LockContentsView(); |
- window->SetContentsView(contents); |
- window->Show(); |
+ auto* contents = new LockContentsView(); |
+ window_->SetContentsView(contents); |
+ window_->Show(); |
return true; |
} |
+void DestroyLockScreen() { |
+ CHECK(window_); |
+ window_->Close(); |
+ window_ = nullptr; |
+} |
+ |
} // namespace ash |