summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 09:10:14 +0000
committerrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-02 09:10:14 +0000
commit4f5c4b89293b9cd686468e7e921df16aa80d891b (patch)
tree9c32a2068eefaef9b1a3831dbad9656c79143171
parent69bfd2e9ba568606ac4363e1772af826d59624d7 (diff)
downloadchromium_src-4f5c4b89293b9cd686468e7e921df16aa80d891b.zip
chromium_src-4f5c4b89293b9cd686468e7e921df16aa80d891b.tar.gz
chromium_src-4f5c4b89293b9cd686468e7e921df16aa80d891b.tar.bz2
Revert 134878 - 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/10316004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134881 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp9
-rw-r--r--ash/screensaver/DEPS3
-rw-r--r--ash/screensaver/screensaver_view.cc140
-rw-r--r--ash/screensaver/screensaver_view.h86
-rw-r--r--ash/screensaver/screensaver_view_unittest.cc93
-rw-r--r--ash/shell/shell_delegate_impl.cc4
-rw-r--r--ash/shell/shell_delegate_impl.h1
-rw-r--r--ash/shell/window_type_launcher.cc17
-rw-r--r--ash/shell/window_type_launcher.h1
-rw-r--r--ash/shell_delegate.h3
-rw-r--r--ash/test/DEPS3
-rw-r--r--ash/test/test_shell_delegate.cc5
-rw-r--r--ash/test/test_shell_delegate.h1
-rw-r--r--chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc13
-rw-r--r--chrome/browser/chromeos/ui/screensaver_extension_dialog.cc109
-rw-r--r--chrome/browser/chromeos/ui/screensaver_extension_dialog.h58
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views_unittest.cc6
-rw-r--r--chrome/browser/ui/views/ash/chrome_shell_delegate.cc4
-rw-r--r--chrome/browser/ui/views/ash/chrome_shell_delegate.h1
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc6
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.cc6
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.h4
-rw-r--r--chrome/browser/ui/views/menu_model_adapter_test.cc6
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--content/content_tests.gypi4
-rw-r--r--content/test/content_test_suite.cc35
-rw-r--r--content/test/test_content_client_initializer.cc35
-rw-r--r--content/test/test_content_client_initializer.h37
-rw-r--r--content/test/test_render_view_host_factory.cc39
-rw-r--r--content/test/test_render_view_host_factory.h53
-rw-r--r--content/test/test_renderer_host.cc61
-rw-r--r--ui/views/controls/webview/webview.cc27
-rw-r--r--ui/views/controls/webview/webview.h9
-rw-r--r--ui/views/test/DEPS3
-rw-r--r--ui/views/test/test_views_delegate.cc8
-rw-r--r--ui/views/test/test_views_delegate.h4
-rw-r--r--ui/views/test/webview_test_helper.cc34
-rw-r--r--ui/views/test/webview_test_helper.h41
-rw-r--r--ui/views/views.gyp33
-rw-r--r--ui/views/views_delegate.h11
40 files changed, 270 insertions, 745 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 0835f9b..0000000
--- a/ash/screensaver/screensaver_view.h
+++ /dev/null
@@ -1,86 +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 "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;
-}
-
-void ShowScreensaver(const GURL& url);
-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 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;
diff --git a/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc b/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc
index 68f725e..9bdfb33 100644
--- a/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc
+++ b/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h"
-#include "ash/screensaver/screensaver_view.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/lazy_instance.h"
@@ -12,7 +11,7 @@
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/chromeos/ui/screensaver_extension_dialog.h"
#include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
@@ -174,11 +173,7 @@ void KioskModeScreensaver::SetupScreensaver(
chromeos::DBusThreadManager::Get()->
GetPowerManagerClient()->RequestActiveNotification();
- // Add the extension to the extension service and display the screensaver.
- Profile* default_profile = ProfileManager::GetDefaultProfile();
- default_profile->GetExtensionService()->AddExtension(extension);
-
- ash::ShowScreensaver(extension->GetFullLaunchURL());
+ browser::ShowScreensaverDialog(extension);
}
// NotificationObserver overrides:
@@ -193,7 +188,7 @@ void KioskModeScreensaver::Observe(
if (power_manager->HasObserver(this))
power_manager->RemoveObserver(this);
- ash::CloseScreensaver();
+ browser::CloseScreensaverDialog();
ShutdownKioskModeScreensaver();
}
@@ -208,7 +203,7 @@ void KioskModeScreensaver::ActiveNotify() {
} else {
// Remove the screensaver so the user can at least use the underlying
// login screen to be able to log in.
- ash::CloseScreensaver();
+ browser::CloseScreensaverDialog();
}
}
diff --git a/chrome/browser/chromeos/ui/screensaver_extension_dialog.cc b/chrome/browser/chromeos/ui/screensaver_extension_dialog.cc
new file mode 100644
index 0000000..c8bd9e7
--- /dev/null
+++ b/chrome/browser/chromeos/ui/screensaver_extension_dialog.cc
@@ -0,0 +1,109 @@
+// 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 "chrome/browser/chromeos/ui/screensaver_extension_dialog.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/sessions/restore_tab_helper.h"
+#include "chrome/browser/ui/views/extensions/extension_dialog.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_file_util.h"
+
+using content::BrowserThread;
+
+namespace {
+
+ScreensaverExtensionDialog* g_instance = NULL;
+
+} // namespace
+
+namespace browser {
+
+void ShowScreensaverDialog(scoped_refptr<Extension> extension) {
+ ScreensaverExtensionDialog::ShowScreensaverDialog(extension);
+}
+
+void CloseScreensaverDialog() {
+ ScreensaverExtensionDialog::CloseScreensaverDialog();
+}
+
+} // namespace browser
+
+// static
+void ScreensaverExtensionDialog::ShowScreensaverDialog(
+ scoped_refptr<Extension> extension) {
+ if (!g_instance)
+ g_instance = new ScreensaverExtensionDialog(extension);
+ g_instance->Show();
+}
+
+// static
+void ScreensaverExtensionDialog::CloseScreensaverDialog() {
+ if (g_instance)
+ g_instance->Close();
+}
+
+ScreensaverExtensionDialog::ScreensaverExtensionDialog(
+ scoped_refptr<Extension> extension)
+ : screensaver_extension_(extension) {
+}
+
+void ScreensaverExtensionDialog::Show() {
+ if (!screensaver_extension_)
+ return;
+
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ Profile* default_profile = ProfileManager::GetDefaultProfile();
+ default_profile->GetExtensionService()->AddExtension(screensaver_extension_);
+ extension_dialog_ = ExtensionDialog::ShowFullscreen(
+ screensaver_extension_->GetFullLaunchURL(),
+ default_profile,
+ string16(),
+ this);
+}
+
+void ScreensaverExtensionDialog::Close() {
+ if (extension_dialog_) {
+ extension_dialog_->Close();
+ extension_dialog_ = NULL;
+ }
+}
+
+ScreensaverExtensionDialog::~ScreensaverExtensionDialog() {
+ if (extension_dialog_)
+ extension_dialog_->ObserverDestroyed();
+}
+
+void ScreensaverExtensionDialog::ExtensionDialogClosing(
+ ExtensionDialog* dialog) {
+ // Release our reference to the dialog to allow it to close.
+ extension_dialog_ = NULL;
+}
+
+void ScreensaverExtensionDialog::ExtensionTerminated(
+ ExtensionDialog* dialog) {
+ // This needs to be run 'slightly' delayed. When we get the extension
+ // terminated notification, the extension isn't fully unloaded yet. There
+ // is no good way to get around this. The correct solution will be to
+ // not need to reload the extension at all - but the current wiring in
+ // ExtensionViewsHost makes that not possible.
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(&ScreensaverExtensionDialog::ReloadAndShow,
+ base::Unretained(this)));
+ dialog->Close();
+}
+
+void ScreensaverExtensionDialog::ReloadAndShow() {
+ ProfileManager::GetDefaultProfile()->GetExtensionService()->ReloadExtension(
+ screensaver_extension_->id());
+
+ Show();
+}
diff --git a/chrome/browser/chromeos/ui/screensaver_extension_dialog.h b/chrome/browser/chromeos/ui/screensaver_extension_dialog.h
new file mode 100644
index 0000000..6da2683
--- /dev/null
+++ b/chrome/browser/chromeos/ui/screensaver_extension_dialog.h
@@ -0,0 +1,58 @@
+// 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 CHROME_BROWSER_CHROMEOS_UI_SCREENSAVER_EXTENSION_DIALOG_H_
+#define CHROME_BROWSER_CHROMEOS_UI_SCREENSAVER_EXTENSION_DIALOG_H_
+#pragma once
+
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/views/extensions/extension_dialog_observer.h"
+
+class Extension;
+class ExtensionDialog;
+
+namespace browser {
+
+void ShowScreensaverDialog(scoped_refptr<Extension> extension);
+void CloseScreensaverDialog();
+
+} // namespace browser
+
+// Shows or hides the screensaver extension in fullscreen mode on
+// top of all other windows.
+class ScreensaverExtensionDialog : public ExtensionDialogObserver {
+ public:
+ static void ShowScreensaverDialog(scoped_refptr<Extension> extension);
+ static void CloseScreensaverDialog();
+
+ // ExtensionDialog::Observer implementation.
+ virtual void ExtensionDialogClosing(ExtensionDialog* dialog) OVERRIDE;
+ virtual void ExtensionTerminated(ExtensionDialog* dialog) OVERRIDE;
+
+ protected:
+ virtual void Show();
+ virtual void Close();
+
+ private:
+ friend class ScreensaverExtensionDialogBrowserTest;
+ friend class ScreensaverExtensionDialogTest;
+
+ explicit ScreensaverExtensionDialog(scoped_refptr<Extension> extension);
+ virtual ~ScreensaverExtensionDialog();
+
+ // Reload the screensaver extension and show another screensaver dialog.
+ void ReloadAndShow();
+
+ scoped_refptr<Extension> screensaver_extension_;
+ // Host for the extension that implements this dialog.
+ scoped_refptr<ExtensionDialog> extension_dialog_;
+
+ // Set while we're loading an extension; only touched from the UI thread.
+ bool loading_extension_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreensaverExtensionDialog);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_UI_SCREENSAVER_EXTENSION_DIALOG_H_
diff --git a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
index 82ad589..981db9b 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
@@ -90,12 +90,6 @@ class AccessibilityViewsDelegate : public views::ViewsDelegate {
}
#endif
- virtual content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) OVERRIDE {
- return NULL;
- }
-
DISALLOW_COPY_AND_ASSIGN(AccessibilityViewsDelegate);
};
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
index 3e29621..368d798 100644
--- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
@@ -186,10 +186,6 @@ void ChromeShellDelegate::OpenMobileSetup() {
#endif
}
-content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() {
- return ProfileManager::GetDefaultProfile();
-}
-
ash::AppListViewDelegate*
ChromeShellDelegate::CreateAppListViewDelegate() {
// Shell will own the created delegate.
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.h b/chrome/browser/ui/views/ash/chrome_shell_delegate.h
index 9415ce4..7a71f49 100644
--- a/chrome/browser/ui/views/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.h
@@ -42,7 +42,6 @@ class ChromeShellDelegate : 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/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index cb5d34d..62465f5 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -128,12 +128,6 @@ class ViewsDelegateImpl : public views::ViewsDelegate {
}
#endif
- virtual content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) OVERRIDE {
- return NULL;
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(ViewsDelegateImpl);
};
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 5b6b3e3..51c573e 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -170,9 +170,3 @@ views::NativeWidgetHelperAura* ChromeViewsDelegate::CreateNativeWidgetHelper(
#endif
}
#endif
-
-content::WebContents* ChromeViewsDelegate::CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) {
- return NULL;
-}
diff --git a/chrome/browser/ui/views/chrome_views_delegate.h b/chrome/browser/ui/views/chrome_views_delegate.h
index 963150d..c7e4b7c 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.h
+++ b/chrome/browser/ui/views/chrome_views_delegate.h
@@ -51,10 +51,6 @@ class ChromeViewsDelegate : public views::ViewsDelegate {
views::NativeWidgetAura* native_widget) OVERRIDE;
#endif
- virtual content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) OVERRIDE;
-
private:
DISALLOW_COPY_AND_ASSIGN(ChromeViewsDelegate);
};
diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc
index 98a6683..740ec42 100644
--- a/chrome/browser/ui/views/menu_model_adapter_test.cc
+++ b/chrome/browser/ui/views/menu_model_adapter_test.cc
@@ -95,12 +95,6 @@ class TestViewsDelegate : public views::ViewsDelegate {
}
#endif
- content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) OVERRIDE {
- return NULL;
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate);
};
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 44fb363..41d7cbd 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -845,6 +845,8 @@
'browser/chromeos/ui/brightness_bubble.h',
'browser/chromeos/ui/idle_logout_dialog_view.cc',
'browser/chromeos/ui/idle_logout_dialog_view.h',
+ 'browser/chromeos/ui/screensaver_extension_dialog.cc',
+ 'browser/chromeos/ui/screensaver_extension_dialog.h',
'browser/chromeos/ui/setting_level_bubble.cc',
'browser/chromeos/ui/setting_level_bubble.h',
'browser/chromeos/ui/setting_level_bubble_view.cc',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 88c7400..df47b5e0 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -90,8 +90,6 @@
'test/test_browser_thread.h',
'test/test_content_client.cc',
'test/test_content_client.h',
- 'test/test_content_client_initializer.cc',
- 'test/test_content_client_initializer.h',
'test/test_file_error_injector.cc',
'test/test_file_error_injector.h',
'test/test_navigation_observer.cc',
@@ -100,8 +98,6 @@
'test/test_notification_tracker.h',
'test/test_renderer_host.cc',
'test/test_renderer_host.h',
- 'test/test_render_view_host_factory.cc',
- 'test/test_render_view_host_factory.h',
'test/test_url_fetcher_factory.cc',
'test/test_url_fetcher_factory.h',
'test/test_web_contents_view.cc',
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc
index a81b816b..4272a9c 100644
--- a/content/test/content_test_suite.cc
+++ b/content/test/content_test_suite.cc
@@ -5,11 +5,13 @@
#include "content/test/content_test_suite.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "content/browser/mock_content_browser_client.h"
+#include "content/browser/notification_service_impl.h"
+#include "content/public/common/content_client.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/url_constants.h"
#include "content/test/test_content_client.h"
-#include "content/test/test_content_client_initializer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_paths.h"
@@ -18,27 +20,40 @@
#endif
#include "ui/gfx/compositor/compositor_setup.h"
-
namespace {
-class TestInitializationListener : public testing::EmptyTestEventListener {
+class TestContentClientInitializer : public testing::EmptyTestEventListener {
public:
- TestInitializationListener() : test_content_client_initializer_(NULL) {
+ TestContentClientInitializer() {
}
virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
- test_content_client_initializer_ =
- new content::TestContentClientInitializer();
+ notification_service_.reset(new NotificationServiceImpl());
+
+ DCHECK(!content::GetContentClient());
+ content_client_.reset(new TestContentClient);
+ content::SetContentClient(content_client_.get());
+
+ content_browser_client_.reset(new content::MockContentBrowserClient());
+ content_client_->set_browser(content_browser_client_.get());
}
virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
- delete test_content_client_initializer_;
+ notification_service_.reset();
+
+ DCHECK_EQ(content_client_.get(), content::GetContentClient());
+ content::SetContentClient(NULL);
+ content_client_.reset();
+
+ content_browser_client_.reset();
}
private:
- content::TestContentClientInitializer* test_content_client_initializer_;
+ scoped_ptr<NotificationServiceImpl> notification_service_;
+ scoped_ptr<content::ContentClient> content_client_;
+ scoped_ptr<content::ContentBrowserClient> content_browser_client_;
- DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
+ DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer);
};
} // namespace
@@ -70,6 +85,6 @@ void ContentTestSuite::Initialize() {
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
- listeners.Append(new TestInitializationListener);
+ listeners.Append(new TestContentClientInitializer);
}
diff --git a/content/test/test_content_client_initializer.cc b/content/test/test_content_client_initializer.cc
deleted file mode 100644
index 26cd3aa..0000000
--- a/content/test/test_content_client_initializer.cc
+++ /dev/null
@@ -1,35 +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 "content/test/test_content_client_initializer.h"
-
-#include "content/browser/mock_content_browser_client.h"
-#include "content/browser/notification_service_impl.h"
-#include "content/public/common/content_client.h"
-#include "content/test/test_content_client.h"
-
-namespace content {
-
-TestContentClientInitializer::TestContentClientInitializer() {
- notification_service_.reset(new NotificationServiceImpl());
-
- DCHECK(!content::GetContentClient());
- content_client_.reset(new TestContentClient);
- content::SetContentClient(content_client_.get());
-
- content_browser_client_.reset(new content::MockContentBrowserClient());
- content_client_->set_browser(content_browser_client_.get());
-}
-
-TestContentClientInitializer::~TestContentClientInitializer() {
- notification_service_.reset();
-
- DCHECK_EQ(content_client_.get(), content::GetContentClient());
- content::SetContentClient(NULL);
- content_client_.reset();
-
- content_browser_client_.reset();
-}
-
-} // namespace content
diff --git a/content/test/test_content_client_initializer.h b/content/test/test_content_client_initializer.h
deleted file mode 100644
index fbbdd80..0000000
--- a/content/test/test_content_client_initializer.h
+++ /dev/null
@@ -1,37 +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 CONTENT_TEST_TEST_CONTENT_CLIENT_INITIALIZER_
-#define CONTENT_TEST_TEST_CONTENT_CLIENT_INITIALIZER_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-
-class NotificationServiceImpl;
-
-namespace content {
-
-class ContentClient;
-class ContentBrowserClient;
-
-// Initializes various objects needed to run unit tests that use content::
-// objects. Currently this includes setting up the notification service,
-// creating and setting the content client and the content browser client.
-class TestContentClientInitializer {
- public:
- TestContentClientInitializer();
- ~TestContentClientInitializer();
-
- private:
- scoped_ptr<NotificationServiceImpl> notification_service_;
- scoped_ptr<content::ContentClient> content_client_;
- scoped_ptr<content::ContentBrowserClient> content_browser_client_;
-
- DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer);
-};
-
-} // namespace content
-
-#endif // CONTENT_TEST_TEST_CONTENT_CLIENT_INITIALIZER_
diff --git a/content/test/test_render_view_host_factory.cc b/content/test/test_render_view_host_factory.cc
deleted file mode 100644
index 429922c..0000000
--- a/content/test/test_render_view_host_factory.cc
+++ /dev/null
@@ -1,39 +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 "content/test/test_render_view_host_factory.h"
-
-#include "content/browser/renderer_host/test_render_view_host.h"
-#include "content/browser/site_instance_impl.h"
-#include "content/public/browser/render_process_host_factory.h"
-
-namespace content {
-
-TestRenderViewHostFactory::TestRenderViewHostFactory(
- content::RenderProcessHostFactory* rph_factory)
- : render_process_host_factory_(rph_factory) {
- RenderViewHostFactory::RegisterFactory(this);
-}
-
-TestRenderViewHostFactory::~TestRenderViewHostFactory() {
- RenderViewHostFactory::UnregisterFactory();
-}
-
-void TestRenderViewHostFactory::set_render_process_host_factory(
- content::RenderProcessHostFactory* rph_factory) {
- render_process_host_factory_ = rph_factory;
-}
-
-content::RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost(
- SiteInstance* instance,
- RenderViewHostDelegate* delegate,
- int routing_id,
- SessionStorageNamespace* session_storage) {
- // See declaration of render_process_host_factory_ below.
- static_cast<SiteInstanceImpl*>(instance)->
- set_render_process_host_factory(render_process_host_factory_);
- return new TestRenderViewHost(instance, delegate, routing_id);
-}
-
-} // namespace content
diff --git a/content/test/test_render_view_host_factory.h b/content/test/test_render_view_host_factory.h
deleted file mode 100644
index 406d1c2..0000000
--- a/content/test/test_render_view_host_factory.h
+++ /dev/null
@@ -1,53 +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 CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_
-#define CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "content/browser/renderer_host/render_view_host_factory.h"
-
-namespace content {
-
-class SiteInstance;
-class RenderViewHostDelegate;
-class RenderProcessHostFactory;
-class SessionStorageNamespace;
-
-// Manages creation of the RenderViewHosts using our special subclass. This
-// automatically registers itself when it goes in scope, and unregisters itself
-// when it goes out of scope. Since you can't have more than one factory
-// registered at a time, you can only have one of these objects at a time.
-class TestRenderViewHostFactory : public RenderViewHostFactory {
- public:
- explicit TestRenderViewHostFactory(
- content::RenderProcessHostFactory* rph_factory);
- virtual ~TestRenderViewHostFactory();
-
- virtual void set_render_process_host_factory(
- content::RenderProcessHostFactory* rph_factory);
- virtual content::RenderViewHost* CreateRenderViewHost(
- content::SiteInstance* instance,
- content::RenderViewHostDelegate* delegate,
- int routing_id,
- content::SessionStorageNamespace* session_storage) OVERRIDE;
-
- private:
- // This is a bit of a hack. With the current design of the site instances /
- // browsing instances, it's difficult to pass a RenderProcessHostFactory
- // around properly.
- //
- // Instead, we set it right before we create a new RenderViewHost, which
- // happens before the RenderProcessHost is created. This way, the instance
- // has the correct factory and creates our special RenderProcessHosts.
- content::RenderProcessHostFactory* render_process_host_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory);
-};
-
-} // namespace content
-
-#endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_
diff --git a/content/test/test_renderer_host.cc b/content/test/test_renderer_host.cc
index 0921774..cd9aa34 100644
--- a/content/test/test_renderer_host.cc
+++ b/content/test/test_renderer_host.cc
@@ -12,7 +12,6 @@
#include "content/public/browser/web_contents.h"
#include "content/test/mock_render_process_host.h"
#include "content/test/test_browser_context.h"
-#include "content/test/test_render_view_host_factory.h"
#if defined(USE_AURA)
#include "ui/aura/env.h"
@@ -26,6 +25,66 @@
namespace content {
+// Manages creation of the RenderViewHosts using our special subclass. This
+// automatically registers itself when it goes in scope, and unregisters itself
+// when it goes out of scope. Since you can't have more than one factory
+// registered at a time, you can only have one of these objects at a time.
+//
+// This is an implementation detail of this file and used only via
+// RenderViewHostTestEnabler.
+class TestRenderViewHostFactory : public RenderViewHostFactory {
+ public:
+ explicit TestRenderViewHostFactory(
+ content::RenderProcessHostFactory* rph_factory);
+ virtual ~TestRenderViewHostFactory();
+
+ virtual void set_render_process_host_factory(
+ content::RenderProcessHostFactory* rph_factory);
+ virtual content::RenderViewHost* CreateRenderViewHost(
+ content::SiteInstance* instance,
+ content::RenderViewHostDelegate* delegate,
+ int routing_id,
+ content::SessionStorageNamespace* session_storage) OVERRIDE;
+
+ private:
+ // This is a bit of a hack. With the current design of the site instances /
+ // browsing instances, it's difficult to pass a RenderProcessHostFactory
+ // around properly.
+ //
+ // Instead, we set it right before we create a new RenderViewHost, which
+ // happens before the RenderProcessHost is created. This way, the instance
+ // has the correct factory and creates our special RenderProcessHosts.
+ content::RenderProcessHostFactory* render_process_host_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory);
+};
+
+TestRenderViewHostFactory::TestRenderViewHostFactory(
+ content::RenderProcessHostFactory* rph_factory)
+ : render_process_host_factory_(rph_factory) {
+ RenderViewHostFactory::RegisterFactory(this);
+}
+
+TestRenderViewHostFactory::~TestRenderViewHostFactory() {
+ RenderViewHostFactory::UnregisterFactory();
+}
+
+void TestRenderViewHostFactory::set_render_process_host_factory(
+ content::RenderProcessHostFactory* rph_factory) {
+ render_process_host_factory_ = rph_factory;
+}
+
+content::RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost(
+ SiteInstance* instance,
+ RenderViewHostDelegate* delegate,
+ int routing_id,
+ SessionStorageNamespace* session_storage) {
+ // See declaration of render_process_host_factory_ below.
+ static_cast<SiteInstanceImpl*>(instance)->
+ set_render_process_host_factory(render_process_host_factory_);
+ return new TestRenderViewHost(instance, delegate, routing_id);
+}
+
// static
RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) {
return static_cast<TestRenderViewHost*>(host);
diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc
index b6825d1..eb7846b 100644
--- a/ui/views/controls/webview/webview.cc
+++ b/ui/views/controls/webview/webview.cc
@@ -17,7 +17,6 @@
#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 {
@@ -47,7 +46,11 @@ content::WebContents* WebView::GetWebContents() {
void WebView::CreateWebContentsWithSiteInstance(
content::SiteInstance* site_instance) {
if (!web_contents_) {
- wc_owner_.reset(CreateWebContents(browser_context_, site_instance));
+ wc_owner_.reset(content::WebContents::Create(browser_context_,
+ site_instance,
+ MSG_ROUTING_NONE,
+ NULL,
+ NULL));
web_contents_ = wc_owner_.get();
web_contents_->SetDelegate(this);
AttachWebContents();
@@ -225,24 +228,4 @@ 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 de6fa7c..5a73dc9 100644
--- a/ui/views/controls/webview/webview.h
+++ b/ui/views/controls/webview/webview.h
@@ -102,13 +102,6 @@ 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<content::WebContents> wc_owner_;
content::WebContents* web_contents_;
@@ -121,4 +114,4 @@ class VIEWS_EXPORT WebView : public View,
} // namespace views
-#endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_
+#endif // UI_VIEWS_CONTROLS_WEBVIEW_WEBVIEW_H_ \ No newline at end of file
diff --git a/ui/views/test/DEPS b/ui/views/test/DEPS
deleted file mode 100644
index 659b105..0000000
--- a/ui/views/test/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+content/test",
-]
diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc
index 21ae8ae..a8fe511 100644
--- a/ui/views/test/test_views_delegate.cc
+++ b/ui/views/test/test_views_delegate.cc
@@ -5,7 +5,6 @@
#include "ui/views/test/test_views_delegate.h"
#include "base/logging.h"
-#include "content/test/web_contents_tester.h"
#include "ui/base/clipboard/clipboard.h"
namespace views {
@@ -65,11 +64,4 @@ views::NativeWidgetHelperAura* TestViewsDelegate::CreateNativeWidgetHelper(
}
#endif
-content::WebContents* TestViewsDelegate::CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) {
- return content::WebContentsTester::CreateTestWebContents(browser_context,
- site_instance);
-}
-
} // namespace views
diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h
index 54ae0be..1ea5cdf 100644
--- a/ui/views/test/test_views_delegate.h
+++ b/ui/views/test/test_views_delegate.h
@@ -64,10 +64,6 @@ class TestViewsDelegate : public ViewsDelegate {
views::NativeWidgetAura* native_widget) OVERRIDE;
#endif
- virtual content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) OVERRIDE;
-
private:
mutable scoped_ptr<ui::Clipboard> clipboard_;
bool use_transparent_windows_;
diff --git a/ui/views/test/webview_test_helper.cc b/ui/views/test/webview_test_helper.cc
deleted file mode 100644
index 6ff3925..0000000
--- a/ui/views/test/webview_test_helper.cc
+++ /dev/null
@@ -1,34 +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 "ui/views/test/webview_test_helper.h"
-
-#include "base/message_loop.h"
-#include "content/test/mock_render_process_host.h"
-#include "content/test/test_browser_thread.h"
-#include "content/test/test_content_client_initializer.h"
-#include "content/test/test_render_view_host_factory.h"
-#include "ui/views/controls/webview/webview.h"
-
-namespace views {
-
-WebViewTestHelper::WebViewTestHelper(MessageLoopForUI* ui_loop) {
- test_content_client_initializer_.reset(
- new content::TestContentClientInitializer);
-
- // Setup to register a new RenderViewHost factory which manufactures
- // mock render process hosts. This ensures that we never create a 'real'
- // render view host since support for it doesn't exist in unit tests.
- rph_factory_.reset(new content::MockRenderProcessHostFactory());
- rvh_factory_.reset(
- new content::TestRenderViewHostFactory(rph_factory_.get()));
-
- ui_thread_.reset(
- new content::TestBrowserThread(content::BrowserThread::UI, ui_loop));
-}
-
-WebViewTestHelper::~WebViewTestHelper() {
-}
-
-} // namespace views
diff --git a/ui/views/test/webview_test_helper.h b/ui/views/test/webview_test_helper.h
deleted file mode 100644
index 9868bcc..0000000
--- a/ui/views/test/webview_test_helper.h
+++ /dev/null
@@ -1,41 +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 UI_VIEWS_TEST_WEB_VIEW_TEST_HELPER_H_
-#define UI_VIEWS_TEST_WEB_VIEW_TEST_HELPER_H_
-#pragma once
-
-#include "base/memory/scoped_ptr.h"
-
-class MessageLoopForUI;
-
-namespace content {
-class TestContentClientInitializer;
-class TestBrowserThread;
-class MockRenderProcessHostFactory;
-class TestRenderViewHostFactory;
-} // namespace content
-
-namespace views {
-
-class WebViewTestHelper {
- public:
- explicit WebViewTestHelper(MessageLoopForUI* ui_loop);
- virtual ~WebViewTestHelper();
-
- private:
- scoped_ptr<content::TestContentClientInitializer>
- test_content_client_initializer_;
-
- scoped_ptr<content::TestBrowserThread> ui_thread_;
-
- scoped_ptr<content::MockRenderProcessHostFactory> rph_factory_;
- scoped_ptr<content::TestRenderViewHostFactory> rvh_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(WebViewTestHelper);
-};
-
-} // namespace views
-
-#endif // UI_VIEWS_TEST_WEB_VIEW_TEST_HELPER_H_
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index e83e467..7919b8e 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -451,32 +451,6 @@
],
}, # target_name: views
{
- 'target_name': 'test_support_views',
- 'type': 'static_library',
- 'dependencies': [
- '../../base/base.gyp:base',
- '../../content/content.gyp:test_support_content',
- '../../ipc/ipc.gyp:test_support_ipc',
- '../../net/net.gyp:net_test_support',
- '../../skia/skia.gyp:skia',
- '../../testing/gtest.gyp:gtest',
- '../ui.gyp:ui',
- 'views',
- ],
- 'include_dirs': [
- '..',
- ],
- 'sources': [
- 'test/test_tooltip_client.h',
- 'test/test_views_delegate.cc',
- 'test/test_views_delegate.h',
- 'test/views_test_base.cc',
- 'test/views_test_base.h',
- 'test/webview_test_helper.cc',
- 'test/webview_test_helper.h',
- ],
- }, # target_name: test_support_views
- {
'target_name': 'views_unittests',
'type': 'executable',
'dependencies': [
@@ -499,7 +473,6 @@
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
'../ui.gyp:ui_resources_standard',
- 'test_support_views',
'views',
],
'include_dirs': [
@@ -531,6 +504,11 @@
'focus/focus_traversal_unittest.cc',
'layout/box_layout_unittest.cc',
'layout/grid_layout_unittest.cc',
+ 'test/test_tooltip_client.h',
+ 'test/test_views_delegate.cc',
+ 'test/test_views_delegate.h',
+ 'test/views_test_base.cc',
+ 'test/views_test_base.h',
'view_model_unittest.cc',
'view_model_utils_unittest.cc',
'view_unittest.cc',
@@ -677,7 +655,6 @@
'../../chrome/chrome_resources.gyp:packed_resources',
'../../content/content.gyp:content_shell_lib',
'../../content/content.gyp:content',
- '../../content/content.gyp:test_support_content',
'../../skia/skia.gyp:skia',
'../../third_party/icu/icu.gyp:icui18n',
'../../third_party/icu/icu.gyp:icuuc',
diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h
index 11e38f5..d1fc739 100644
--- a/ui/views/views_delegate.h
+++ b/ui/views/views_delegate.h
@@ -17,12 +17,6 @@
#include "ui/base/ui_base_types.h"
#include "ui/views/views_export.h"
-namespace content {
-class WebContents;
-class BrowserContext;
-class SiteInstance;
-}
-
namespace gfx {
class Rect;
}
@@ -114,11 +108,6 @@ class VIEWS_EXPORT ViewsDelegate {
virtual NativeWidgetHelperAura* CreateNativeWidgetHelper(
NativeWidgetAura* native_widget) = 0;
#endif
-
- // Creates a web contents. This will return NULL unless overriden.
- virtual content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) = 0;
};
} // namespace views