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
3 // found in the LICENSE file.
5 #ifndef ASH_SCREENSAVER_SCREENSAVER_VIEW_H_
6 #define ASH_SCREENSAVER_SCREENSAVER_VIEW_H_
8 #include "ash/content_support/ash_with_content_export.h"
9 #include "base/callback.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "ui/views/widget/widget_delegate.h"
25 class ScreensaverViewTest
;
28 ASH_WITH_CONTENT_EXPORT
void ShowScreensaver(const GURL
& url
);
29 ASH_WITH_CONTENT_EXPORT
void CloseScreensaver();
30 ASH_WITH_CONTENT_EXPORT
bool IsScreensaverShown();
33 base::Callback
<views::WebView
*(content::BrowserContext
*)> WebViewFactory
;
35 // Shows a URL as a screensaver. The screensaver window is fullscreen,
36 // always on top of every other window and will reload the URL if the
37 // renderer crashes for any reason.
38 class ScreensaverView
: public views::WidgetDelegateView
,
39 public content::WebContentsObserver
{
41 static void ShowScreensaver(const GURL
& url
);
42 static void CloseScreensaver();
44 static bool IsScreensaverShown();
47 friend class test::ScreensaverViewTest
;
49 explicit ScreensaverView(const GURL
& url
);
50 virtual ~ScreensaverView();
52 // views::WidgetDelegate overrides.
53 virtual views::View
* GetContentsView() OVERRIDE
;
55 // content::WebContentsObserver overrides.
56 virtual void RenderProcessGone(base::TerminationStatus status
) OVERRIDE
;
61 // Creates and adds web contents to our view.
62 void AddChildWebContents();
63 // Load the screensaver in the WebView's webcontent. If the webcontents
64 // don't exist, they'll be created by WebView.
65 void LoadScreensaver();
66 // Creates and shows a frameless full screen window containing our view.
69 // For testing purposes.
70 static ASH_WITH_CONTENT_EXPORT ScreensaverView
* GetInstance();
71 ASH_WITH_CONTENT_EXPORT
bool IsScreensaverShowingURL(const GURL
& url
);
73 // URL to show in the screensaver.
76 // Number of times the screensaver has been terminated (usually this will be
77 // synonymous with the number of times it has crashed).
78 int termination_count_
;
80 // Host for the extension that implements this dialog.
81 views::WebView
* screensaver_webview_
;
83 // Window that holds the screensaver webview.
84 views::Widget
* container_window_
;
86 DISALLOW_COPY_AND_ASSIGN(ScreensaverView
);
91 #endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_