Revert of Add nacl_loader_unittests to the chromium_builder_tests (https://codereview...
[chromium-blink-merge.git] / ash / screensaver / screensaver_view.h
blob1a01aa9b4214abb0a4f6f800518487ed1c54136e
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"
12 #include "url/gurl.h"
14 namespace content {
15 class BrowserContent;
18 namespace views {
19 class WebView;
22 namespace ash {
24 namespace test {
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();
32 typedef
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 {
40 public:
41 static void ShowScreensaver(const GURL& url);
42 static void CloseScreensaver();
44 static bool IsScreensaverShown();
46 private:
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;
58 void Show();
59 void Close();
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.
67 void ShowWindow();
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.
74 GURL url_;
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);
89 } // namespace ash
91 #endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_