| 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 #ifndef ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ | 5 #ifndef ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ |
| 6 #define ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ | 6 #define ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class BrowserContent; | 15 class BrowserContent; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class WebView; | 19 class WebView; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 | 23 |
| 24 namespace test { | 24 namespace test { |
| 25 class ScreensaverViewTest; | 25 class ScreensaverViewTest; |
| 26 } | 26 } |
| 27 | 27 |
| 28 ASH_EXPORT void ShowScreensaver(const GURL& url); | 28 ASH_EXPORT void ShowScreensaver(const GURL& url); |
| 29 ASH_EXPORT void CloseScreensaver(); | 29 ASH_EXPORT void CloseScreensaver(); |
| 30 ASH_EXPORT bool IsScreensaverShown(); |
| 30 | 31 |
| 31 typedef | 32 typedef |
| 32 base::Callback<views::WebView*(content::BrowserContext*)> WebViewFactory; | 33 base::Callback<views::WebView*(content::BrowserContext*)> WebViewFactory; |
| 33 | 34 |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 // Shows a URL as a screensaver. The screensaver window is fullscreen, | 37 // Shows a URL as a screensaver. The screensaver window is fullscreen, |
| 37 // always on top of every other window and will reload the URL if the | 38 // always on top of every other window and will reload the URL if the |
| 38 // renderer crashes for any reason. | 39 // renderer crashes for any reason. |
| 39 class ScreensaverView : public views::WidgetDelegateView, | 40 class ScreensaverView : public views::WidgetDelegateView, |
| 40 public content::WebContentsObserver { | 41 public content::WebContentsObserver { |
| 41 public: | 42 public: |
| 42 static void ShowScreensaver(const GURL& url); | 43 static void ShowScreensaver(const GURL& url); |
| 43 static void CloseScreensaver(); | 44 static void CloseScreensaver(); |
| 44 | 45 |
| 46 static bool IsScreensaverShown(); |
| 47 |
| 45 private: | 48 private: |
| 46 friend class test::ScreensaverViewTest; | 49 friend class test::ScreensaverViewTest; |
| 47 | 50 |
| 48 explicit ScreensaverView(const GURL& url); | 51 explicit ScreensaverView(const GURL& url); |
| 49 virtual ~ScreensaverView(); | 52 virtual ~ScreensaverView(); |
| 50 | 53 |
| 51 // views::WidgetDelegate overrides. | 54 // views::WidgetDelegate overrides. |
| 52 virtual views::View* GetContentsView() OVERRIDE; | 55 virtual views::View* GetContentsView() OVERRIDE; |
| 53 | 56 |
| 54 // content::WebContentsObserver overrides. | 57 // content::WebContentsObserver overrides. |
| 55 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 58 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 56 | 59 |
| 57 void Show(); | 60 void Show(); |
| 58 void Close(); | 61 void Close(); |
| 59 | 62 |
| 60 // Creates and adds web contents to our view. | 63 // Creates and adds web contents to our view. |
| 61 void AddChildWebContents(); | 64 void AddChildWebContents(); |
| 62 // Load the screensaver in the WebView's webcontent. If the webcontents | 65 // Load the screensaver in the WebView's webcontent. If the webcontents |
| 63 // don't exist, they'll be created by WebView. | 66 // don't exist, they'll be created by WebView. |
| 64 void LoadScreensaver(); | 67 void LoadScreensaver(); |
| 65 // Creates and shows a frameless full screen window containing our view. | 68 // Creates and shows a frameless full screen window containing our view. |
| 66 void ShowWindow(); | 69 void ShowWindow(); |
| 67 | 70 |
| 68 // For testing purposes. | 71 // For testing purposes. |
| 69 static ASH_EXPORT ScreensaverView* GetInstance(); | 72 static ASH_EXPORT ScreensaverView* GetInstance(); |
| 73 bool IsScreensaverShowingURL(const GURL& url); |
| 70 | 74 |
| 71 // URL to show in the screensaver. | 75 // URL to show in the screensaver. |
| 72 GURL url_; | 76 GURL url_; |
| 73 | 77 |
| 74 // Number of times the screensaver has been terminated (usually this will be | 78 // Number of times the screensaver has been terminated (usually this will be |
| 75 // synonymous with the number of times it has crashed). | 79 // synonymous with the number of times it has crashed). |
| 76 int termination_count_; | 80 int termination_count_; |
| 77 | 81 |
| 78 // Host for the extension that implements this dialog. | 82 // Host for the extension that implements this dialog. |
| 79 views::WebView* screensaver_webview_; | 83 views::WebView* screensaver_webview_; |
| 80 | 84 |
| 81 // Window that holds the screensaver webview. | 85 // Window that holds the screensaver webview. |
| 82 views::Widget* container_window_; | 86 views::Widget* container_window_; |
| 83 | 87 |
| 84 DISALLOW_COPY_AND_ASSIGN(ScreensaverView); | 88 DISALLOW_COPY_AND_ASSIGN(ScreensaverView); |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 } // namespace internal | 91 } // namespace internal |
| 88 } // namespace ash | 92 } // namespace ash |
| 89 | 93 |
| 90 #endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ | 94 #endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ |
| OLD | NEW |