Chromium Code Reviews| 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 "base/callback.h" | |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 #include "googleurl/src/gurl.h" | |
| 12 #include "ui/views/widget/widget_delegate.h" | |
| 13 | |
| 14 namespace content { | |
| 15 class BrowserContent; | |
| 16 } | |
| 17 | |
| 18 namespace views { | |
| 19 class WebView; | |
| 20 } | |
| 21 | |
| 22 namespace ash { | |
| 23 | |
| 24 namespace test { | |
| 25 class ScreensaverViewTest; | |
| 26 } | |
| 27 | |
| 28 void ShowScreensaver(const GURL& url); | |
| 29 void CloseScreensaver(); | |
| 30 | |
| 31 typedef | |
| 32 base::Callback<views::WebView*(content::BrowserContext*)> WebViewFactory; | |
| 33 | |
| 34 namespace internal { | |
| 35 | |
| 36 // 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 // renderer crashes for any reason. | |
| 39 class ScreensaverView : public views::WidgetDelegateView, | |
| 40 public content::WebContentsObserver { | |
| 41 public: | |
| 42 static void ShowScreensaver(const GURL& url); | |
| 43 static void CloseScreensaver(); | |
| 44 | |
| 45 private: | |
| 46 friend class test::ScreensaverViewTest; | |
| 47 | |
| 48 // views::WidgetDelegate overrides. | |
| 49 virtual views::View* GetContentsView() OVERRIDE; | |
| 50 | |
| 51 // content::WebContentsObserver overrides. | |
| 52 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
| 53 | |
| 54 ScreensaverView(const GURL& url); | |
|
Ben Goodger (Google)
2012/05/01 16:57:42
explicit
rkc
2012/05/02 00:51:03
Done.
| |
| 55 virtual ~ScreensaverView(); | |
| 56 | |
| 57 void Show(); | |
| 58 void Close(); | |
| 59 | |
| 60 // Creates and adds web contents to our view. | |
| 61 void AddChildWebContents(); | |
| 62 // Load the screensaver in the WebView's webcontent. If the webcontents | |
| 63 // don't exist, they'll be created by WebView. | |
| 64 void LoadScreensaver(); | |
| 65 // Creates and shows a frameless full screen window containing our view. | |
| 66 void ShowWindow(); | |
| 67 | |
| 68 // For testing purposes. | |
| 69 static views::WebView* CreateWebView(content::BrowserContext* context); | |
| 70 static 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 // For testing purposes. | |
| 82 static WebViewFactory webview_factory_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(ScreensaverView); | |
| 85 }; | |
| 86 | |
| 87 } // namespace internal | |
| 88 } // namespace ash | |
| 89 | |
| 90 #endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ | |
| OLD | NEW |