diff options
-rw-r--r-- | webkit/glue/webkitclient_impl.h | 1 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.h | 2 | ||||
-rw-r--r-- | webkit/support/test_webkit_client.cc | 233 | ||||
-rw-r--r-- | webkit/support/test_webkit_client.h | 75 | ||||
-rw-r--r-- | webkit/support/test_webplugin_page_delegate.h | 37 | ||||
-rw-r--r-- | webkit/support/webkit_support.cc | 133 | ||||
-rw-r--r-- | webkit/support/webkit_support.gyp | 17 | ||||
-rw-r--r-- | webkit/support/webkit_support.gypi | 48 | ||||
-rw-r--r-- | webkit/support/webkit_support.h | 47 | ||||
-rw-r--r-- | webkit/support/webkit_support_glue.cc | 37 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.gypi | 16 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 35 | ||||
-rw-r--r-- | webkit/webkit.gyp | 1 |
13 files changed, 633 insertions, 49 deletions
diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index 8435bd0..df1f9c7 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -19,6 +19,7 @@ namespace webkit_glue { class WebKitClientImpl : public WebKit::WebKitClient { public: WebKitClientImpl(); + virtual ~WebKitClientImpl() {} // WebKitClient methods (partial implementation): virtual WebKit::WebThemeEngine* themeEngine(); diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h index d747d27..86e9df4 100644 --- a/webkit/glue/webplugin_impl.h +++ b/webkit/glue/webplugin_impl.h @@ -50,7 +50,7 @@ class WebPluginImpl : public WebPlugin, WebKit::WebFrame* frame, const WebKit::WebPluginParams& params, const base::WeakPtr<WebPluginPageDelegate>& page_delegate); - ~WebPluginImpl(); + virtual ~WebPluginImpl(); // Helper function for sorting post data. static bool SetPostData(WebKit::WebURLRequest* request, diff --git a/webkit/support/test_webkit_client.cc b/webkit/support/test_webkit_client.cc new file mode 100644 index 0000000..7f41c07 --- /dev/null +++ b/webkit/support/test_webkit_client.cc @@ -0,0 +1,233 @@ +// 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 "base/file_util.h" +#include "base/path_service.h" +#include "base/scoped_temp_dir.h" +#include "base/stats_counters.h" +#include "base/string_util.h" +#include "net/base/cookie_monster.h" +#include "net/http/http_cache.h" +#include "net/socket/ssl_test_util.h" +#include "media/base/media.h" +#include "third_party/WebKit/WebKit/chromium/public/WebData.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" +#include "third_party/WebKit/WebKit/chromium/public/WebKit.h" +#include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" +#include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h" +#include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h" +#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/WebKit/chromium/public/WebURL.h" +#include "webkit/appcache/web_application_cache_host_impl.h" +#include "webkit/database/vfs_backend.h" +#include "webkit/extensions/v8/gc_extension.h" +#include "webkit/extensions/v8/gears_extension.h" +#include "webkit/extensions/v8/interval_extension.h" +#include "webkit/glue/simple_webmimeregistry_impl.h" +#include "webkit/glue/webclipboard_impl.h" +#include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webkitclient_impl.h" +#include "webkit/support/test_webkit_client.h" +#include "webkit/tools/test_shell/mock_webclipboard_impl.h" +#include "webkit/tools/test_shell/simple_appcache_system.h" +#include "webkit/tools/test_shell/simple_database_system.h" +#include "webkit/tools/test_shell/simple_resource_loader_bridge.h" +#include "webkit/tools/test_shell/simple_webcookiejar_impl.h" +#include "webkit/tools/test_shell/test_shell_request_context.h" +#include "v8/include/v8.h" + +#if defined(OS_WIN) +#include "third_party/WebKit/WebKit/chromium/public/win/WebThemeEngine.h" +#include "webkit/tools/test_shell/test_shell_webthemeengine.h" +#endif + +using WebKit::WebScriptController; + +TestWebKitClient::TestWebKitClient() { + v8::V8::SetCounterFunction(StatsTable::FindLocation); + + WebKit::initialize(this); + WebKit::setLayoutTestMode(true); + WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( + WebKit::WebString::fromUTF8("test-shell-resource")); + WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( + WebKit::WebString::fromUTF8("test-shell-resource")); + WebScriptController::enableV8SingleThreadMode(); + WebScriptController::registerExtension( + extensions_v8::GearsExtension::Get()); + WebScriptController::registerExtension( + extensions_v8::IntervalExtension::Get()); + WebKit::WebRuntimeFeatures::enableSockets(true); + WebKit::WebRuntimeFeatures::enableApplicationCache(true); + WebKit::WebRuntimeFeatures::enableDatabase(true); + + // Load libraries for media and enable the media player. + FilePath module_path; + WebKit::WebRuntimeFeatures::enableMediaPlayer( + PathService::Get(base::DIR_MODULE, &module_path) && + media::InitializeMediaLibrary(module_path)); + // TODO(joth): Make a dummy geolocation service implemenation for + // test_shell, and set this to true. http://crbug.com/36451 + WebKit::WebRuntimeFeatures::enableGeolocation(false); + + // Construct and initialize an appcache system for this scope. + // A new empty temp directory is created to house any cached + // content during the run. Upon exit that directory is deleted. + // If we can't create a tempdir, we'll use in-memory storage. + if (!appcache_dir_.CreateUniqueTempDir()) { + LOG(WARNING) << "Failed to create a temp dir for the appcache, " + "using in-memory storage."; + DCHECK(appcache_dir_.path().empty()); + } + SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); + + WebKit::WebDatabase::setObserver(&database_system_); + +#if defined(OS_WIN) + // Ensure we pick up the default theme engine. + SetThemeEngine(NULL); +#endif + + net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; + net::CookieMonster::EnableFileScheme(); + + // Initializing with a default context, which means no on-disk cookie DB, + // and no support for directory listings. + SimpleResourceLoaderBridge::Init( + new TestShellRequestContext(FilePath(), cache_mode, true)); + + // Test shell always exposes the GC. + webkit_glue::SetJavaScriptFlags(L" --expose-gc"); + // Expose GCController to JavaScript. + WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); +} + +TestWebKitClient::~TestWebKitClient() { + WebKit::shutdown(); +} + +WebKit::WebMimeRegistry* TestWebKitClient::mimeRegistry() { + return &mime_registry_; +} + +WebKit::WebClipboard* TestWebKitClient::clipboard() { + // Mock out clipboard calls so that tests don't mess + // with each other's copies/pastes when running in parallel. + return &mock_clipboard_; +} + +WebKit::WebSandboxSupport* TestWebKitClient::sandboxSupport() { + return NULL; +} + +WebKit::WebCookieJar* TestWebKitClient::cookieJar() { + return &cookie_jar_; +} + +bool TestWebKitClient::sandboxEnabled() { + return true; +} + +WebKit::WebKitClient::FileHandle TestWebKitClient::databaseOpenFile( + const WebKit::WebString& vfs_file_name, int desired_flags, + WebKit::WebKitClient::FileHandle* dir_handle) { + return SimpleDatabaseSystem::GetInstance()->OpenFile( + vfs_file_name, desired_flags, dir_handle); +} + +int TestWebKitClient::databaseDeleteFile(const WebKit::WebString& vfs_file_name, + bool sync_dir) { + return SimpleDatabaseSystem::GetInstance()->DeleteFile( + vfs_file_name, sync_dir); +} + +long TestWebKitClient::databaseGetFileAttributes( + const WebKit::WebString& vfs_file_name) { + return SimpleDatabaseSystem::GetInstance()->GetFileAttributes(vfs_file_name); +} + +long long TestWebKitClient::databaseGetFileSize( + const WebKit::WebString& vfs_file_name) { + return SimpleDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name); +} + +bool TestWebKitClient::getFileSize(const WebKit::WebString& path, long long& result) { + return file_util::GetFileSize( + webkit_glue::WebStringToFilePath(path), + reinterpret_cast<int64*>(&result)); +} + +unsigned long long TestWebKitClient::visitedLinkHash(const char* canonicalURL, + size_t length) { + return 0; +} + +bool TestWebKitClient::isLinkVisited(unsigned long long linkHash) { + return false; +} + +WebKit::WebMessagePortChannel* TestWebKitClient::createMessagePortChannel() { + return NULL; +} + +void TestWebKitClient::prefetchHostName(const WebKit::WebString&) { +} + +WebKit::WebData TestWebKitClient::loadResource(const char* name) { + if (!strcmp(name, "deleteButton")) { + // Create a red 30x30 square. + const char red_square[] = + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" + "\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3" + "\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00" + "\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80" + "\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff" + "\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00" + "\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a" + "\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a" + "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d" + "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" + "\x82"; + return WebKit::WebData(red_square, arraysize(red_square)); + } + return webkit_glue::WebKitClientImpl::loadResource(name); +} + +WebKit::WebString TestWebKitClient::defaultLocale() { + return ASCIIToUTF16("en-US"); +} + +WebKit::WebStorageNamespace* TestWebKitClient::createLocalStorageNamespace( + const WebKit::WebString& path, unsigned quota) { + return WebKit::WebStorageNamespace::createLocalStorageNamespace(path, quota); +} + +void TestWebKitClient::dispatchStorageEvent(const WebKit::WebString& key, + const WebKit::WebString& old_value, const WebKit::WebString& new_value, + const WebKit::WebString& origin, const WebKit::WebURL& url, + bool is_local_storage) { + // The event is dispatched by the proxy. +} + +WebKit::WebApplicationCacheHost* TestWebKitClient::createApplicationCacheHost( + WebKit::WebApplicationCacheHostClient* client) { + return SimpleAppCacheSystem::CreateApplicationCacheHost(client); +} + +#if defined(OS_WIN) +void TestWebKitClient::SetThemeEngine(WebKit::WebThemeEngine* engine) { + active_theme_engine_ = engine ? engine : WebKitClientImpl::themeEngine(); +} + +WebKit::WebThemeEngine* TestWebKitClient::themeEngine() { + return active_theme_engine_; +} +#endif + +WebKit::WebSharedWorkerRepository* TestWebKitClient::sharedWorkerRepository() { + return NULL; +} diff --git a/webkit/support/test_webkit_client.h b/webkit/support/test_webkit_client.h new file mode 100644 index 0000000..c17999a --- /dev/null +++ b/webkit/support/test_webkit_client.h @@ -0,0 +1,75 @@ +// 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. + +#ifndef WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_ +#define WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_ + +#include "webkit/glue/simple_webmimeregistry_impl.h" +#include "webkit/glue/webkitclient_impl.h" +#include "webkit/tools/test_shell/mock_webclipboard_impl.h" +#include "webkit/tools/test_shell/simple_appcache_system.h" +#include "webkit/tools/test_shell/simple_database_system.h" +#include "webkit/tools/test_shell/simple_webcookiejar_impl.h" + +// An implementation of WebKitClient for tests. +class TestWebKitClient : public webkit_glue::WebKitClientImpl { + public: + explicit TestWebKitClient(); + virtual ~TestWebKitClient(); + + virtual WebKit::WebMimeRegistry* mimeRegistry(); + WebKit::WebClipboard* clipboard(); + virtual WebKit::WebSandboxSupport* sandboxSupport(); + virtual WebKit::WebCookieJar* cookieJar(); + virtual bool sandboxEnabled(); + virtual WebKit::WebKitClient::FileHandle databaseOpenFile( + const WebKit::WebString& vfs_file_name, int desired_flags, + WebKit::WebKitClient::FileHandle* dir_handle); + virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, + bool sync_dir); + virtual long databaseGetFileAttributes( + const WebKit::WebString& vfs_file_name); + virtual long long databaseGetFileSize( + const WebKit::WebString& vfs_file_name); + virtual bool getFileSize(const WebKit::WebString& path, long long& result); + virtual unsigned long long visitedLinkHash(const char* canonicalURL, + size_t length); + virtual bool isLinkVisited(unsigned long long linkHash); + virtual WebKit::WebMessagePortChannel* createMessagePortChannel(); + virtual void prefetchHostName(const WebKit::WebString&); + virtual WebKit::WebData loadResource(const char* name); + virtual WebKit::WebString defaultLocale(); + virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( + const WebKit::WebString& path, unsigned quota); + + void dispatchStorageEvent(const WebKit::WebString& key, + const WebKit::WebString& old_value, const WebKit::WebString& new_value, + const WebKit::WebString& origin, const WebKit::WebURL& url, + bool is_local_storage); + + virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( + WebKit::WebApplicationCacheHostClient* client); + +#if defined(OS_WIN) + void SetThemeEngine(WebKit::WebThemeEngine* engine); + virtual WebKit::WebThemeEngine *themeEngine(); +#endif + + virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository(); + + private: + webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; + MockWebClipboardImpl mock_clipboard_; + ScopedTempDir appcache_dir_; + SimpleAppCacheSystem appcache_system_; + SimpleDatabaseSystem database_system_; + SimpleWebCookieJarImpl cookie_jar_; + +#if defined(OS_WIN) + WebKit::WebThemeEngine* active_theme_engine_; +#endif + DISALLOW_COPY_AND_ASSIGN(TestWebKitClient); +}; + +#endif // WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_ diff --git a/webkit/support/test_webplugin_page_delegate.h b/webkit/support/test_webplugin_page_delegate.h new file mode 100644 index 0000000..771aba3 --- /dev/null +++ b/webkit/support/test_webplugin_page_delegate.h @@ -0,0 +1,37 @@ +// 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. + +#ifndef WEBKIT_SUPPORT_TEST_WEBPLUGIN_PAGE_DELEGATE_H_ +#define WEBKIT_SUPPORT_TEST_WEBPLUGIN_PAGE_DELEGATE_H_ + +#include <string> + +#include "webkit/glue/webplugin_page_delegate.h" + +namespace webkit_support { + +class TestWebPluginPageDelegate : public webkit_glue::WebPluginPageDelegate { + public: + TestWebPluginPageDelegate() {} + virtual ~TestWebPluginPageDelegate() {} + + virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( + const GURL& url, + const std::string& mime_type, + std::string* actual_mime_type) { return NULL; } + virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle) {} + virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle) {} + virtual void DidMovePlugin(const webkit_glue::WebPluginGeometry& move) {} + virtual void DidStartLoadingForPlugin() {} + virtual void DidStopLoadingForPlugin() {} + virtual void ShowModalHTMLDialogForPlugin( + const GURL& url, + const gfx::Size& size, + const std::string& json_arguments, + std::string* json_retval) {} + virtual WebKit::WebCookieJar* GetCookieJar() { return NULL; } +}; + +} // namespace webkit_support +#endif // WEBKIT_SUPPORT_TEST_WEBPLUGIN_PAGE_DELEGATE_H_ 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 diff --git a/webkit/support/webkit_support.gyp b/webkit/support/webkit_support.gyp new file mode 100644 index 0000000..8853b6c --- /dev/null +++ b/webkit/support/webkit_support.gyp @@ -0,0 +1,17 @@ +# 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. + +{ + # Suppose this file is put at WebKit/WebKit/chromium/webkit/support/. + 'includes': [ + '../../features.gypi', + 'webkit_support.gypi', + ], +} + +# Local Variables: +# tab-width:2 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=2 shiftwidth=2: diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi new file mode 100644 index 0000000..cc8cc02 --- /dev/null +++ b/webkit/support/webkit_support.gypi @@ -0,0 +1,48 @@ +# 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. + +{ + 'targets': [ + { + 'target_name': 'webkit_support', + 'type': 'static_library', + 'dependencies': [ + '<(DEPTH)/media/media.gyp:media', + '<(DEPTH)/skia/skia.gyp:skia', + '<(DEPTH)/webkit/webkit.gyp:appcache', + '<(DEPTH)/webkit/webkit.gyp:database', + '<(DEPTH)/webkit/webkit.gyp:glue', + ], + 'sources': [ + 'test_webkit_client.cc', + 'test_webkit_client.h', + 'test_webplugin_page_delegate.h', + 'webkit_support.cc', + 'webkit_support.h', + 'webkit_support_glue.cc', + # TODO(tkent): Move the following files to here. + '<(DEPTH)/webkit/tools/test_shell/mock_webclipboard_impl.cc', + '<(DEPTH)/webkit/tools/test_shell/mock_webclipboard_impl.h', + '<(DEPTH)/webkit/tools/test_shell/simple_appcache_system.cc', + '<(DEPTH)/webkit/tools/test_shell/simple_appcache_system.h', + '<(DEPTH)/webkit/tools/test_shell/simple_clipboard_impl.cc', + '<(DEPTH)/webkit/tools/test_shell/simple_database_system.cc', + '<(DEPTH)/webkit/tools/test_shell/simple_database_system.h', + '<(DEPTH)/webkit/tools/test_shell/simple_resource_loader_bridge.cc', + '<(DEPTH)/webkit/tools/test_shell/simple_resource_loader_bridge.h', + '<(DEPTH)/webkit/tools/test_shell/simple_socket_stream_bridge.cc', + '<(DEPTH)/webkit/tools/test_shell/simple_socket_stream_bridge.h', + '<(DEPTH)/webkit/tools/test_shell/simple_webcookiejar_impl.cc', + '<(DEPTH)/webkit/tools/test_shell/simple_webcookiejar_impl.h', + '<(DEPTH)/webkit/tools/test_shell/test_shell_request_context.cc', + '<(DEPTH)/webkit/tools/test_shell/test_shell_request_context.h', + ], + }, + ], +} +# Local Variables: +# tab-width:2 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=2 shiftwidth=2: diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h new file mode 100644 index 0000000..651bb5c --- /dev/null +++ b/webkit/support/webkit_support.h @@ -0,0 +1,47 @@ +// 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. + +#ifndef WEBKIT_SUPPORT_WEBIT_SUPPORT_H_ +#define WEBKIT_SUPPORT_WEBIT_SUPPORT_H_ + +namespace WebKit { +class WebFrame; +class WebKitClient; +class WebMediaPlayer; +class WebMediaPlayerClient; +class WebPlugin; +struct WebPluginParams; +} + +// This package provides functions used by DumpRenderTree/chromium. +// DumpRenderTree/chromium uses some code in webkit/ of Chromium. In +// order to minimize the dependency from WebKit to Chromium, the +// following functions uses WebKit API classes as possible and hide +// implementation classes. +namespace webkit_support { + +// Initializes or terminates a test environment. +void SetUpTestEnvironment(); +void TearDownTestEnvironment(); + +// Returns a pointer to a WebKitClient implementation for DumpRenderTree. +// Needs to call SetUpTestEnvironment() before this. +// This returns a pointer to a static instance. Don't delete it. +WebKit::WebKitClient* GetWebKitClient(); + +// This is used by WebFrameClient::createPlugin(). +WebKit::WebPlugin* CreateWebPlugin(WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params); + +// This is used by WebFrameClient::createMediaPlayer(). +WebKit::WebMediaPlayer* CreateMediaPlayer(WebKit::WebFrame* frame, + WebKit::WebMediaPlayerClient* client); + +// The following functions are used by LayoutTestController. +void SetDatabaseQuota(int quota); +void ClearAllDatabases(); + +} // namespace webkit_support + +#endif // WEBKIT_SUPPORT_WEBIT_CLIENT_IMPL_H_ diff --git a/webkit/support/webkit_support_glue.cc b/webkit/support/webkit_support_glue.cc new file mode 100644 index 0000000..6857c89 --- /dev/null +++ b/webkit/support/webkit_support_glue.cc @@ -0,0 +1,37 @@ +// 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 "googleurl/src/gurl.h" +#include "webkit/glue/plugins/plugin_list.h" +#include "webkit/glue/webkit_glue.h" + +// Functions needed by webkit_glue. + +namespace webkit_glue { + +void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { + NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); +} + +bool IsDefaultPluginEnabled() { + return false; +} + +bool IsPluginRunningInRendererProcess() { + return true; +} + +void AppendToLog(const char*, int, const char*) { +} + +bool IsProtocolSupportedForMedia(const GURL& url) { + if (url.SchemeIsFile() || + url.SchemeIs("http") || + url.SchemeIs("https") || + url.SchemeIs("data")) + return true; + return false; +} + +} // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index 67bb736..ebdabae 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -43,6 +43,7 @@ '<(DEPTH)/webkit/webkit.gyp:database', '<(DEPTH)/webkit/webkit.gyp:glue', '<(DEPTH)/webkit/webkit.gyp:inspector_resources', + '<(DEPTH)/webkit/webkit.gyp:webkit_support', 'npapi_layout_test_plugin', ], 'msvs_guid': '77C32787-1B96-CB84-B905-7F170629F0AC', @@ -69,22 +70,9 @@ 'layout_test_controller.h', 'mock_spellcheck.cc', 'mock_spellcheck.h', - 'mock_webclipboard_impl.cc', - 'mock_webclipboard_impl.h', 'plain_text_controller.cc', 'plain_text_controller.h', 'resource.h', - 'simple_appcache_system.cc', - 'simple_appcache_system.h', - 'simple_clipboard_impl.cc', - 'simple_database_system.cc', - 'simple_database_system.h', - 'simple_resource_loader_bridge.cc', - 'simple_resource_loader_bridge.h', - 'simple_socket_stream_bridge.cc', - 'simple_socket_stream_bridge.h', - 'simple_webcookiejar_impl.h', - 'simple_webcookiejar_impl.cc', 'test_navigation_controller.cc', 'test_navigation_controller.h', 'test_shell.cc', @@ -102,8 +90,6 @@ 'test_shell_platform_delegate_gtk.cc', 'test_shell_platform_delegate_mac.mm', 'test_shell_platform_delegate_win.cc', - 'test_shell_request_context.cc', - 'test_shell_request_context.h', 'test_shell_switches.cc', 'test_shell_switches.h', 'test_shell_win.cc', diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 1cff673..ded3c1c 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -41,18 +41,14 @@ #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/glue/glue_serialize.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/webdropdata.h" #include "webkit/glue/webplugin_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" -#include "webkit/glue/webmediaplayer_impl.h" #include "webkit/glue/window_open_disposition.h" +#include "webkit/support/webkit_support.h" #include "webkit/tools/test_shell/accessibility_controller.h" #include "webkit/tools/test_shell/mock_spellcheck.h" #include "webkit/tools/test_shell/test_navigation_controller.h" @@ -642,34 +638,7 @@ WebWorker* TestWebViewDelegate::createWorker( WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( WebFrame* frame, WebMediaPlayerClient* client) { - scoped_refptr<media::FilterFactoryCollection> factory = - new media::FilterFactoryCollection(); - - WebApplicationCacheHostImpl* appcache_host = - 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()); + return webkit_support::CreateMediaPlayer(frame, client); } bool TestWebViewDelegate::allowPlugins(WebFrame* frame, diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index eaeb46e..561f892 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -7,6 +7,7 @@ '../third_party/WebKit/WebKit/chromium/features.gypi', '../third_party/WebKit/WebKit/chromium/WebKit.gypi', '../third_party/WebKit/WebCore/WebCore.gypi', + 'support/webkit_support.gypi', 'tools/test_shell/test_shell.gypi', ], 'variables': { |