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/tools | |
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/tools')
-rw-r--r-- | webkit/tools/test_shell/simple_resource_loader_bridge.cc | 18 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_resource_loader_bridge.h | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_socket_stream_bridge.cc | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_socket_stream_bridge.h | 17 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 28 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_mac.mm | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.cc | 38 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 74 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_win.cc | 15 |
10 files changed, 128 insertions, 93 deletions
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; } |