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..d13311deb0173968ca734781c9425b1768000020 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* g_window = nullptr; |
+} // namespace |
+ |
bool ShowLockScreen() { |
- LockWindow* window = new LockWindow(); |
- window->SetBounds(display::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
+ CHECK(!g_window); |
+ g_window = new LockWindow(); |
+ g_window->SetBounds( |
+ display::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
- views::View* contents = new LockContentsView(); |
- window->SetContentsView(contents); |
- window->Show(); |
+ auto* contents = new LockContentsView(); |
+ g_window->SetContentsView(contents); |
+ g_window->Show(); |
return true; |
} |
+void DestroyLockScreen() { |
+ CHECK(g_window); |
+ g_window->Close(); |
+ g_window = nullptr; |
+} |
+ |
} // namespace ash |