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 return g_instance && g_instance->IsScreensaverShowingURL(g_instance->url_); |
| 66 } |
| 67 |
| 68 bool ScreensaverView::IsScreensaverShowingURL(const GURL& url) { |
| 69 return screensaver_webview_ && |
| 70 screensaver_webview_->web_contents() && |
| 71 (screensaver_webview_->web_contents()->GetURL() == url); |
| 72 } |
59 | 73 |
60 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
61 // ScreensaverView, views::WidgetDelegateView implementation. | 75 // ScreensaverView, views::WidgetDelegateView implementation. |
62 views::View* ScreensaverView::GetContentsView() { | 76 views::View* ScreensaverView::GetContentsView() { |
63 return this; | 77 return this; |
64 } | 78 } |
65 | 79 |
66 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
67 // ScreensaverView, content::WebContentsObserver implementation. | 81 // ScreensaverView, content::WebContentsObserver implementation. |
68 void ScreensaverView::RenderViewGone( | 82 void ScreensaverView::RenderViewGone( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 container_window_->Show(); | 160 container_window_->Show(); |
147 } | 161 } |
148 | 162 |
149 // static | 163 // static |
150 ScreensaverView* ScreensaverView::GetInstance() { | 164 ScreensaverView* ScreensaverView::GetInstance() { |
151 return g_instance; | 165 return g_instance; |
152 } | 166 } |
153 | 167 |
154 } // namespace internal | 168 } // namespace internal |
155 } // namespace ash | 169 } // namespace ash |
OLD | NEW |