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 /content | |
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 'content')
-rw-r--r-- | content/content_tests.gypi | 4 | ||||
-rw-r--r-- | content/test/content_test_suite.cc | 35 | ||||
-rw-r--r-- | content/test/test_content_client_initializer.cc | 35 | ||||
-rw-r--r-- | content/test/test_content_client_initializer.h | 37 | ||||
-rw-r--r-- | content/test/test_render_view_host_factory.cc | 40 | ||||
-rw-r--r-- | content/test/test_render_view_host_factory.h | 54 | ||||
-rw-r--r-- | content/test/test_renderer_host.cc | 63 |
7 files changed, 87 insertions, 181 deletions
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 9173dcb..0000000 --- a/content/test/test_render_view_host_factory.cc +++ /dev/null @@ -1,40 +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, - bool swapped_out, - 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, swapped_out); -} - -} // 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 c7f05e2..0000000 --- a/content/test/test_render_view_host_factory.h +++ /dev/null @@ -1,54 +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, - bool swapped_out, - 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..58d3ac9 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,68 @@ 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, + bool swapped_out, + 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, + bool swapped_out, + 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, swapped_out); +} + // static RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { return static_cast<TestRenderViewHost*>(host); |