Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/screensaver/screensaver_view.h" | 5 #include "ash/screensaver/screensaver_view.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 namespace ash { | 32 namespace ash { |
| 33 | 33 |
| 34 void ShowScreensaver(const GURL& url) { | 34 void ShowScreensaver(const GURL& url) { |
| 35 internal::ScreensaverView::ShowScreensaver(url); | 35 internal::ScreensaverView::ShowScreensaver(url); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void CloseScreensaver() { | 38 void CloseScreensaver() { |
| 39 internal::ScreensaverView::CloseScreensaver(); | 39 internal::ScreensaverView::CloseScreensaver(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool IsScreensaverShown() { | |
| 43 return internal::ScreensaverView::IsScreensaverShown(); | |
| 44 } | |
| 45 | |
| 42 namespace internal { | 46 namespace internal { |
| 43 | 47 |
| 44 // static | 48 // static |
| 45 void ScreensaverView::ShowScreensaver(const GURL& url) { | 49 void ScreensaverView::ShowScreensaver(const GURL& url) { |
| 46 if (!g_instance) { | 50 if (!g_instance) { |
| 47 g_instance = new ScreensaverView(url); | 51 g_instance = new ScreensaverView(url); |
| 48 g_instance->Show(); | 52 g_instance->Show(); |
| 49 } | 53 } |
| 50 } | 54 } |
| 51 | 55 |
| 52 // static | 56 // static |
| 53 void ScreensaverView::CloseScreensaver() { | 57 void ScreensaverView::CloseScreensaver() { |
| 54 if (g_instance) { | 58 if (g_instance) { |
| 55 g_instance->Close(); | 59 g_instance->Close(); |
| 56 g_instance = NULL; | 60 g_instance = NULL; |
| 57 } | 61 } |
| 58 } | 62 } |
| 63 // static | |
| 64 bool ScreensaverView::IsScreensaverShown() { | |
| 65 if (g_instance) | |
|
Matt Perry
2013/01/31 00:37:23
nit: can simplify to "return g_instance && g_insta
rkc
2013/01/31 02:15:46
Done.
| |
| 66 return g_instance->IsScreensaverShowingURL(g_instance->url_); | |
| 67 else | |
| 68 return false; | |
| 69 } | |
| 70 | |
| 71 bool ScreensaverView::IsScreensaverShowingURL(const GURL& url) { | |
| 72 if (screensaver_webview_ && | |
| 73 screensaver_webview_->web_contents() && | |
| 74 screensaver_webview_->web_contents()->GetURL() == url) { | |
|
Matt Perry
2013/01/31 00:37:23
ditto, just return this expression
rkc
2013/01/31 02:15:46
Done.
| |
| 75 return true; | |
| 76 } else { | |
| 77 return false; | |
| 78 } | |
| 79 } | |
| 59 | 80 |
| 60 //////////////////////////////////////////////////////////////////////////////// | 81 //////////////////////////////////////////////////////////////////////////////// |
| 61 // ScreensaverView, views::WidgetDelegateView implementation. | 82 // ScreensaverView, views::WidgetDelegateView implementation. |
| 62 views::View* ScreensaverView::GetContentsView() { | 83 views::View* ScreensaverView::GetContentsView() { |
| 63 return this; | 84 return this; |
| 64 } | 85 } |
| 65 | 86 |
| 66 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
| 67 // ScreensaverView, content::WebContentsObserver implementation. | 88 // ScreensaverView, content::WebContentsObserver implementation. |
| 68 void ScreensaverView::RenderViewGone( | 89 void ScreensaverView::RenderViewGone( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 container_window_->Show(); | 167 container_window_->Show(); |
| 147 } | 168 } |
| 148 | 169 |
| 149 // static | 170 // static |
| 150 ScreensaverView* ScreensaverView::GetInstance() { | 171 ScreensaverView* ScreensaverView::GetInstance() { |
| 151 return g_instance; | 172 return g_instance; |
| 152 } | 173 } |
| 153 | 174 |
| 154 } // namespace internal | 175 } // namespace internal |
| 155 } // namespace ash | 176 } // namespace ash |
| OLD | NEW |