diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 23:37:55 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 23:37:55 +0000 |
commit | 8d86fce009d9dc39300a5ec9b0559ce17ff0e44e (patch) | |
tree | 74d2f7779a00c20f7ca9ef5e88852b01f4f4619d /webkit | |
parent | 5c935c135c544163d9b3923fd9e6d612cedf05c1 (diff) | |
download | chromium_src-8d86fce009d9dc39300a5ec9b0559ce17ff0e44e.zip chromium_src-8d86fce009d9dc39300a5ec9b0559ce17ff0e44e.tar.gz chromium_src-8d86fce009d9dc39300a5ec9b0559ce17ff0e44e.tar.bz2 |
Chrome side to implement WebMimeRegistry.
R=dglazkov
Review URL: http://codereview.chromium.org/27222
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/SConscript | 3 | ||||
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 51 | ||||
-rw-r--r-- | webkit/glue/glue.vcproj | 20 | ||||
-rw-r--r-- | webkit/glue/glue_util.cc | 19 | ||||
-rw-r--r-- | webkit/glue/glue_util.h | 7 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_stream.cc | 4 | ||||
-rw-r--r-- | webkit/glue/simple_webmimeregistry_impl.cc | 61 | ||||
-rw-r--r-- | webkit/glue/simple_webmimeregistry_impl.h | 26 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 15 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.cc (renamed from webkit/glue/webkit_client_impl.cc) | 6 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.h (renamed from webkit/glue/webkit_client_impl.h) | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj | 15 | ||||
-rw-r--r-- | webkit/tools/test_shell/run_all_tests.cc | 4 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_shell.cc | 15 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.vcproj | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 12 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 35 | ||||
-rw-r--r-- | webkit/webkit.gyp | 7 | ||||
-rw-r--r-- | webkit/webkit.xcodeproj/project.pbxproj | 26 |
19 files changed, 216 insertions, 117 deletions
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript index 375b8de..555f657 100644 --- a/webkit/glue/SConscript +++ b/webkit/glue/SConscript @@ -78,6 +78,7 @@ input_files = [ 'resource_handle_impl.cc', 'resource_loader_bridge.cc', 'searchable_form_data.cc', + 'simple_webmimeregistry_impl.cc', 'stacking_order_iterator.cc', 'webclipboard_impl.cc', 'webcursor.cc', @@ -87,7 +88,7 @@ input_files = [ 'webframe_impl.cc', 'webframeloaderclient_impl.cc', 'webhistoryitem_impl.cc', - 'webkit_client_impl.cc', + 'webkitclient_impl.cc', 'webkit_glue.cc', 'webmediaplayer_impl.cc', 'webplugin_delegate.cc', diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index aeb5f40..4fb80c4 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -34,7 +34,6 @@ #include "base/trace_event.h" #include "build/build_config.h" #include "googleurl/src/url_util.h" -#include "net/base/mime_util.h" #include "skia/ext/skia_utils_win.h" #if USE(V8) #include <v8.h> @@ -142,56 +141,6 @@ bool ChromiumBridge::layoutTestMode() { return webkit_glue::IsLayoutTestMode(); } -// MimeType ------------------------------------------------------------------- - -bool ChromiumBridge::isSupportedImageMIMEType(const char* mime_type) { - return net::IsSupportedImageMimeType(mime_type); -} - -bool ChromiumBridge::isSupportedJavascriptMIMEType(const char* mime_type) { - return net::IsSupportedJavascriptMimeType(mime_type); -} - -bool ChromiumBridge::isSupportedNonImageMIMEType(const char* mime_type) { - return net::IsSupportedNonImageMimeType(mime_type); -} - -bool ChromiumBridge::matchesMIMEType(const String& pattern, - const String& type) { - return net::MatchesMimeType(webkit_glue::StringToStdString(pattern), - webkit_glue::StringToStdString(type)); -} - -String ChromiumBridge::mimeTypeForExtension(const String& ext) { - if (ext.isEmpty()) - return String(); - - std::string type; - webkit_glue::GetMimeTypeFromExtension( - webkit_glue::StringToFilePathString(ext), &type); - return webkit_glue::StdStringToString(type); -} - -String ChromiumBridge::mimeTypeFromFile(const String& file_path) { - if (file_path.isEmpty()) - return String(); - - std::string type; - webkit_glue::GetMimeTypeFromFile( - FilePath(webkit_glue::StringToFilePathString(file_path)), &type); - return webkit_glue::StdStringToString(type); -} - -String ChromiumBridge::preferredExtensionForMIMEType(const String& mime_type) { - if (mime_type.isEmpty()) - return String(); - - FilePath::StringType stdext; - webkit_glue::GetPreferredExtensionForMimeType( - webkit_glue::StringToStdString(mime_type), &stdext); - return webkit_glue::FilePathStringToString(stdext); -} - // Plugin --------------------------------------------------------------------- bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) { diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj index 6dae503..bb0d3e3 100644 --- a/webkit/glue/glue.vcproj +++ b/webkit/glue/glue.vcproj @@ -525,6 +525,14 @@ >
</File>
<File
+ RelativePath=".\simple_webmimeregistry_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\simple_webmimeregistry_impl.h"
+ >
+ </File>
+ <File
RelativePath=".\stacking_order_iterator.cc"
>
</File>
@@ -609,27 +617,27 @@ >
</File>
<File
- RelativePath=".\webinputevent_win.cc"
+ RelativePath=".\webinputevent_utils.cc"
>
</File>
<File
- RelativePath=".\webkit_client_impl.cc"
+ RelativePath=".\webkit_glue.cc"
>
</File>
<File
- RelativePath=".\webkit_client_impl.h"
+ RelativePath=".\webkit_glue.h"
>
</File>
<File
- RelativePath=".\webkit_glue.cc"
+ RelativePath=".\webkit_glue_win.cc"
>
</File>
<File
- RelativePath=".\webkit_glue.h"
+ RelativePath=".\webkitclient_impl.cc"
>
</File>
<File
- RelativePath=".\webkit_glue_win.cc"
+ RelativePath=".\webkitclient_impl.h"
>
</File>
<File
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc index 113d413..359eb40 100644 --- a/webkit/glue/glue_util.cc +++ b/webkit/glue/glue_util.cc @@ -16,8 +16,9 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "KURL.h" MSVC_POP_WARNING(); -#undef LOG +#include "WebString.h" +#undef LOG #include "base/compiler_specific.h" #include "base/gfx/rect.h" #include "base/string_piece.h" @@ -98,6 +99,22 @@ WebCore::String FilePathStringToString(const FilePath::StringType& str) { #endif } +FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str) { +#if defined(OS_POSIX) + return base::SysWideToNativeMB(UTF16ToWide(str)); +#elif defined(OS_WIN) + return UTF16ToWide(str); +#endif +} + +WebKit::WebString FilePathStringToWebString(const FilePath::StringType& str) { +#if defined(OS_POSIX) + return WideToUTF16(base::SysNativeMBToWide(str)); +#elif defined(OS_WIN) + return WideToUTF16(str); +#endif +} + // URL conversions ------------------------------------------------------------- GURL KURLToGURL(const WebCore::KURL& url) { diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h index 576ec34..adbaffc 100644 --- a/webkit/glue/glue_util.h +++ b/webkit/glue/glue_util.h @@ -17,6 +17,10 @@ class KURL; class String; } +namespace WebKit { +class WebString; +} + namespace gfx { class Rect; } @@ -46,6 +50,9 @@ WebCore::String StdStringToString(const std::string& str); FilePath::StringType StringToFilePathString(const WebCore::String& str); WebCore::String FilePathStringToString(const FilePath::StringType& str); +FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str); +WebKit::WebString FilePathStringToWebString(const FilePath::StringType& str); + GURL KURLToGURL(const WebCore::KURL& url); WebCore::KURL GURLToKURL(const GURL& url); GURL StringToGURL(const WebCore::String& spec); diff --git a/webkit/glue/plugins/plugin_stream.cc b/webkit/glue/plugins/plugin_stream.cc index af7fbe9..e66182b 100644 --- a/webkit/glue/plugins/plugin_stream.cc +++ b/webkit/glue/plugins/plugin_stream.cc @@ -12,8 +12,8 @@ #include "base/string_util.h" #include "base/message_loop.h" +#include "net/base/mime_util.h" #include "webkit/glue/plugins/plugin_instance.h" -#include "webkit/glue/webkit_glue.h" #include "googleurl/src/gurl.h" namespace NPAPI { @@ -57,7 +57,7 @@ bool PluginStream::Open(const std::string &mime_type, #elif defined(OS_POSIX) FilePath path(gurl.path()); #endif - if (webkit_glue::GetMimeTypeFromFile(path, &temp_mime_type)) + if (net::GetMimeTypeFromFile(path, &temp_mime_type)) char_mime_type = temp_mime_type.c_str(); } diff --git a/webkit/glue/simple_webmimeregistry_impl.cc b/webkit/glue/simple_webmimeregistry_impl.cc new file mode 100644 index 0000000..a662958 --- /dev/null +++ b/webkit/glue/simple_webmimeregistry_impl.cc @@ -0,0 +1,61 @@ +// Copyright (c) 2009 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. + +// TODO(darin): This include should not be necessary, but for some reason the +// Mac build requires it. +#include "config.h" + +#include "webkit/glue/simple_webmimeregistry_impl.h" + +#include "WebString.h" + +#include "base/string_util.h" +#include "base/sys_string_conversions.h" +#include "net/base/mime_util.h" +#include "webkit/glue/glue_util.h" + +using WebKit::WebString; + +namespace webkit_glue { + +bool SimpleWebMimeRegistryImpl::supportsImageMIMEType( + const WebString& mime_type) { + return net::IsSupportedImageMimeType(UTF16ToASCII(mime_type).c_str()); +} + +bool SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( + const WebString& mime_type) { + return net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str()); +} + +bool SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( + const WebString& mime_type) { + return net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str()); +} + +WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension( + const WebString& file_extension) { + std::string mime_type; + net::GetMimeTypeFromExtension( + WebStringToFilePathString(file_extension), &mime_type); + return ASCIIToUTF16(mime_type); +} + +WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( + const WebString& file_path) { + std::string mime_type; + net::GetMimeTypeFromFile( + FilePath(WebStringToFilePathString(file_path)), &mime_type); + return ASCIIToUTF16(mime_type); +} + +WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( + const WebString& mime_type) { + FilePath::StringType file_extension; + net::GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type), + &file_extension); + return FilePathStringToWebString(file_extension); +} + +} // namespace webkit_glue diff --git a/webkit/glue/simple_webmimeregistry_impl.h b/webkit/glue/simple_webmimeregistry_impl.h new file mode 100644 index 0000000..778dee0 --- /dev/null +++ b/webkit/glue/simple_webmimeregistry_impl.h @@ -0,0 +1,26 @@ +// Copyright (c) 2009 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 WEBMIMEREGISTRY_IMPL_H_ +#define WEBMIMEREGISTRY_IMPL_H_ + +#include "WebMimeRegistry.h" + +namespace webkit_glue { + +class SimpleWebMimeRegistryImpl : public WebKit::WebMimeRegistry { + public: + // WebMimeRegistry methods: + virtual bool supportsImageMIMEType(const WebKit::WebString&); + virtual bool supportsJavaScriptMIMEType(const WebKit::WebString&); + virtual bool supportsNonImageMIMEType(const WebKit::WebString&); + virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); + virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); + virtual WebKit::WebString preferredExtensionForMIMEType( + const WebKit::WebString&); +}; + +} // namespace webkit_glue + +#endif // WEBMIMEREGISTRY_IMPL_H_ diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index aca3250..579ca5d 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -162,21 +162,6 @@ void PrecacheUrl(const char16* url, int url_length); // This function is called to add a line to the application's log file. void AppendToLog(const char* filename, int line, const char* message); -// Get the mime type (if any) that is associated with the given file extension. -// Returns true if a corresponding mime type exists. -bool GetMimeTypeFromExtension(const FilePath::StringType& ext, - std::string* mime_type); - -// Get the mime type (if any) that is associated with the given file. -// Returns true if a corresponding mime type exists. -bool GetMimeTypeFromFile(const FilePath& file_path, std::string* mime_type); - -// Get the preferred extension (if any) associated with the given mime type. -// Returns true if a corresponding file extension exists. The extension does -// not include a prefixed dot, ex "html". -bool GetPreferredExtensionForMimeType(const std::string& mime_type, - FilePath::StringType* ext); - // Sets a cookie string for the given URL. The policy_url argument indicates // the URL of the topmost frame, which may be useful for determining whether or // not to allow this cookie setting. NOTE: the cookie string is a standard diff --git a/webkit/glue/webkit_client_impl.cc b/webkit/glue/webkitclient_impl.cc index 2389a71..a243716 100644 --- a/webkit/glue/webkit_client_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -6,14 +6,12 @@ // Mac build requires it. #include "config.h" -#include "webkit/glue/webkit_client_impl.h" +#include "webkit/glue/webkitclient_impl.h" namespace webkit_glue { WebKit::WebClipboard* WebKitClientImpl::clipboard() { - if (!clipboard_.get()) - clipboard_.reset(new WebClipboardImpl()); - return clipboard_.get(); + return &clipboard_; } } // namespace webkit_glue diff --git a/webkit/glue/webkit_client_impl.h b/webkit/glue/webkitclient_impl.h index e2ff98a..481a5fe 100644 --- a/webkit/glue/webkit_client_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -16,9 +16,10 @@ class WebKitClientImpl : public WebKit::WebKitClient { public: // WebKitClient methods: virtual WebKit::WebClipboard* clipboard(); + virtual WebKit::WebMimeRegistry* mimeRegistry() = 0; private: - scoped_ptr<WebClipboardImpl> clipboard_; + WebClipboardImpl clipboard_; }; } // namespace webkit_glue diff --git a/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj b/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj index 6f841f5b..10ce2f9 100644 --- a/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj +++ b/webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj @@ -715,6 +715,13 @@ remoteGlobalIDString = 937A16010F53326C003E8D2D; remoteInfo = webkit; }; + 938D0FF30F573E28009F1128 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 829E2E250DBE7DE200819EBF /* webkit.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 937A15B60F53326C003E8D2D /* webkit */; + remoteInfo = webkit; + }; E4506A370EF020EE003BE099 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; @@ -796,6 +803,7 @@ 82F39A1C0E7EF85C00785E15 /* gtest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = gtest.xcodeproj; path = testing/gtest.xcodeproj; sourceTree = "<group>"; }; 82F39CFF0E7EF95A00785E15 /* modp_b64.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = modp_b64.xcodeproj; path = third_party/modp_b64/modp_b64.xcodeproj; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 938D0FAF0F5737AC009F1128 /* test_shell_webkit_init.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = test_shell_webkit_init.h; sourceTree = "<group>"; }; 93AF4F300EFAFE2C0073C62D /* BMPImageDecoder_unittest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BMPImageDecoder_unittest.cpp; path = ../../webcore_unit_tests/BMPImageDecoder_unittest.cpp; sourceTree = SOURCE_ROOT; }; 93AF4F310EFAFE2C0073C62D /* GKURL_unittest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GKURL_unittest.cpp; path = ../../webcore_unit_tests/GKURL_unittest.cpp; sourceTree = SOURCE_ROOT; }; 93AF4F320EFAFE2C0073C62D /* ICOImageDecoder_unittest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ICOImageDecoder_unittest.cpp; path = ../../webcore_unit_tests/ICOImageDecoder_unittest.cpp; sourceTree = SOURCE_ROOT; }; @@ -1313,6 +1321,7 @@ ABCF253B0DB8436B00099567 /* test_shell_switches.h */, AB8A786E0DC5544D005C27B8 /* test_shell_test.h */, AB8A78560DC553C7005C27B8 /* test_shell_test.cc */, + 938D0FAF0F5737AC009F1128 /* test_shell_webkit_init.h */, F479F6560F2F8319000C19D4 /* test_shell_win.cc */, E44662060ECCD652000B9316 /* test_webview_delegate.cc */, AB8A78590DC553D7005C27B8 /* test_webview_delegate.h */, @@ -1426,6 +1435,7 @@ 82F39D4C0E7EFDB500785E15 /* PBXTargetDependency */, 82F39D4E0E7EFDB500785E15 /* PBXTargetDependency */, 82F39CF70E7EF91900785E15 /* PBXTargetDependency */, + 938D0FF40F573E28009F1128 /* PBXTargetDependency */, ); name = TestShell; productInstallPath = "$(HOME)/Applications"; @@ -2154,6 +2164,11 @@ name = v8; targetProxy = 82F39D4D0E7EFDB500785E15 /* PBXContainerItemProxy */; }; + 938D0FF40F573E28009F1128 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = webkit; + targetProxy = 938D0FF30F573E28009F1128 /* PBXContainerItemProxy */; + }; E4506A380EF020EE003BE099 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = E45067A70EEF2776003BE099 /* test_shell_tests */; diff --git a/webkit/tools/test_shell/run_all_tests.cc b/webkit/tools/test_shell/run_all_tests.cc index 579338b..df6a1ae 100644 --- a/webkit/tools/test_shell/run_all_tests.cc +++ b/webkit/tools/test_shell/run_all_tests.cc @@ -23,6 +23,7 @@ #include "webkit/tools/test_shell/test_shell.h" #include "webkit/tools/test_shell/test_shell_platform_delegate.h" #include "webkit/tools/test_shell/test_shell_test.h" +#include "webkit/tools/test_shell/test_shell_webkit_init.h" #include "testing/gtest/include/gtest/gtest.h" const char* TestShellTest::kJavascriptDelayExitScript = @@ -61,7 +62,8 @@ int main(int argc, char* argv[]) { // request than automatically quit. TestShell::InitializeTestShell(true); - webkit_glue::InitializeForTesting(); + // Initialize WebKit for this scope. + TestShellWebKitInit test_shell_webkit_init(true); // Allocate a message loop for this thread. Although it is not used // directly, its constructor sets up some necessary state. diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 086c305..66a9fc6 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -559,21 +559,6 @@ void AppendToLog(const char* file, int line, const char* msg) { logging::LogMessage(file, line).stream() << msg; } -bool GetMimeTypeFromExtension(const FilePath::StringType& ext, - std::string *mime_type) { - return net::GetMimeTypeFromExtension(ext, mime_type); -} - -bool GetMimeTypeFromFile(const FilePath& file_path, - std::string *mime_type) { - return net::GetMimeTypeFromFile(file_path, mime_type); -} - -bool GetPreferredExtensionForMimeType(const std::string& mime_type, - FilePath::StringType* ext) { - return net::GetPreferredExtensionForMimeType(mime_type, ext); -} - #if defined(OS_MACOSX) SkBitmap* #else diff --git a/webkit/tools/test_shell/test_shell.vcproj b/webkit/tools/test_shell/test_shell.vcproj index 0a02735..6659101 100644 --- a/webkit/tools/test_shell/test_shell.vcproj +++ b/webkit/tools/test_shell/test_shell.vcproj @@ -294,6 +294,10 @@ > </File> <File + RelativePath=".\test_shell_webkit_init.h" + > + </File> + <File RelativePath=".\test_shell_win.cc" > </File> diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 795b17b..d042226 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -25,7 +25,6 @@ #include "net/http/http_cache.h" #include "net/base/ssl_test_util.h" #include "net/url_request/url_request_context.h" -#include "webkit/glue/webkit_client_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/window_open_disposition.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" @@ -33,6 +32,7 @@ #include "webkit/tools/test_shell/test_shell_platform_delegate.h" #include "webkit/tools/test_shell/test_shell_request_context.h" #include "webkit/tools/test_shell/test_shell_switches.h" +#include "webkit/tools/test_shell/test_shell_webkit_init.h" #include "WebKit.h" @@ -88,17 +88,13 @@ int main(int argc, char* argv[]) { layout_test_mode, enable_gp_fault_error_box); - webkit_glue::WebKitClientImpl webkit_client_impl; - WebKit::initialize(&webkit_client_impl); - - // Set this early before we start using WebCore. - webkit_glue::SetLayoutTestMode(layout_test_mode); + // Initialize WebKit for this scope. + TestShellWebKitInit test_shell_webkit_init(layout_test_mode); // Suppress abort message in v8 library in debugging mode. // V8 calls abort() when it hits assertion errors. - if (suppress_error_dialogs) { + if (suppress_error_dialogs) platform.SuppressErrorReporting(); - } if (parsed_command_line.HasSwitch(test_shell::kEnableTracing)) base::TraceLog::StartTracing(); diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h new file mode 100644 index 0000000..a10102a --- /dev/null +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -0,0 +1,35 @@ +// Copyright (c) 2009 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_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ +#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ + +#include "webkit/glue/simple_webmimeregistry_impl.h" +#include "webkit/glue/webkit_glue.h" +#include "webkit/glue/webkitclient_impl.h" + +#include "WebKit.h" + +class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { + public: + TestShellWebKitInit(bool layout_test_mode) { + WebKit::initialize(this); + + // TODO(darin): This should eventually be a property of WebKitClientImpl. + webkit_glue::SetLayoutTestMode(layout_test_mode); + } + + ~TestShellWebKitInit() { + WebKit::shutdown(); + } + + virtual WebKit::WebMimeRegistry* mimeRegistry() { + return &mime_registry_; + } + + private: + webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; +}; + +#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 3533faf..69a5cc5 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4039,6 +4039,7 @@ '../third_party/WebKit/WebKit/chromium/public/WebImage.h', '../third_party/WebKit/WebKit/chromium/public/WebKit.h', '../third_party/WebKit/WebKit/chromium/public/WebKitClient.h', + '../third_party/WebKit/WebKit/chromium/public/WebMimeRegistry.h', '../third_party/WebKit/WebKit/chromium/public/WebPoint.h', '../third_party/WebKit/WebKit/chromium/public/WebRect.h', '../third_party/WebKit/WebKit/chromium/public/WebSize.h', @@ -4233,6 +4234,8 @@ 'glue/searchable_form_data.cc', 'glue/searchable_form_data.h', 'glue/simple_clipboard_impl.cc', + 'glue/simple_webmimeregistry_impl.cc', + 'glue/simple_webmimeregistry_impl.h', 'glue/stacking_order_iterator.cc', 'glue/stacking_order_iterator.h', 'glue/tools_proxy.h', @@ -4266,8 +4269,8 @@ 'glue/webinputevent_linux.cc', 'glue/webinputevent_mac.mm', 'glue/webinputevent_win.cc', - 'glue/webkit_client_impl.cc', - 'glue/webkit_client_impl.h', + 'glue/webkitclient_impl.cc', + 'glue/webkitclient_impl.h', 'glue/webkit_glue.cc', 'glue/webkit_glue.h', 'glue/webkit_glue_gtk.cc', diff --git a/webkit/webkit.xcodeproj/project.pbxproj b/webkit/webkit.xcodeproj/project.pbxproj index b959e0f..1e03a77 100644 --- a/webkit/webkit.xcodeproj/project.pbxproj +++ b/webkit/webkit.xcodeproj/project.pbxproj @@ -1319,7 +1319,8 @@ 9389E8310F55C4550035E7D0 /* WebKit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9389E82C0F55C4550035E7D0 /* WebKit.cpp */; }; 9389E8320F55C4550035E7D0 /* WebURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9389E82E0F55C4550035E7D0 /* WebURL.cpp */; }; 9389E8370F55C4810035E7D0 /* webclipboard_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9389E8330F55C4810035E7D0 /* webclipboard_impl.cc */; }; - 9389E8380F55C4810035E7D0 /* webkit_client_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9389E8350F55C4810035E7D0 /* webkit_client_impl.cc */; }; + 938D0F750F573770009F1128 /* simple_webmimeregistry_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 938D0F710F573770009F1128 /* simple_webmimeregistry_impl.cc */; }; + 938D0F760F573770009F1128 /* webkitclient_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 938D0F730F573770009F1128 /* webkitclient_impl.cc */; }; 93AF52490F001CAB0073C62D /* media_player_private_impl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93AF52480F001CAB0073C62D /* media_player_private_impl.cc */; }; 93AF57990F0198CD0073C62D /* webkit_glue_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93AF57980F0198CD0073C62D /* webkit_glue_mac.mm */; }; A5779DD6BC0DA17AB7DE63D4 /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 715E874BCC05E0A3DD5E5D8F /* GCController.cpp */; }; @@ -4138,8 +4139,11 @@ 9389E82E0F55C4550035E7D0 /* WebURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebURL.cpp; path = ../third_party/WebKit/WebKit/chromium/src/WebURL.cpp; sourceTree = SOURCE_ROOT; }; 9389E8330F55C4810035E7D0 /* webclipboard_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = webclipboard_impl.cc; sourceTree = "<group>"; }; 9389E8340F55C4810035E7D0 /* webclipboard_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = webclipboard_impl.h; sourceTree = "<group>"; }; - 9389E8350F55C4810035E7D0 /* webkit_client_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = webkit_client_impl.cc; sourceTree = "<group>"; }; - 9389E8360F55C4810035E7D0 /* webkit_client_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = webkit_client_impl.h; sourceTree = "<group>"; }; + 938D0F700F573741009F1128 /* WebMimeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebMimeRegistry.h; path = ../third_party/WebKit/WebKit/chromium/public/WebMimeRegistry.h; sourceTree = SOURCE_ROOT; }; + 938D0F710F573770009F1128 /* simple_webmimeregistry_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simple_webmimeregistry_impl.cc; sourceTree = "<group>"; }; + 938D0F720F573770009F1128 /* simple_webmimeregistry_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simple_webmimeregistry_impl.h; sourceTree = "<group>"; }; + 938D0F730F573770009F1128 /* webkitclient_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = webkitclient_impl.cc; sourceTree = "<group>"; }; + 938D0F740F573770009F1128 /* webkitclient_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = webkitclient_impl.h; sourceTree = "<group>"; }; 93AF4D040EFAF0090073C62D /* ScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollView.cpp; sourceTree = "<group>"; }; 93AF52480F001CAB0073C62D /* media_player_private_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = media_player_private_impl.cc; sourceTree = "<group>"; }; 93AF525D0F002E930073C62D /* KURLGoogle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KURLGoogle.cpp; sourceTree = "<group>"; }; @@ -7711,8 +7715,8 @@ 825405080D92E3DA0006B936 /* dragclient_impl.h */, 825405090D92E3DA0006B936 /* editor_client_impl.cc */, 8254050A0D92E3DA0006B936 /* editor_client_impl.h */, - E4506C0E0EF03A2F003BE099 /* entity_map.h */, E4506C0F0EF03A2F003BE099 /* entity_map.cc */, + E4506C0E0EF03A2F003BE099 /* entity_map.h */, 8254050B0D92E3DA0006B936 /* event_conversion.cc */, 8254050C0D92E3DA0006B936 /* event_conversion.h */, 8254050F0D92E3DA0006B936 /* feed_preview.cc */, @@ -7752,6 +7756,8 @@ 8254052C0D92E3DA0006B936 /* searchable_form_data.cc */, 8254052D0D92E3DA0006B936 /* searchable_form_data.h */, 8254052E0D92E3DA0006B936 /* simple_clipboard_impl.cc */, + 938D0F710F573770009F1128 /* simple_webmimeregistry_impl.cc */, + 938D0F720F573770009F1128 /* simple_webmimeregistry_impl.h */, AB9552AD0F37AC0B0015C8FB /* stacking_order_iterator.cc */, 8254052F0D92E3DA0006B936 /* unittest_test_server.h */, 9389E8330F55C4810035E7D0 /* webclipboard_impl.cc */, @@ -7779,12 +7785,12 @@ 825405420D92E3DA0006B936 /* webhistoryitem_impl.h */, 825405450D92E3DA0006B936 /* webinputevent.h */, 825405440D92E3DA0006B936 /* webinputevent_mac.mm */, - 9389E8350F55C4810035E7D0 /* webkit_client_impl.cc */, - 9389E8360F55C4810035E7D0 /* webkit_client_impl.h */, - 825405470D92E3DB0006B936 /* webkit_glue.h */, 825405460D92E3DA0006B936 /* webkit_glue.cc */, + 825405470D92E3DB0006B936 /* webkit_glue.h */, 93AF57980F0198CD0073C62D /* webkit_glue_mac.mm */, 8254054A0D92E3DB0006B936 /* webkit_strings.grd */, + 938D0F730F573770009F1128 /* webkitclient_impl.cc */, + 938D0F740F573770009F1128 /* webkitclient_impl.h */, 8254054F0D92E3DB0006B936 /* webplugin.h */, 1459AC310DEBF6A597167F45 /* webplugin_delegate.cc */, 8254054B0D92E3DB0006B936 /* webplugin_delegate.h */, @@ -7863,6 +7869,7 @@ 937A15B10F5331F7003E8D2D /* public */ = { isa = PBXGroup; children = ( + 938D0F700F573741009F1128 /* WebMimeRegistry.h */, 9389E81F0F55C4110035E7D0 /* WebClipboard.h */, 937A15B40F533249003E8D2D /* WebCommon.h */, 9389E8200F55C4110035E7D0 /* WebCString.h */, @@ -9791,7 +9798,8 @@ E45626F30E268F03005E4685 /* webwidget_impl.cc in Sources */, ABF923090F3A388C009B64EC /* webplugin_delegate_impl_mac.cc in Sources */, 9389E8370F55C4810035E7D0 /* webclipboard_impl.cc in Sources */, - 9389E8380F55C4810035E7D0 /* webkit_client_impl.cc in Sources */, + 938D0F750F573770009F1128 /* simple_webmimeregistry_impl.cc in Sources */, + 938D0F760F573770009F1128 /* webkitclient_impl.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -10410,7 +10418,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7BF884300E71C120000BAF8A /* staticlib.xcconfig */; buildSettings = { - GCC_PREFIX_HEADER = ../third_party/WebKit/WebCore/WebCorePrefix.h; HEADER_SEARCH_PATHS = ( "$(HEADER_SEARCH_PATHS)", "$(CONFIGURATION_TEMP_DIR)/generated/DerivedSources/v8/bindings", @@ -10427,7 +10434,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7BF884300E71C120000BAF8A /* staticlib.xcconfig */; buildSettings = { - GCC_PREFIX_HEADER = ../third_party/WebKit/WebCore/WebCorePrefix.h; HEADER_SEARCH_PATHS = ( "$(HEADER_SEARCH_PATHS)", "$(CONFIGURATION_TEMP_DIR)/generated/DerivedSources/v8/bindings", |