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