OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ |
| 6 #define ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "ash/ash_export.h" |
| 10 #include "base/callback.h" |
| 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "googleurl/src/gurl.h" |
| 13 #include "ui/views/widget/widget_delegate.h" |
| 14 |
| 15 namespace content { |
| 16 class BrowserContent; |
| 17 } |
| 18 |
| 19 namespace views { |
| 20 class WebView; |
| 21 } |
| 22 |
| 23 namespace ash { |
| 24 |
| 25 namespace test { |
| 26 class ScreensaverViewTest; |
| 27 } |
| 28 |
| 29 ASH_EXPORT void ShowScreensaver(const GURL& url); |
| 30 ASH_EXPORT void CloseScreensaver(); |
| 31 |
| 32 typedef |
| 33 base::Callback<views::WebView*(content::BrowserContext*)> WebViewFactory; |
| 34 |
| 35 namespace internal { |
| 36 |
| 37 // Shows a URL as a screensaver. The screensaver window is fullscreen, |
| 38 // always on top of every other window and will reload the URL if the |
| 39 // renderer crashes for any reason. |
| 40 class ScreensaverView : public views::WidgetDelegateView, |
| 41 public content::WebContentsObserver { |
| 42 public: |
| 43 static void ShowScreensaver(const GURL& url); |
| 44 static void CloseScreensaver(); |
| 45 |
| 46 private: |
| 47 friend class test::ScreensaverViewTest; |
| 48 |
| 49 explicit ScreensaverView(const GURL& url); |
| 50 virtual ~ScreensaverView(); |
| 51 |
| 52 // views::WidgetDelegate overrides. |
| 53 virtual views::View* GetContentsView() OVERRIDE; |
| 54 |
| 55 // content::WebContentsObserver overrides. |
| 56 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 57 |
| 58 void Show(); |
| 59 void Close(); |
| 60 |
| 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(); |
| 68 |
| 69 // For testing purposes. |
| 70 static ASH_EXPORT ScreensaverView* GetInstance(); |
| 71 |
| 72 // URL to show in the screensaver. |
| 73 GURL url_; |
| 74 |
| 75 // Host for the extension that implements this dialog. |
| 76 views::WebView* screensaver_webview_; |
| 77 |
| 78 // Window that holds the screensaver webview. |
| 79 views::Widget* container_window_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(ScreensaverView); |
| 82 }; |
| 83 |
| 84 } // namespace internal |
| 85 } // namespace ash |
| 86 |
| 87 #endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ |
OLD | NEW |