summaryrefslogtreecommitdiffstats
path: root/webkit/support/webkit_support.cc
diff options
context:
space:
mode:
authortkent@google.com <tkent@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 08:25:08 +0000
committertkent@google.com <tkent@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-04 08:25:08 +0000
commit43b3be394cf9062a2b80e4dba5d880759d060633 (patch)
tree074b05cf00d1df1e057f8cedcc23774519cbd988 /webkit/support/webkit_support.cc
parentebaac267c41fce4a5b8ed4341ba32be40c7ac43e (diff)
downloadchromium_src-43b3be394cf9062a2b80e4dba5d880759d060633.zip
chromium_src-43b3be394cf9062a2b80e4dba5d880759d060633.tar.gz
chromium_src-43b3be394cf9062a2b80e4dba5d880759d060633.tar.bz2
Initial change for DumpRrenderTree support library
This library provides: - An implementation of WebKitClient, - An implementation of WebPlugin, - An implementation of WebMediaPalyer, - Initialization and termination functions, - Two function for database, and - Some functions required by webkit_glue. webkit_support.gyp is not referred by build/all.gyp. A gyp for DRT/chromium in WebKit tree will refer to it. BUG=none TEST=none. This is a part of test code. Review URL: http://codereview.chromium.org/652226 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support/webkit_support.cc')
-rw-r--r--webkit/support/webkit_support.cc133
1 files changed, 133 insertions, 0 deletions
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
new file mode 100644
index 0000000..0918b28
--- /dev/null
+++ b/webkit/support/webkit_support.cc
@@ -0,0 +1,133 @@
+// Copyright (c) 2010 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 "webkit/support/webkit_support.h"
+
+#include "base/at_exit.h"
+#include "base/i18n/icu_util.h"
+#include "base/message_loop.h"
+#include "base/process_util.h"
+#include "base/weak_ptr.h"
+#include "webkit/appcache/web_application_cache_host_impl.h"
+#include "webkit/glue/media/buffered_data_source.h"
+#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+#include "webkit/glue/media/simple_data_source.h"
+#include "webkit/glue/media/video_renderer_impl.h"
+#include "webkit/glue/webkitclient_impl.h"
+#include "webkit/glue/webmediaplayer_impl.h"
+#include "webkit/glue/webplugin_impl.h"
+#include "webkit/glue/webplugin_page_delegate.h"
+#include "webkit/support/test_webplugin_page_delegate.h"
+#include "webkit/support/test_webkit_client.h"
+#include "webkit/tools/test_shell/simple_database_system.h"
+#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
+
+using WebKit::WebPlugin;
+using WebKit::WebFrame;
+using WebKit::WebPluginParams;
+using WebKit::WebMediaPlayerClient;
+
+namespace {
+
+class TestEnvironment {
+ public:
+ explicit TestEnvironment() {}
+
+ ~TestEnvironment() {
+ SimpleResourceLoaderBridge::Shutdown();
+ }
+
+ WebKit::WebKitClient* webkit_client() { return &webkit_client_; }
+
+ private:
+ base::AtExitManager at_exit_manager_;
+ TestWebKitClient webkit_client_;
+ MessageLoopForUI main_message_loop_;
+};
+
+class WebPluginImplWithPageDelegate
+ : public webkit_support::TestWebPluginPageDelegate,
+ public base::SupportsWeakPtr<WebPluginImplWithPageDelegate>,
+ public webkit_glue::WebPluginImpl {
+ public:
+ WebPluginImplWithPageDelegate(WebFrame* frame,
+ const WebPluginParams& params)
+ : webkit_support::TestWebPluginPageDelegate(),
+ webkit_glue::WebPluginImpl(frame, params, AsWeakPtr()) {}
+ virtual ~WebPluginImplWithPageDelegate() {}
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebPluginImplWithPageDelegate);
+};
+
+} // namespace
+
+namespace webkit_support {
+
+static TestEnvironment* test_environment;
+
+void SetUpTestEnvironment() {
+ base::EnableTerminationOnHeapCorruption();
+ // Load ICU data tables
+ icu_util::Initialize();
+ test_environment = new TestEnvironment;
+}
+
+void TearDownTestEnvironment() {
+ delete test_environment;
+ test_environment = NULL;
+}
+
+WebKit::WebKitClient* GetWebKitClient() {
+ DCHECK(test_environment);
+ return test_environment->webkit_client();
+}
+
+WebPlugin* CreateWebPlugin(WebFrame* frame,
+ const WebPluginParams& params) {
+ return new WebPluginImplWithPageDelegate(frame, params);
+}
+
+WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame,
+ WebMediaPlayerClient* client) {
+ scoped_refptr<media::FilterFactoryCollection> factory =
+ new media::FilterFactoryCollection();
+
+ appcache::WebApplicationCacheHostImpl* appcache_host =
+ appcache::WebApplicationCacheHostImpl::FromFrame(frame);
+
+ // TODO(hclam): this is the same piece of code as in RenderView, maybe they
+ // should be grouped together.
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory =
+ new webkit_glue::MediaResourceLoaderBridgeFactory(
+ GURL(), // referrer
+ "null", // frame origin
+ "null", // main_frame_origin
+ base::GetCurrentProcId(),
+ appcache_host ? appcache_host->host_id() : appcache::kNoHostId,
+ 0);
+ // A simple data source that keeps all data in memory.
+ media::FilterFactory* simple_data_source_factory =
+ webkit_glue::SimpleDataSource::CreateFactory(MessageLoop::current(),
+ bridge_factory);
+ // A sophisticated data source that does memory caching.
+ media::FilterFactory* buffered_data_source_factory =
+ webkit_glue::BufferedDataSource::CreateFactory(MessageLoop::current(),
+ bridge_factory);
+ factory->AddFactory(buffered_data_source_factory);
+ factory->AddFactory(simple_data_source_factory);
+ return new webkit_glue::WebMediaPlayerImpl(
+ client, factory, new webkit_glue::VideoRendererImpl::FactoryFactory());
+}
+
+// Bridge for SimpleDatabaseSystem
+
+void SetDatabaseQuota(int quota) {
+ SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(quota);
+}
+
+void ClearAllDatabases() {
+ SimpleDatabaseSystem::GetInstance()->ClearAllDatabases();
+}
+
+} // namespace webkit_support