diff options
author | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 22:11:44 +0000 |
---|---|---|
committer | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 22:11:44 +0000 |
commit | 166ea521da0b6fec159d864171e15f1e74785845 (patch) | |
tree | d94043a50d77e100c01298e08cef0419c3071e9b /ash | |
parent | 8dee09204160685d7409a0caf525aea59d87a0c6 (diff) | |
download | chromium_src-166ea521da0b6fec159d864171e15f1e74785845.zip chromium_src-166ea521da0b6fec159d864171e15f1e74785845.tar.gz chromium_src-166ea521da0b6fec159d864171e15f1e74785845.tar.bz2 |
Revert 135000 - 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
TBR=rkc@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10335010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 9 | ||||
-rw-r--r-- | ash/screensaver/DEPS | 3 | ||||
-rw-r--r-- | ash/screensaver/screensaver_view.cc | 140 | ||||
-rw-r--r-- | ash/screensaver/screensaver_view.h | 87 | ||||
-rw-r--r-- | ash/screensaver/screensaver_view_unittest.cc | 93 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.cc | 4 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.h | 1 | ||||
-rw-r--r-- | ash/shell/window_type_launcher.cc | 17 | ||||
-rw-r--r-- | ash/shell/window_type_launcher.h | 1 | ||||
-rw-r--r-- | ash/shell_delegate.h | 3 | ||||
-rw-r--r-- | ash/test/DEPS | 3 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.cc | 5 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.h | 1 |
13 files changed, 1 insertions, 366 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index 67090bd..47e6b8a 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -18,8 +18,6 @@ '../base/base.gyp:base_i18n', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../build/temp_gyp/googleurl.gyp:googleurl', - '../content/content.gyp:content', - '../content/content.gyp:content_browser', '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/icu/icu.gyp:icui18n', @@ -113,8 +111,6 @@ 'monitor/secondary_monitor_view.h', 'screen_ash.cc', 'screen_ash.h', - 'screensaver/screensaver_view.cc', - 'screensaver/screensaver_view.h', 'screenshot_delegate.h', 'shell.cc', 'shell.h', @@ -327,8 +323,6 @@ '../base/base.gyp:base', '../base/base.gyp:test_support_base', '../chrome/chrome_resources.gyp:packed_resources', - '../content/content.gyp:content_browser', - '../content/content.gyp:test_support_content', '../build/temp_gyp/googleurl.gyp:googleurl', '../skia/skia.gyp:skia', '../testing/gtest.gyp:gtest', @@ -343,7 +337,6 @@ '../ui/ui.gyp:ui_resources', '../ui/ui.gyp:ui_resources_standard', '../ui/views/views.gyp:views', - '../ui/views/views.gyp:test_support_views', 'ash', ], 'sources': [ @@ -363,7 +356,6 @@ 'launcher/launcher_unittest.cc', 'launcher/launcher_view_unittest.cc', 'monitor/multi_monitor_manager_unittest.cc', - 'screensaver/screensaver_view_unittest.cc', 'shell_unittest.cc', 'test/ash_test_base.cc', 'test/ash_test_base.h', @@ -465,7 +457,6 @@ '../ui/ui.gyp:ui_resources_standard', '../ui/views/views.gyp:views', '../ui/views/views.gyp:views_examples_lib', - '../ui/views/views.gyp:test_support_views', 'ash', ], 'sources': [ diff --git a/ash/screensaver/DEPS b/ash/screensaver/DEPS deleted file mode 100644 index 1c35d9c..0000000 --- a/ash/screensaver/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+content/public/browser", -] diff --git a/ash/screensaver/screensaver_view.cc b/ash/screensaver/screensaver_view.cc deleted file mode 100644 index 858ae9c..0000000 --- a/ash/screensaver/screensaver_view.cc +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/screensaver/screensaver_view.h" - -#include "ash/shell.h" -#include "ash/shell_delegate.h" -#include "base/bind.h" -#include "base/logging.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/browser_thread.h" -#include "ui/gfx/screen.h" -#include "ui/aura/root_window.h" -#include "ui/views/layout/fill_layout.h" -#include "ui/views/controls/webview/webview.h" -#include "ui/views/widget/widget.h" - -using content::BrowserThread; - -namespace { - -ash::internal::ScreensaverView* g_instance = NULL; - -} // namespace - -namespace ash { - -void ShowScreensaver(const GURL& url) { - internal::ScreensaverView::ShowScreensaver(url); -} - -void CloseScreensaver() { - internal::ScreensaverView::CloseScreensaver(); -} - -namespace internal { - -// static -void ScreensaverView::ShowScreensaver(const GURL& url) { - if (!g_instance) { - g_instance = new ScreensaverView(url); - g_instance->Show(); - } -} - -// static -void ScreensaverView::CloseScreensaver() { - if (g_instance) { - g_instance->Close(); - g_instance = NULL; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// ScreensaverView, views::WidgetDelegateView implementation. -views::View* ScreensaverView::GetContentsView() { - return this; -} - -//////////////////////////////////////////////////////////////////////////////// -// ScreensaverView, content::WebContentsObserver implementation. -void ScreensaverView::RenderViewGone( - base::TerminationStatus status) { - LOG(ERROR) << "Screensaver terminated with status " << status - << ", reloading."; - // Reload the screensaver url into the webcontents. - LoadScreensaver(); -} - -//////////////////////////////////////////////////////////////////////////////// -// ScreensaverView private methods. -ScreensaverView::ScreensaverView(const GURL& url) - : url_(url), - screensaver_webview_(NULL), - container_window_(NULL) { -} - -ScreensaverView::~ScreensaverView() { -} - -void ScreensaverView::Show() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - // Add the WebView to our view. - AddChildWebContents(); - // Show the window. - ShowWindow(); -} - -void ScreensaverView::Close() { - DCHECK(GetWidget()); - GetWidget()->Close(); -} - -void ScreensaverView::AddChildWebContents() { - content::BrowserContext* context = - Shell::GetInstance()->delegate()->GetCurrentBrowserContext(); - screensaver_webview_ = new views::WebView(context); - SetLayoutManager(new views::FillLayout); - AddChildView(screensaver_webview_); - - LoadScreensaver(); - content::WebContentsObserver::Observe( - screensaver_webview_->GetWebContents()); -} - -void ScreensaverView::LoadScreensaver() { - screensaver_webview_->GetWebContents()->GetController().LoadURL( - url_, - content::Referrer(), - content::PAGE_TRANSITION_START_PAGE, - std::string()); -} - -void ScreensaverView::ShowWindow() { - aura::RootWindow* root_window = ash::Shell::GetRootWindow(); - gfx::Rect screen_rect = - gfx::Screen::GetMonitorNearestWindow(root_window).bounds(); - - // We want to be the fullscreen topmost child of the root window. - // There should be nothing ever really that should show up on top of us. - container_window_ = new views::Widget(); - views::Widget::InitParams params( - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params.delegate = this; - params.parent = root_window; - container_window_->Init(params); - - container_window_->StackAtTop(); - container_window_->SetBounds(screen_rect); - container_window_->Show(); -} - -// static -ScreensaverView* ScreensaverView::GetInstance() { - return g_instance; -} - -} // namespace internal -} // namespace ash diff --git a/ash/screensaver/screensaver_view.h b/ash/screensaver/screensaver_view.h deleted file mode 100644 index 541a254..0000000 --- a/ash/screensaver/screensaver_view.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ -#define ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ -#pragma once - -#include "ash/ash_export.h" -#include "base/callback.h" -#include "content/public/browser/web_contents_observer.h" -#include "googleurl/src/gurl.h" -#include "ui/views/widget/widget_delegate.h" - -namespace content { -class BrowserContent; -} - -namespace views { -class WebView; -} - -namespace ash { - -namespace test { -class ScreensaverViewTest; -} - -ASH_EXPORT void ShowScreensaver(const GURL& url); -ASH_EXPORT void CloseScreensaver(); - -typedef - base::Callback<views::WebView*(content::BrowserContext*)> WebViewFactory; - -namespace internal { - -// Shows a URL as a screensaver. The screensaver window is fullscreen, -// always on top of every other window and will reload the URL if the -// renderer crashes for any reason. -class ScreensaverView : public views::WidgetDelegateView, - public content::WebContentsObserver { - public: - static void ShowScreensaver(const GURL& url); - static void CloseScreensaver(); - - private: - friend class test::ScreensaverViewTest; - - explicit ScreensaverView(const GURL& url); - virtual ~ScreensaverView(); - - // views::WidgetDelegate overrides. - virtual views::View* GetContentsView() OVERRIDE; - - // content::WebContentsObserver overrides. - virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; - - void Show(); - void Close(); - - // Creates and adds web contents to our view. - void AddChildWebContents(); - // Load the screensaver in the WebView's webcontent. If the webcontents - // don't exist, they'll be created by WebView. - void LoadScreensaver(); - // Creates and shows a frameless full screen window containing our view. - void ShowWindow(); - - // For testing purposes. - static ASH_EXPORT ScreensaverView* GetInstance(); - - // URL to show in the screensaver. - GURL url_; - - // Host for the extension that implements this dialog. - views::WebView* screensaver_webview_; - - // Window that holds the screensaver webview. - views::Widget* container_window_; - - DISALLOW_COPY_AND_ASSIGN(ScreensaverView); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_SCREENSAVER_SCREENSAVER_VIEW_H_ diff --git a/ash/screensaver/screensaver_view_unittest.cc b/ash/screensaver/screensaver_view_unittest.cc deleted file mode 100644 index 47a19e2..0000000 --- a/ash/screensaver/screensaver_view_unittest.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/screensaver/screensaver_view.h" - -#include "ash/test/ash_test_base.h" -#include "base/bind.h" -#include "content/public/browser/browser_context.h" -#include "ui/views/controls/webview/webview.h" -#include "ui/views/test/test_views_delegate.h" -#include "ui/views/test/webview_test_helper.h" - -namespace ash { -namespace test { - -class ScreensaverViewTest : public ash::test::AshTestBase { - public: - ScreensaverViewTest() { - url_ = GURL("http://www.google.com"); - views_delegate_.reset(new views::TestViewsDelegate); - webview_test_helper_.reset(new views::WebViewTestHelper(message_loop())); - } - - virtual ~ScreensaverViewTest() {} - - virtual void SetUp() OVERRIDE { - AshTestBase::SetUp(); - RunAllPendingInMessageLoop(); - } - - virtual void TearDown() OVERRIDE { - AshTestBase::TearDown(); - } - - void ExpectOpenScreensaver() { - internal::ScreensaverView* screensaver = - internal::ScreensaverView::GetInstance(); - EXPECT_TRUE(screensaver != NULL); - if (!screensaver) return; - - EXPECT_TRUE(screensaver->screensaver_webview_ != NULL); - if (!screensaver->screensaver_webview_) return; - - EXPECT_TRUE(screensaver->screensaver_webview_->web_contents() != NULL); - if (!screensaver->screensaver_webview_->web_contents()) return; - - EXPECT_EQ(screensaver->screensaver_webview_->web_contents()->GetURL(), - url_); - } - - void ExpectClosedScreensaver() { - EXPECT_TRUE(internal::ScreensaverView::GetInstance() == NULL); - } - - protected: - GURL url_; - - private: - scoped_ptr<views::TestViewsDelegate> views_delegate_; - scoped_ptr<views::WebViewTestHelper> webview_test_helper_; - - DISALLOW_COPY_AND_ASSIGN(ScreensaverViewTest); -}; - -TEST_F(ScreensaverViewTest, ShowScreensaverAndClose) { - ash::ShowScreensaver(url_); - RunAllPendingInMessageLoop(); - ExpectOpenScreensaver(); - - ash::CloseScreensaver(); - ExpectClosedScreensaver(); -} - -TEST_F(ScreensaverViewTest, OutOfOrderMultipleShowAndClose) { - ash::CloseScreensaver(); - ExpectClosedScreensaver(); - - ash::ShowScreensaver(url_); - ExpectOpenScreensaver(); - RunAllPendingInMessageLoop(); - ash::ShowScreensaver(url_); - ExpectOpenScreensaver(); - RunAllPendingInMessageLoop(); - - ash::CloseScreensaver(); - ExpectClosedScreensaver(); - ash::CloseScreensaver(); - ExpectClosedScreensaver(); -} - -} // namespace test -} // namespace ash diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 4805957..c2bfdc0 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -75,10 +75,6 @@ void ShellDelegateImpl::OpenCrosh() { void ShellDelegateImpl::OpenMobileSetup() { } -content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() { - return Shell::GetInstance()->browser_context(); -} - ash::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() { return ash::shell::CreateAppListViewDelegate(); } diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 243cfa4..b3905e0 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -33,7 +33,6 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual void OpenFileManager() OVERRIDE; virtual void OpenCrosh() OVERRIDE; virtual void OpenMobileSetup() OVERRIDE; - virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; virtual ash::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual void StartPartialScreenshot( ash::ScreenshotDelegate* screenshot_delegate) OVERRIDE; diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc index 020ec00..f3abad2 100644 --- a/ash/shell/window_type_launcher.cc +++ b/ash/shell/window_type_launcher.cc @@ -4,7 +4,6 @@ #include "ash/shell/window_type_launcher.h" -#include "ash/screensaver/screensaver_view.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" @@ -12,10 +11,7 @@ #include "ash/shell/panel_window.h" #include "ash/shell/toplevel_window.h" #include "ash/wm/shadow_types.h" -#include "base/bind.h" -#include "base/time.h" #include "base/utf_string_conversions.h" -#include "content/public/browser/browser_thread.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/gfx/canvas.h" @@ -220,10 +216,7 @@ WindowTypeLauncher::WindowTypeLauncher() this, ASCIIToUTF16("Open Views Examples Window")))), ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_( new views::NativeTextButton( - this, ASCIIToUTF16("Show/Hide a Window")))), - ALLOW_THIS_IN_INITIALIZER_LIST(show_screensaver_( - new views::NativeTextButton( - this, ASCIIToUTF16("Show the Screensaver [for 5 seconds]")))) { + this, ASCIIToUTF16("Show/Hide a Window")))) { views::GridLayout* layout = new views::GridLayout(this); layout->SetInsets(5, 5, 5, 5); SetLayoutManager(layout); @@ -246,7 +239,6 @@ WindowTypeLauncher::WindowTypeLauncher() AddViewToLayout(layout, transient_button_); AddViewToLayout(layout, examples_button_); AddViewToLayout(layout, show_hide_window_button_); - AddViewToLayout(layout, show_screensaver_); #if !defined(OS_MACOSX) set_context_menu_controller(this); #endif @@ -313,13 +305,6 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender, NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); } else if (sender == show_hide_window_button_) { NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); - } else if (sender == show_screensaver_) { - ash::ShowScreensaver(GURL("http://www.google.com")); - content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, - FROM_HERE, - base::Bind(&ash::CloseScreensaver), - base::TimeDelta::FromSeconds(5)); - } #if !defined(OS_MACOSX) else if (sender == examples_button_) { diff --git a/ash/shell/window_type_launcher.h b/ash/shell/window_type_launcher.h index 4dcc5ab..3b9807d 100644 --- a/ash/shell/window_type_launcher.h +++ b/ash/shell/window_type_launcher.h @@ -77,7 +77,6 @@ class WindowTypeLauncher : public views::WidgetDelegateView, views::NativeTextButton* transient_button_; views::NativeTextButton* examples_button_; views::NativeTextButton* show_hide_window_button_; - views::NativeTextButton* show_screensaver_; #if !defined(OS_MACOSX) scoped_ptr<views::MenuRunner> menu_runner_; #endif diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index 9cbe304..0a86aa3 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -71,9 +71,6 @@ class ASH_EXPORT ShellDelegate { // Invoked when the user needs to set up mobile networking. virtual void OpenMobileSetup() = 0; - // Get the current browser context. This will get us the current profile. - virtual content::BrowserContext* GetCurrentBrowserContext() = 0; - // Invoked to create an AppListViewDelegate. Shell takes the ownership of // the created delegate. virtual AppListViewDelegate* CreateAppListViewDelegate() = 0; diff --git a/ash/test/DEPS b/ash/test/DEPS deleted file mode 100644 index 659b105..0000000 --- a/ash/test/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+content/test", -] diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index ad6f34a..f3dbea5 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -10,7 +10,6 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/test_launcher_delegate.h" -#include "content/test/test_browser_context.h" #include "grit/ui_resources.h" #include "ui/aura/window.h" @@ -60,10 +59,6 @@ void TestShellDelegate::OpenCrosh() { void TestShellDelegate::OpenMobileSetup() { } -content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() { - return new TestBrowserContext(); -} - AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { return NULL; } diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index ce04845..1788a4a 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -29,7 +29,6 @@ class TestShellDelegate : public ShellDelegate { virtual void OpenFileManager() OVERRIDE; virtual void OpenCrosh() OVERRIDE; virtual void OpenMobileSetup() OVERRIDE; - virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE; virtual AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual void StartPartialScreenshot( ScreenshotDelegate* screenshot_delegate) OVERRIDE; |