From d35162497672a6c2d66429e94b7341bc73d3620c Mon Sep 17 00:00:00 2001 From: "rkc@chromium.org" Date: Wed, 2 May 2012 08:54:20 +0000 Subject: Re-implement the screensaver to use WebView instead of ExtensionDialogHost. Use WebView to render the screensaver extension instead of ExtensionDialogHost. Using the RenderViewGone override to detect termination of the renderer process to restart it. Added browser tests. R=ben@chromium.org,sky@chromium.org BUG=chromium-os:28211 TEST=Tested that the screensaver comes up; tested the reload via crashing the extension renderer with SIG_ABRT; also ran browser tests. Review URL: https://chromiumcodereview.appspot.com/10191010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134878 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/controls/webview/webview.cc | 27 ++++++++++++++++++++++----- ui/views/controls/webview/webview.h | 9 ++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'ui/views/controls') diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc index eb7846b..b6825d1 100644 --- a/ui/views/controls/webview/webview.cc +++ b/ui/views/controls/webview/webview.cc @@ -17,6 +17,7 @@ #include "ui/base/accessibility/accessibility_types.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/focus/focus_manager.h" +#include "ui/views/views_delegate.h" namespace views { @@ -46,11 +47,7 @@ content::WebContents* WebView::GetWebContents() { void WebView::CreateWebContentsWithSiteInstance( content::SiteInstance* site_instance) { if (!web_contents_) { - wc_owner_.reset(content::WebContents::Create(browser_context_, - site_instance, - MSG_ROUTING_NONE, - NULL, - NULL)); + wc_owner_.reset(CreateWebContents(browser_context_, site_instance)); web_contents_ = wc_owner_.get(); web_contents_->SetDelegate(this); AttachWebContents(); @@ -228,4 +225,24 @@ void WebView::WebContentsDestroyed(content::WebContents* web_contents) { SetWebContents(NULL); } +content::WebContents* WebView::CreateWebContents( + content::BrowserContext* browser_context, + content::SiteInstance* site_instance) { + content::WebContents* contents = NULL; + if (ViewsDelegate::views_delegate) { + contents = ViewsDelegate::views_delegate->CreateWebContents( + browser_context, site_instance); + } + + if (!contents) { + return content::WebContents::Create(browser_context, + site_instance, + MSG_ROUTING_NONE, + NULL, + NULL); + } + + return contents; +} + } // namespace views diff --git a/ui/views/controls/webview/webview.h b/ui/views/controls/webview/webview.h index 5a73dc9..de6fa7c 100644 --- a/ui/views/controls/webview/webview.h +++ b/ui/views/controls/webview/webview.h @@ -102,6 +102,13 @@ class VIEWS_EXPORT WebView : public View, content::RenderViewHost* new_host); void WebContentsDestroyed(content::WebContents* web_contents); + // Create a regular or test web contents (based on whether we're running + // in a unit test or not). + content::WebContents* CreateWebContents( + content::BrowserContext* browser_context, + content::SiteInstance* site_instance); + + NativeViewHost* wcv_holder_; scoped_ptr wc_owner_; content::WebContents* web_contents_; @@ -114,4 +121,4 @@ class VIEWS_EXPORT WebView : public View, } // namespace views -#endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ \ No newline at end of file +#endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ -- cgit v1.1