diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 05:42:36 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 05:42:36 +0000 |
commit | 0157282494c1096cef55f04d7b8936c7db022679 (patch) | |
tree | 33d30478c95e60b4ba629b098db06ae2d1418278 /webkit | |
parent | 745816be61e207da7cef1f839591bfb35bd15fd3 (diff) | |
download | chromium_src-0157282494c1096cef55f04d7b8936c7db022679.zip chromium_src-0157282494c1096cef55f04d7b8936c7db022679.tar.gz chromium_src-0157282494c1096cef55f04d7b8936c7db022679.tar.bz2 |
Move some webkit_glue embedder functions into WebKitPlatformSupport virtual methods
This moves the functions into a pattern that is component-friendly.
BUG=98755
TEST=chrome test_shell test_shell_tests browser_tests DumpRenderTree
Review URL: http://codereview.chromium.org/8602002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
26 files changed, 306 insertions, 240 deletions
diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index 6711039..da0a36e 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -4,8 +4,7 @@ // // The intent of this file is to provide a type-neutral abstraction between // Chrome and WebKit for resource loading. This pure-virtual interface is -// implemented by the embedder, which also provides a factory method Create -// to instantiate this object. +// implemented by the embedder. // // One of these objects will be created by WebKit for each request. WebKit // will own the pointer to the bridge, and will delete it when the request is @@ -197,7 +196,8 @@ struct ResourceResponseInfo { class ResourceLoaderBridge { public: - // Structure used when calling ResourceLoaderBridge::Create(). + // Structure used when calling + // WebKitPlatformSupportImpl::CreateResourceLoader(). struct RequestInfo { RequestInfo(); ~RequestInfo(); @@ -329,16 +329,10 @@ class ResourceLoaderBridge { const base::Time& completion_time) = 0; }; - // use Create() for construction, but anybody can delete at any time, - // INCLUDING during processing of callbacks. + // use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but + // anybody can delete at any time, INCLUDING during processing of callbacks. virtual ~ResourceLoaderBridge(); - // Call this method to make a new instance. - // - // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload - // methods may be called to construct the body of the request. - static ResourceLoaderBridge* Create(const RequestInfo& request_info); - // Call this method before calling Start() to append a chunk of binary data // to the request body. May only be used with HTTP(S) POST requests. virtual void AppendDataToUpload(const char* data, int data_len) = 0; @@ -394,7 +388,10 @@ class ResourceLoaderBridge { virtual void UpdateRoutingId(int new_routing_id) = 0; protected: - // construction must go through Create() + // Construction must go through + // WebKitPlatformSupportImpl::CreateResourceLoader() + // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload + // methods may be called to construct the body of the request. ResourceLoaderBridge(); private: diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index ddbc3a3..ef00fb4 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -36,15 +36,8 @@ class WebFrame; class WebString; } -namespace webkit { -struct WebPluginInfo; -} - namespace webkit_glue { - -//---- BEGIN FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE ----------------------------- - void SetJavaScriptFlags(const std::string& flags); // Turn on logging for flags in the provided comma delimited list. @@ -151,28 +144,6 @@ std::string GetInspectorProtocolVersion(); // Tells caller whether the given protocol version is supported by the. bool IsInspectorProtocolVersionSupported(const std::string& version); -//---- END FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE ------------------------------- - - -//---- BEGIN FUNCTIONS IMPLEMENTED BY EMBEDDER -------------------------------- - -// Glue to get resources from the embedder. - -// Gets a localized string given a message id. Returns an empty string if the -// message id is not found. -string16 GetLocalizedString(int message_id); - -// Returns the raw data for a resource. This resource must have been -// specified as BINDATA in the relevant .rc file. -base::StringPiece GetDataResource(int resource_id); - -// Embedders implement this function to return the list of plugins to Webkit. -void GetPlugins(bool refresh, - std::vector<webkit::WebPluginInfo>* plugins); - -// ---- END FUNCTIONS IMPLEMENTED BY EMBEDDER --------------------------------- - - } // namespace webkit_glue #endif // WEBKIT_GLUE_WEBKIT_GLUE_H_ diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc index 7c0863f..5df7d13 100644 --- a/webkit/glue/webkitplatformsupport_impl.cc +++ b/webkit/glue/webkitplatformsupport_impl.cc @@ -223,11 +223,11 @@ WebThemeEngine* WebKitPlatformSupportImpl::themeEngine() { } WebURLLoader* WebKitPlatformSupportImpl::createURLLoader() { - return new WebURLLoaderImpl(); + return new WebURLLoaderImpl(this); } WebSocketStreamHandle* WebKitPlatformSupportImpl::createSocketStreamHandle() { - return new WebSocketStreamHandleImpl(); + return new WebSocketStreamHandleImpl(this); } WebString WebKitPlatformSupportImpl::userAgent(const WebURL& url) { @@ -306,7 +306,8 @@ void WebKitPlatformSupportImpl::traceEventEnd(const char* name, void* id, namespace { -WebData loadAudioSpatializationResource(const char* name) { +WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform, + const char* name) { #ifdef IDR_AUDIO_SPATIALIZATION_T000_P000 const size_t kExpectedSpatializationNameLength = 31; if (strlen(name) != kExpectedSpatializationNameLength) { @@ -346,7 +347,7 @@ WebData loadAudioSpatializationResource(const char* name) { is_resource_index_good) { const int kFirstAudioResourceIndex = IDR_AUDIO_SPATIALIZATION_T000_P000; base::StringPiece resource = - GetDataResource(kFirstAudioResourceIndex + resource_index); + platform->GetDataResource(kFirstAudioResourceIndex + resource_index); return WebData(resource.data(), resource.size()); } #endif // IDR_AUDIO_SPATIALIZATION_T000_P000 @@ -434,7 +435,7 @@ WebData WebKitPlatformSupportImpl::loadResource(const char* name) { // Check the name prefix to see if it's an audio resource. if (StartsWithASCII(name, "IRC_Composite", true)) - return loadAudioSpatializationResource(name); + return loadAudioSpatializationResource(this, name); for (size_t i = 0; i < arraysize(kDataResources); ++i) { if (!strcmp(name, kDataResources[i].name)) { diff --git a/webkit/glue/webkitplatformsupport_impl.h b/webkit/glue/webkitplatformsupport_impl.h index d73e242..7ecbd3a 100644 --- a/webkit/glue/webkitplatformsupport_impl.h +++ b/webkit/glue/webkitplatformsupport_impl.h @@ -9,6 +9,7 @@ #include "base/threading/thread_local_storage.h" #include "base/timer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport.h" +#include "webkit/glue/resource_loader_bridge.h" #if defined(OS_WIN) #include "webkit/glue/webthemeengine_impl_win.h" #elif defined(OS_MACOSX) @@ -20,8 +21,19 @@ class MessageLoop; +namespace webkit { +struct WebPluginInfo; +} + +namespace WebKit { +class WebSocketStreamHandle; +} + namespace webkit_glue { +class WebSocketStreamHandleDelegate; +class WebSocketStreamHandleBridge; + class WebKitPlatformSupportImpl : public WebKit::WebKitPlatformSupport { public: WebKitPlatformSupportImpl(); @@ -82,6 +94,29 @@ class WebKitPlatformSupportImpl : public WebKit::WebKitPlatformSupport { virtual WebKit::WebThread* createThread(const char* name); virtual WebKit::WebThread* currentThread(); + + // Embedder functions. The following are not implemented by the glue layer and + // need to be specialized by the embedder. + + // Gets a localized string given a message id. Returns an empty string if the + // message id is not found. + virtual string16 GetLocalizedString(int message_id) = 0; + + // Returns the raw data for a resource. This resource must have been + // specified as BINDATA in the relevant .rc file. + virtual base::StringPiece GetDataResource(int resource_id) = 0; + + // Returns the list of plugins. + virtual void GetPlugins(bool refresh, + std::vector<webkit::WebPluginInfo>* plugins) = 0; + // Creates a ResourceLoaderBridge. + virtual ResourceLoaderBridge* CreateResourceLoader( + const ResourceLoaderBridge::RequestInfo& request_info) = 0; + // Creates a WebSocketStreamHandleBridge. + virtual WebSocketStreamHandleBridge* CreateWebSocketBridge( + WebKit::WebSocketStreamHandle* handle, + WebSocketStreamHandleDelegate* delegate) = 0; + void SuspendSharedTimer(); void ResumeSharedTimer(); diff --git a/webkit/glue/websocketstreamhandle_bridge.h b/webkit/glue/websocketstreamhandle_bridge.h index d051712..c1712cb 100644 --- a/webkit/glue/websocketstreamhandle_bridge.h +++ b/webkit/glue/websocketstreamhandle_bridge.h @@ -23,10 +23,6 @@ class WebSocketStreamHandleDelegate; class WebSocketStreamHandleBridge : public base::RefCountedThreadSafe<WebSocketStreamHandleBridge> { public: - static WebSocketStreamHandleBridge* Create( - WebKit::WebSocketStreamHandle* handle, - WebSocketStreamHandleDelegate* delegate); - virtual void Connect(const GURL& url) = 0; virtual bool Send(const std::vector<char>& data) = 0; diff --git a/webkit/glue/websocketstreamhandle_impl.cc b/webkit/glue/websocketstreamhandle_impl.cc index 9e26896..d9cf197 100644 --- a/webkit/glue/websocketstreamhandle_impl.cc +++ b/webkit/glue/websocketstreamhandle_impl.cc @@ -15,6 +15,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketStreamHandleClient.h" +#include "webkit/glue/webkitplatformsupport_impl.h" #include "webkit/glue/websocketstreamhandle_bridge.h" #include "webkit/glue/websocketstreamhandle_delegate.h" @@ -33,7 +34,7 @@ class WebSocketStreamHandleImpl::Context client_ = client; } - void Connect(const WebKit::WebURL& url); + void Connect(const WebKit::WebURL& url, WebKitPlatformSupportImpl* platform); bool Send(const WebKit::WebData& data); void Close(); @@ -71,10 +72,12 @@ WebSocketStreamHandleImpl::Context::Context(WebSocketStreamHandleImpl* handle) bridge_(NULL) { } -void WebSocketStreamHandleImpl::Context::Connect(const WebKit::WebURL& url) { +void WebSocketStreamHandleImpl::Context::Connect( + const WebKit::WebURL& url, + WebKitPlatformSupportImpl* platform) { VLOG(1) << "Connect url=" << url; DCHECK(!bridge_); - bridge_ = WebSocketStreamHandleBridge::Create(handle_, this); + bridge_ = platform->CreateWebSocketBridge(handle_, this); AddRef(); // Will be released by DidClose(). bridge_->Connect(url); } @@ -138,8 +141,10 @@ void WebSocketStreamHandleImpl::Context::DidClose( // WebSocketStreamHandleImpl ------------------------------------------------ -WebSocketStreamHandleImpl::WebSocketStreamHandleImpl() - : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))) { +WebSocketStreamHandleImpl::WebSocketStreamHandleImpl( + WebKitPlatformSupportImpl* platform) + : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))), + platform_(platform) { } WebSocketStreamHandleImpl::~WebSocketStreamHandleImpl() { @@ -155,7 +160,7 @@ void WebSocketStreamHandleImpl::connect( DCHECK(!context_->client()); context_->set_client(client); - context_->Connect(url); + context_->Connect(url, platform_); } bool WebSocketStreamHandleImpl::send(const WebKit::WebData& data) { diff --git a/webkit/glue/websocketstreamhandle_impl.h b/webkit/glue/websocketstreamhandle_impl.h index e018388..9ce5d77 100644 --- a/webkit/glue/websocketstreamhandle_impl.h +++ b/webkit/glue/websocketstreamhandle_impl.h @@ -10,9 +10,11 @@ namespace webkit_glue { +class WebKitPlatformSupportImpl; + class WebSocketStreamHandleImpl : public WebKit::WebSocketStreamHandle { public: - WebSocketStreamHandleImpl(); + explicit WebSocketStreamHandleImpl(WebKitPlatformSupportImpl* platform); virtual ~WebSocketStreamHandleImpl(); // WebSocketStreamHandle methods: @@ -25,6 +27,7 @@ class WebSocketStreamHandleImpl : public WebKit::WebSocketStreamHandle { private: class Context; scoped_refptr<Context> context_; + WebKitPlatformSupportImpl* platform_; DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleImpl); }; diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 1d8f21c..9e7c3eb 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -32,6 +32,7 @@ #include "webkit/glue/multipart_response_delegate.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webkitplatformsupport_impl.h" using base::Time; using base::TimeDelta; @@ -262,7 +263,8 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>, void SetDefersLoading(bool value); void Start( const WebURLRequest& request, - ResourceLoaderBridge::SyncLoadResponse* sync_load_response); + ResourceLoaderBridge::SyncLoadResponse* sync_load_response, + WebKitPlatformSupportImpl* platform); void UpdateRoutingId(int new_routing_id); // ResourceLoaderBridge::Peer methods: @@ -332,7 +334,8 @@ void WebURLLoaderImpl::Context::UpdateRoutingId(int new_routing_id) { void WebURLLoaderImpl::Context::Start( const WebURLRequest& request, - ResourceLoaderBridge::SyncLoadResponse* sync_load_response) { + ResourceLoaderBridge::SyncLoadResponse* sync_load_response, + WebKitPlatformSupportImpl* platform) { DCHECK(!bridge_.get()); request_ = request; // Save the request. @@ -413,7 +416,7 @@ void WebURLLoaderImpl::Context::Start( request_info.download_to_file = request.downloadToFile(); request_info.has_user_gesture = request.hasUserGesture(); request_info.extra_data = request.extraData(); - bridge_.reset(ResourceLoaderBridge::Create(request_info)); + bridge_.reset(platform->CreateResourceLoader(request_info)); if (!request.httpBody().isNull()) { // GET and HEAD requests shouldn't have http bodies. @@ -686,8 +689,9 @@ void WebURLLoaderImpl::Context::HandleDataURL() { // WebURLLoaderImpl ----------------------------------------------------------- -WebURLLoaderImpl::WebURLLoaderImpl() - : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))) { +WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform) + : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))), + platform_(platform) { } WebURLLoaderImpl::~WebURLLoaderImpl() { @@ -699,7 +703,7 @@ void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request, WebURLError& error, WebData& data) { ResourceLoaderBridge::SyncLoadResponse sync_load_response; - context_->Start(request, &sync_load_response); + context_->Start(request, &sync_load_response, platform_); const GURL& final_url = sync_load_response.url; @@ -727,7 +731,7 @@ void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request, DCHECK(!context_->client()); context_->set_client(client); - context_->Start(request, NULL); + context_->Start(request, NULL, platform_); } void WebURLLoaderImpl::cancel() { diff --git a/webkit/glue/weburlloader_impl.h b/webkit/glue/weburlloader_impl.h index ace1cdb..226c2d1 100644 --- a/webkit/glue/weburlloader_impl.h +++ b/webkit/glue/weburlloader_impl.h @@ -10,9 +10,11 @@ namespace webkit_glue { +class WebKitPlatformSupportImpl; + class WebURLLoaderImpl : public WebKit::WebURLLoader { public: - WebURLLoaderImpl(); + explicit WebURLLoaderImpl(WebKitPlatformSupportImpl* platform); virtual ~WebURLLoaderImpl(); // WebURLLoader methods: @@ -32,6 +34,7 @@ class WebURLLoaderImpl : public WebKit::WebURLLoader { private: class Context; scoped_refptr<Context> context_; + WebKitPlatformSupportImpl* platform_; }; } // namespace webkit_glue diff --git a/webkit/support/platform_support_android.cc b/webkit/support/platform_support_android.cc index d069dbc..17e9a2e 100644 --- a/webkit/support/platform_support_android.cc +++ b/webkit/support/platform_support_android.cc @@ -13,6 +13,7 @@ #include "googleurl/src/gurl.h" #include "grit/webkit_resources.h" #include "ui/base/resource/resource_bundle.h" +#include "webkit/support/test_webkit_platform_support.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" namespace webkit_support { @@ -53,13 +54,11 @@ void AfterShutdown() { } // namespace webkit_support -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { FilePath resources_path; PathService::Get(base::DIR_EXE, &resources_path); resources_path = resources_path.Append("DumpRenderTree_resources"); @@ -88,5 +87,3 @@ base::StringPiece GetDataResource(int resource_id) { return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); } - -} // namespace webkit_glue diff --git a/webkit/support/platform_support_linux.cc b/webkit/support/platform_support_linux.cc index ab0f1c0..1ff0490 100644 --- a/webkit/support/platform_support_linux.cc +++ b/webkit/support/platform_support_linux.cc @@ -12,6 +12,7 @@ #include "base/string_piece.h" #include "grit/webkit_resources.h" #include "ui/base/resource/resource_bundle.h" +#include "webkit/support/test_webkit_platform_support.h" namespace webkit_support { @@ -40,13 +41,11 @@ void AfterShutdown() { } // namespace webkit_support -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { FilePath resources_path; PathService::Get(base::DIR_EXE, &resources_path); resources_path = resources_path.Append("DumpRenderTree_resources"); @@ -75,5 +74,3 @@ base::StringPiece GetDataResource(int resource_id) { return ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); } - -} // namespace webkit_glue diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm index 099b9bf..9b40c16 100644 --- a/webkit/support/platform_support_mac.mm +++ b/webkit/support/platform_support_mac.mm @@ -19,6 +19,7 @@ #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.h" #include "ui/base/resource/data_pack.h" #include "webkit/plugins/npapi/plugin_list.h" +#include "webkit/support/test_webkit_platform_support.h" #import "webkit/support/drt_application_mac.h" #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" @@ -156,9 +157,7 @@ void AfterShutdown() { } // namespace webkit_support -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { base::StringPiece res; if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { LOG(FATAL) << "failed to load webkit string with id " << message_id; @@ -194,7 +193,7 @@ static FilePath GetResourcesFilePath() { return path.AppendASCII("Resources"); } -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -231,5 +230,3 @@ base::StringPiece GetDataResource(int resource_id) { g_resource_data_pack->GetStringPiece(resource_id, &res); return res; } - -} // namespace webkit_glue diff --git a/webkit/support/platform_support_win.cc b/webkit/support/platform_support_win.cc index fb5126e..0d5eee2 100644 --- a/webkit/support/platform_support_win.cc +++ b/webkit/support/platform_support_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,6 +14,7 @@ #include "base/win/resource_util.h" #include "grit/webkit_chromium_resources.h" #include "grit/webkit_resources.h" +#include "webkit/support/test_webkit_platform_support.h" #define MAX_LOADSTRING 100 @@ -60,9 +61,7 @@ void AfterShutdown() { } // namespace webkit_support -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { wchar_t localized[MAX_LOADSTRING]; int length = ::LoadString(::GetModuleHandle(NULL), message_id, localized, MAX_LOADSTRING); @@ -73,7 +72,7 @@ string16 GetLocalizedString(int message_id) { return string16(localized, length); } -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -103,5 +102,3 @@ base::StringPiece GetDataResource(int resource_id) { return ResourceProvider(resource_id); } - -} // namespace webkit_glue diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc index 5067681..6ba5c7b 100644 --- a/webkit/support/test_webkit_platform_support.cc +++ b/webkit/support/test_webkit_platform_support.cc @@ -43,6 +43,7 @@ #include "webkit/glue/webkitplatformsupport_impl.h" #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" +#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/support/simple_database_system.h" #include "webkit/support/test_webmessageportchannel.h" #include "webkit/support/webkit_support.h" @@ -51,6 +52,7 @@ #include "webkit/tools/test_shell/mock_webclipboard_impl.h" #include "webkit/tools/test_shell/simple_appcache_system.h" #include "webkit/tools/test_shell/simple_file_system.h" +#include "webkit/tools/test_shell/simple_socket_stream_bridge.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" @@ -407,3 +409,38 @@ void TestWebKitPlatformSupport::setGamepadData( const WebKit::WebGamepads& data) { gamepad_data_ = data; } + +void TestWebKitPlatformSupport::GetPlugins( + bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { + if (refresh) + webkit::npapi::PluginList::Singleton()->RefreshPlugins(); + webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); + // Don't load the forked npapi_layout_test_plugin in DRT, we only want to + // use the upstream version TestNetscapePlugIn. + const FilePath::StringType kPluginBlackList[] = { + FILE_PATH_LITERAL("npapi_layout_test_plugin.dll"), + FILE_PATH_LITERAL("WebKitTestNetscapePlugIn.plugin"), + FILE_PATH_LITERAL("libnpapi_layout_test_plugin.so"), + }; + for (int i = plugins->size() - 1; i >= 0; --i) { + webkit::WebPluginInfo plugin_info = plugins->at(i); + for (size_t j = 0; j < arraysize(kPluginBlackList); ++j) { + if (plugin_info.path.BaseName() == FilePath(kPluginBlackList[j])) { + plugins->erase(plugins->begin() + i); + } + } + } +} + +webkit_glue::ResourceLoaderBridge* +TestWebKitPlatformSupport::CreateResourceLoader( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { + return SimpleResourceLoaderBridge::Create(request_info); +} + +webkit_glue::WebSocketStreamHandleBridge* +TestWebKitPlatformSupport::CreateWebSocketBridge( + WebKit::WebSocketStreamHandle* handle, + webkit_glue::WebSocketStreamHandleDelegate* delegate) { + return SimpleSocketStreamBridge::Create(handle, delegate); +} diff --git a/webkit/support/test_webkit_platform_support.h b/webkit/support/test_webkit_platform_support.h index ab6fedf..ca321c3 100644 --- a/webkit/support/test_webkit_platform_support.h +++ b/webkit/support/test_webkit_platform_support.h @@ -5,6 +5,7 @@ #ifndef WEBKIT_SUPPORT_TEST_WEBKIT_PLATFORM_SUPPORT_H_ #define WEBKIT_SUPPORT_TEST_WEBKIT_PLATFORM_SUPPORT_H_ +#include "base/compiler_specific.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGamepads.h" #include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webkitplatformsupport_impl.h" @@ -29,64 +30,66 @@ class TestWebKitPlatformSupport : explicit TestWebKitPlatformSupport(bool unit_test_mode); virtual ~TestWebKitPlatformSupport(); - virtual WebKit::WebMimeRegistry* mimeRegistry(); - virtual WebKit::WebClipboard* clipboard(); - virtual WebKit::WebFileUtilities* fileUtilities(); - virtual WebKit::WebSandboxSupport* sandboxSupport(); - virtual WebKit::WebCookieJar* cookieJar(); - virtual WebKit::WebBlobRegistry* blobRegistry(); - virtual WebKit::WebFileSystem* fileSystem(); + virtual WebKit::WebMimeRegistry* mimeRegistry() OVERRIDE; + virtual WebKit::WebClipboard* clipboard() OVERRIDE; + virtual WebKit::WebFileUtilities* fileUtilities() OVERRIDE; + virtual WebKit::WebSandboxSupport* sandboxSupport() OVERRIDE; + virtual WebKit::WebCookieJar* cookieJar() OVERRIDE; + virtual WebKit::WebBlobRegistry* blobRegistry() OVERRIDE; + virtual WebKit::WebFileSystem* fileSystem() OVERRIDE; - virtual bool sandboxEnabled(); + virtual bool sandboxEnabled() OVERRIDE; virtual WebKit::WebKitPlatformSupport::FileHandle databaseOpenFile( - const WebKit::WebString& vfs_file_name, int desired_flags); + const WebKit::WebString& vfs_file_name, int desired_flags) OVERRIDE; virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, - bool sync_dir); + bool sync_dir) OVERRIDE; virtual long databaseGetFileAttributes( - const WebKit::WebString& vfs_file_name); + const WebKit::WebString& vfs_file_name) OVERRIDE; virtual long long databaseGetFileSize( - const WebKit::WebString& vfs_file_name); + const WebKit::WebString& vfs_file_name) OVERRIDE; virtual long long databaseGetSpaceAvailableForOrigin( - const WebKit::WebString& origin_identifier); + const WebKit::WebString& origin_identifier) OVERRIDE; 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::WebURLLoader* createURLLoader(); - virtual WebKit::WebData loadResource(const char* name); + size_t length) OVERRIDE; + virtual bool isLinkVisited(unsigned long long linkHash) OVERRIDE; + virtual WebKit::WebMessagePortChannel* createMessagePortChannel() OVERRIDE; + virtual void prefetchHostName(const WebKit::WebString&) OVERRIDE; + virtual WebKit::WebURLLoader* createURLLoader() OVERRIDE; + virtual WebKit::WebData loadResource(const char* name) OVERRIDE; virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name); + WebKit::WebLocalizedString::Name name) OVERRIDE; virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name, const WebKit::WebString& value); + WebKit::WebLocalizedString::Name name, + const WebKit::WebString& value) OVERRIDE; virtual WebKit::WebString queryLocalizedString( WebKit::WebLocalizedString::Name name, - const WebKit::WebString& value1, const WebKit::WebString& value2); - virtual WebKit::WebString defaultLocale(); + const WebKit::WebString& value1, + const WebKit::WebString& value2) OVERRIDE; + virtual WebKit::WebString defaultLocale() OVERRIDE; virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( - const WebKit::WebString& path, unsigned quota); + const WebKit::WebString& path, unsigned quota) OVERRIDE; virtual 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::WebIDBFactory* idbFactory(); + bool is_local_storage) OVERRIDE; + virtual WebKit::WebIDBFactory* idbFactory() OVERRIDE; virtual void createIDBKeysFromSerializedValuesAndKeyPath( const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values, const WebKit::WebString& keyPath, - WebKit::WebVector<WebKit::WebIDBKey>& keys_out); + WebKit::WebVector<WebKit::WebIDBKey>& keys_out) OVERRIDE; virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue( const WebKit::WebIDBKey& key, const WebKit::WebSerializedScriptValue& value, - const WebKit::WebString& keyPath); + const WebKit::WebString& keyPath) OVERRIDE; #if defined(OS_WIN) || defined(OS_MACOSX) void SetThemeEngine(WebKit::WebThemeEngine* engine); - virtual WebKit::WebThemeEngine *themeEngine(); + virtual WebKit::WebThemeEngine *themeEngine() OVERRIDE; #endif - virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository(); - virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(); + virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() OVERRIDE; + virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE; WebURLLoaderMockFactory* url_loader_factory() { return &url_loader_factory_; @@ -98,15 +101,26 @@ class TestWebKitPlatformSupport : // Mock out the WebAudioDevice since the real one // talks with the browser process. - virtual double audioHardwareSampleRate(); - virtual size_t audioHardwareBufferSize(); + virtual double audioHardwareSampleRate() OVERRIDE; + virtual size_t audioHardwareBufferSize() OVERRIDE; virtual WebKit::WebAudioDevice* createAudioDevice(size_t bufferSize, unsigned numberOfChannels, double sampleRate, - WebKit::WebAudioDevice::RenderCallback*); + WebKit::WebAudioDevice::RenderCallback*) OVERRIDE; virtual void sampleGamepads(WebKit::WebGamepads& data); void setGamepadData(const WebKit::WebGamepads& data); + virtual string16 GetLocalizedString(int message_id) OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; + virtual void GetPlugins(bool refresh, + std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; + virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) + OVERRIDE; + virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge( + WebKit::WebSocketStreamHandle* handle, + webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE; + private: TestShellWebMimeRegistryImpl mime_registry_; MockWebClipboardImpl mock_clipboard_; diff --git a/webkit/support/webkit_support_glue.cc b/webkit/support/webkit_support_glue.cc index a1e64fd..dad0b60 100644 --- a/webkit/support/webkit_support_glue.cc +++ b/webkit/support/webkit_support_glue.cc @@ -7,34 +7,11 @@ #include "base/base_paths.h" #include "base/path_service.h" #include "webkit/glue/user_agent.h" -#include "webkit/plugins/npapi/plugin_list.h" // Functions needed by webkit_glue. namespace webkit_glue { -void GetPlugins(bool refresh, - std::vector<webkit::WebPluginInfo>* plugins) { - if (refresh) - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); - webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); - // Don't load the forked npapi_layout_test_plugin in DRT, we only want to - // use the upstream version TestNetscapePlugIn. - const FilePath::StringType kPluginBlackList[] = { - FILE_PATH_LITERAL("npapi_layout_test_plugin.dll"), - FILE_PATH_LITERAL("WebKitTestNetscapePlugIn.plugin"), - FILE_PATH_LITERAL("libnpapi_layout_test_plugin.so"), - }; - for (int i = plugins->size() - 1; i >= 0; --i) { - webkit::WebPluginInfo plugin_info = plugins->at(i); - for (size_t j = 0; j < arraysize(kPluginBlackList); ++j) { - if (plugin_info.path.BaseName() == FilePath(kPluginBlackList[j])) { - plugins->erase(plugins->begin() + i); - } - } - } -} - void AppendToLog(const char*, int, const char*) { } diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index a3e0f64..4b15a5b 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -907,18 +907,6 @@ class CookieGetter : public base::RefCountedThreadSafe<CookieGetter> { //----------------------------------------------------------------------------- -namespace webkit_glue { - -// Factory function. -ResourceLoaderBridge* ResourceLoaderBridge::Create( - const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { - return new ResourceLoaderBridgeImpl(request_info); -} - -} // namespace webkit_glue - -//----------------------------------------------------------------------------- - // static void SimpleResourceLoaderBridge::Init( const FilePath& cache_path, @@ -1047,3 +1035,9 @@ void SimpleResourceLoaderBridge::AllowFileOverHTTP( g_file_over_http_params = new FileOverHTTPParams(file_path_template, http_prefix); } + +// static +webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { + return new ResourceLoaderBridgeImpl(request_info); +} diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.h b/webkit/tools/test_shell/simple_resource_loader_bridge.h index 71f9ce5..003cf5a 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.h +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.h @@ -8,6 +8,7 @@ #include <string> #include "base/message_loop_proxy.h" #include "net/http/http_cache.h" +#include "webkit/glue/resource_loader_bridge.h" class FilePath; class GURL; @@ -51,6 +52,10 @@ class SimpleResourceLoaderBridge { // That is how we implement file-over-http feature. static void AllowFileOverHTTP(const std::string& file_path_template, const GURL& http_prefix); + + // Creates a ResourceLoaderBridge instance. + static webkit_glue::ResourceLoaderBridge* Create( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); }; #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_RESOURCE_LOADER_BRIDGE_H__ diff --git a/webkit/tools/test_shell/simple_socket_stream_bridge.cc b/webkit/tools/test_shell/simple_socket_stream_bridge.cc index 29ca159..3bd79db 100644 --- a/webkit/tools/test_shell/simple_socket_stream_bridge.cc +++ b/webkit/tools/test_shell/simple_socket_stream_bridge.cc @@ -234,13 +234,9 @@ void SimpleSocketStreamBridge::Cleanup() { g_request_context = NULL; } -namespace webkit_glue { - /* static */ -WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( +webkit_glue::WebSocketStreamHandleBridge* SimpleSocketStreamBridge::Create( WebKit::WebSocketStreamHandle* handle, - WebSocketStreamHandleDelegate* delegate) { + webkit_glue::WebSocketStreamHandleDelegate* delegate) { return new WebSocketStreamHandleBridgeImpl(handle, delegate); } - -} // namespace webkit_glue diff --git a/webkit/tools/test_shell/simple_socket_stream_bridge.h b/webkit/tools/test_shell/simple_socket_stream_bridge.h index a8fd821..dee2120 100644 --- a/webkit/tools/test_shell/simple_socket_stream_bridge.h +++ b/webkit/tools/test_shell/simple_socket_stream_bridge.h @@ -5,14 +5,31 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_SOCKET_STREAM_BRIDGE_H_ #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_SOCKET_STREAM_BRIDGE_H_ +#include "base/basictypes.h" + namespace net { class URLRequestContext; } // namespace net +namespace WebKit { +class WebSocketStreamHandle; +} // namespace WebKit + +namespace webkit_glue { +class WebSocketStreamHandleDelegate; +class WebSocketStreamHandleBridge; +} // namespace webkit_glue + class SimpleSocketStreamBridge { public: static void InitializeOnIOThread(net::URLRequestContext* request_context); static void Cleanup(); + static webkit_glue::WebSocketStreamHandleBridge* Create( + WebKit::WebSocketStreamHandle* handle, + webkit_glue::WebSocketStreamHandleDelegate* delegate); + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(SimpleSocketStreamBridge); }; #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_SOCKET_STREAM_BRIDGE_H_ diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index f6d3e5b..f649dfd 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -47,8 +47,6 @@ #include "webkit/glue/user_agent.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" -#include "webkit/plugins/npapi/plugin_list.h" -#include "webkit/plugins/webplugininfo.h" #include "webkit/tools/test_shell/notification_presenter.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_navigation_controller.h" @@ -626,29 +624,3 @@ WebKit::WebGeolocationClientMock* TestShell::geolocation_client_mock() { } return geolocation_client_mock_.get(); } - -namespace webkit_glue { - -void GetPlugins(bool refresh, - std::vector<webkit::WebPluginInfo>* plugins) { - if (refresh) - webkit::npapi::PluginList::Singleton()->RefreshPlugins(); - webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); - // Don't load the forked TestNetscapePlugIn in the chromium code, use - // the copy in webkit.org's repository instead. - const FilePath::StringType kPluginBlackList[] = { - FILE_PATH_LITERAL("npapi_layout_test_plugin.dll"), - FILE_PATH_LITERAL("WebKitTestNetscapePlugIn.plugin"), - FILE_PATH_LITERAL("libnpapi_layout_test_plugin.so"), - }; - for (int i = plugins->size() - 1; i >= 0; --i) { - webkit::WebPluginInfo plugin_info = plugins->at(i); - for (size_t j = 0; j < arraysize(kPluginBlackList); ++j) { - if (plugin_info.path.BaseName() == FilePath(kPluginBlackList[j])) { - plugins->erase(plugins->begin() + i); - } - } - } -} - -} // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index c2b37b1..ee921a8 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -32,6 +32,7 @@ #include "webkit/glue/webpreferences.h" #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/tools/test_shell/test_navigation_controller.h" +#include "webkit/tools/test_shell/test_shell_webkit_init.h" #include "webkit/tools/test_shell/test_webview_delegate.h" using WebKit::WebPoint; @@ -562,13 +563,11 @@ base::StringPiece TestShell::ResourceProvider(int key) { //----------------------------------------------------------------------------- -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestShellWebKitInit::GetLocalizedString(int message_id) { return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); } -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: resource_id = IDR_BROKENIMAGE_TESTSHELL; @@ -579,5 +578,3 @@ base::StringPiece GetDataResource(int resource_id) { } return TestShell::ResourceProvider(resource_id); } - -} // namespace webkit_glue diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index 55748c1..7c8c5b46 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -38,6 +38,7 @@ #include "webkit/tools/test_shell/resource.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_navigation_controller.h" +#include "webkit/tools/test_shell/test_shell_webkit_init.h" #include "webkit/tools/test_shell/test_webview_delegate.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -604,9 +605,7 @@ base::StringPiece TestShell::ResourceProvider(int key) { //----------------------------------------------------------------------------- -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestShellWebKitInit::GetLocalizedString(int message_id) { base::StringPiece res; if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { LOG(FATAL) << "failed to load webkit string with id " << message_id; @@ -630,7 +629,7 @@ string16 GetLocalizedString(int message_id) { return msg; } -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -686,6 +685,8 @@ base::StringPiece GetDataResource(int resource_id) { return base::StringPiece(); } +namespace webkit_glue { + bool DownloadUrl(const std::string& url, NSWindow* caller_window) { return false; } diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc index ca945d5..297b983 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.cc +++ b/webkit/tools/test_shell/test_shell_webkit_init.cc @@ -15,6 +15,9 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" #include "ui/gfx/gl/gl_bindings_skia_in_process.h" #include "v8/include/v8.h" +#include "webkit/plugins/npapi/plugin_list.h" +#include "webkit/plugins/webplugininfo.h" +#include "webkit/tools/test_shell/simple_socket_stream_bridge.h" #include "webkit/tools/test_shell/test_shell.h" #if defined(OS_WIN) @@ -301,3 +304,38 @@ WebKit::WebGraphicsContext3D* TestShellWebKitInit::createGraphicsContext3D() { return new webkit::gpu::WebGraphicsContext3DInProcessImpl( gfx::kNullPluginWindow, NULL); } + +void TestShellWebKitInit::GetPlugins( + bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { + if (refresh) + webkit::npapi::PluginList::Singleton()->RefreshPlugins(); + webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); + // Don't load the forked TestNetscapePlugIn in the chromium code, use + // the copy in webkit.org's repository instead. + const FilePath::StringType kPluginBlackList[] = { + FILE_PATH_LITERAL("npapi_layout_test_plugin.dll"), + FILE_PATH_LITERAL("WebKitTestNetscapePlugIn.plugin"), + FILE_PATH_LITERAL("libnpapi_layout_test_plugin.so"), + }; + for (int i = plugins->size() - 1; i >= 0; --i) { + webkit::WebPluginInfo plugin_info = plugins->at(i); + for (size_t j = 0; j < arraysize(kPluginBlackList); ++j) { + if (plugin_info.path.BaseName() == FilePath(kPluginBlackList[j])) { + plugins->erase(plugins->begin() + i); + } + } + } +} + +webkit_glue::ResourceLoaderBridge* +TestShellWebKitInit::CreateResourceLoader( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { + return SimpleResourceLoaderBridge::Create(request_info); +} + +webkit_glue::WebSocketStreamHandleBridge* +TestShellWebKitInit::CreateWebSocketBridge( + WebKit::WebSocketStreamHandle* handle, + webkit_glue::WebSocketStreamHandleDelegate* delegate) { + return SimpleSocketStreamBridge::Create(handle, delegate); +} diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 4063b94..9dbc70d 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -5,6 +5,7 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ +#include "base/compiler_specific.h" #include "base/utf_string_conversions.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" @@ -35,60 +36,62 @@ class TestShellWebKitInit : public webkit_glue::WebKitPlatformSupportImpl { explicit TestShellWebKitInit(bool layout_test_mode); virtual ~TestShellWebKitInit(); - virtual WebKit::WebMimeRegistry* mimeRegistry(); - virtual WebKit::WebClipboard* clipboard(); - virtual WebKit::WebFileUtilities* fileUtilities(); - virtual WebKit::WebSandboxSupport* sandboxSupport(); - virtual WebKit::WebCookieJar* cookieJar(); - virtual WebKit::WebBlobRegistry* blobRegistry(); - virtual WebKit::WebFileSystem* fileSystem(); - virtual bool sandboxEnabled(); + virtual WebKit::WebMimeRegistry* mimeRegistry() OVERRIDE; + virtual WebKit::WebClipboard* clipboard() OVERRIDE; + virtual WebKit::WebFileUtilities* fileUtilities() OVERRIDE; + virtual WebKit::WebSandboxSupport* sandboxSupport() OVERRIDE; + virtual WebKit::WebCookieJar* cookieJar() OVERRIDE; + virtual WebKit::WebBlobRegistry* blobRegistry() OVERRIDE; + virtual WebKit::WebFileSystem* fileSystem() OVERRIDE; + virtual bool sandboxEnabled() OVERRIDE; virtual WebKit::WebKitPlatformSupport::FileHandle databaseOpenFile( - const WebKit::WebString& vfs_file_name, int desired_flags); + const WebKit::WebString& vfs_file_name, int desired_flags) OVERRIDE; virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, - bool sync_dir); + bool sync_dir) OVERRIDE; virtual long databaseGetFileAttributes( - const WebKit::WebString& vfs_file_name); + const WebKit::WebString& vfs_file_name) OVERRIDE; virtual long long databaseGetFileSize( - const WebKit::WebString& vfs_file_name); + const WebKit::WebString& vfs_file_name) OVERRIDE; virtual long long databaseGetSpaceAvailableForOrigin( - const WebKit::WebString& origin_identifier); + const WebKit::WebString& origin_identifier) OVERRIDE; 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); + size_t length) OVERRIDE; + virtual bool isLinkVisited(unsigned long long linkHash) OVERRIDE; + virtual WebKit::WebMessagePortChannel* createMessagePortChannel() OVERRIDE; + virtual void prefetchHostName(const WebKit::WebString&) OVERRIDE; + virtual WebKit::WebData loadResource(const char* name) OVERRIDE; virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name); + WebKit::WebLocalizedString::Name name) OVERRIDE; virtual WebKit::WebString queryLocalizedString( - WebKit::WebLocalizedString::Name name, const WebKit::WebString& value); + WebKit::WebLocalizedString::Name name, + const WebKit::WebString& value) OVERRIDE; virtual WebKit::WebString queryLocalizedString( WebKit::WebLocalizedString::Name name, - const WebKit::WebString& value1, const WebKit::WebString& value2); + const WebKit::WebString& value1, + const WebKit::WebString& value2) OVERRIDE; - virtual WebKit::WebString defaultLocale(); + virtual WebKit::WebString defaultLocale() OVERRIDE; virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( - const WebKit::WebString& path, unsigned quota); + const WebKit::WebString& path, unsigned quota) OVERRIDE; virtual 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::WebIDBFactory* idbFactory(); + bool is_local_storage) OVERRIDE; + virtual WebKit::WebIDBFactory* idbFactory() OVERRIDE; virtual void createIDBKeysFromSerializedValuesAndKeyPath( const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values, const WebKit::WebString& keyPath, - WebKit::WebVector<WebKit::WebIDBKey>& keys_out); + WebKit::WebVector<WebKit::WebIDBKey>& keys_out) OVERRIDE; virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue( const WebKit::WebIDBKey& key, const WebKit::WebSerializedScriptValue& value, - const WebKit::WebString& keyPath); + const WebKit::WebString& keyPath) OVERRIDE; #if defined(OS_WIN) @@ -97,13 +100,24 @@ class TestShellWebKitInit : public webkit_glue::WebKitPlatformSupportImpl { engine : WebKitPlatformSupportImpl::themeEngine(); } - virtual WebKit::WebThemeEngine *themeEngine() { + virtual WebKit::WebThemeEngine *themeEngine() OVERRIDE { return active_theme_engine_; } #endif - virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository(); - virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(); + virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() OVERRIDE; + virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE; + + virtual string16 GetLocalizedString(int message_id) OVERRIDE; + virtual base::StringPiece GetDataResource(int resource_id) OVERRIDE; + virtual void GetPlugins(bool refresh, + std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; + virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) + OVERRIDE; + virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketBridge( + WebKit::WebSocketStreamHandle* handle, + webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE; private: scoped_ptr<webkit_glue::SimpleWebMimeRegistryImpl> mime_registry_; diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index fa72f4f..7a15880 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -36,6 +36,7 @@ #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell_devtools_agent.h" #include "webkit/tools/test_shell/test_shell_switches.h" +#include "webkit/tools/test_shell/test_shell_webkit_init.h" #include "webkit/tools/test_shell/test_webview_delegate.h" using WebKit::WebWidget; @@ -657,12 +658,7 @@ base::StringPiece TestShell::ResourceProvider(int key) { } -///////////////////////////////////////////////////////////////////////////// -// WebKit glue functions - -namespace webkit_glue { - -string16 GetLocalizedString(int message_id) { +string16 TestShellWebKitInit::GetLocalizedString(int message_id) { wchar_t localized[MAX_LOADSTRING]; int length = LoadString(GetModuleHandle(NULL), message_id, localized, MAX_LOADSTRING); @@ -674,7 +670,7 @@ string16 GetLocalizedString(int message_id) { } // TODO(tc): Convert this to using resources from test_shell.rc. -base::StringPiece GetDataResource(int resource_id) { +base::StringPiece TestShellWebKitInit::GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -727,6 +723,11 @@ base::StringPiece GetDataResource(int resource_id) { return base::StringPiece(); } +///////////////////////////////////////////////////////////////////////////// +// WebKit glue functions + +namespace webkit_glue { + bool EnsureFontLoaded(HFONT font) { return true; } |