diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 17:27:05 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 17:27:05 +0000 |
commit | cf3c5e9186dbf271d23dca43dfb0aff8d8ce4068 (patch) | |
tree | 9ffb42c6557ccd3e2babb30f2b5a9ce08ca712f3 /webkit/glue/simple_webmimeregistry_impl.cc | |
parent | 5b5eec43260959632d2bd2efe6422207a6c2cad6 (diff) | |
download | chromium_src-cf3c5e9186dbf271d23dca43dfb0aff8d8ce4068.zip chromium_src-cf3c5e9186dbf271d23dca43dfb0aff8d8ce4068.tar.gz chromium_src-cf3c5e9186dbf271d23dca43dfb0aff8d8ce4068.tar.bz2 |
Fix a DCHECK we hit when a mime type isn't ASCII.
I have a layout test for this, but Tony says I should send it upstream
so that will be a separate commit.
BUG=17958
Review URL: http://codereview.chromium.org/160363
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/simple_webmimeregistry_impl.cc')
-rw-r--r-- | webkit/glue/simple_webmimeregistry_impl.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/webkit/glue/simple_webmimeregistry_impl.cc b/webkit/glue/simple_webmimeregistry_impl.cc index 29296ff..a2b792d 100644 --- a/webkit/glue/simple_webmimeregistry_impl.cc +++ b/webkit/glue/simple_webmimeregistry_impl.cc @@ -14,18 +14,30 @@ using WebKit::WebString; using WebKit::WebMimeRegistry; +namespace { + +// Convert a WebString to ASCII, falling back on an empty string in the case +// of a non-ASCII string. +std::string AsASCII(const WebString& string) { + if (!IsStringASCII(string)) + return EmptyString(); + return UTF16ToASCII(string); +} + +} // namespace + namespace webkit_glue { WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( const WebString& mime_type) { - if (!net::IsSupportedImageMimeType(UTF16ToASCII(mime_type).c_str())) + if (!net::IsSupportedImageMimeType(AsASCII(mime_type).c_str())) return WebMimeRegistry::IsNotSupported; return WebMimeRegistry::IsSupported; } WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( const WebString& mime_type) { - if (!net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str())) + if (!net::IsSupportedJavascriptMimeType(AsASCII(mime_type).c_str())) return WebMimeRegistry::IsNotSupported; return WebMimeRegistry::IsSupported; } @@ -33,12 +45,12 @@ WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsJavaScriptMIMET WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( const WebString& mime_type, const WebString& codecs) { // Not supporting the container is a flat-out no. - if (!net::IsSupportedMediaMimeType(UTF16ToASCII(mime_type).c_str())) + if (!net::IsSupportedMediaMimeType(AsASCII(mime_type).c_str())) return IsNotSupported; // If we don't recognize the codec, it's possible we support it. std::vector<std::string> parsed_codecs; - net::ParseCodecString(UTF16ToASCII(codecs).c_str(), &parsed_codecs); + net::ParseCodecString(AsASCII(codecs).c_str(), &parsed_codecs); if (!net::AreSupportedMediaCodecs(parsed_codecs)) return MayBeSupported; @@ -48,7 +60,7 @@ WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( const WebString& mime_type) { - if (!net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str())) + if (!net::IsSupportedNonImageMimeType(AsASCII(mime_type).c_str())) return WebMimeRegistry::IsNotSupported; return WebMimeRegistry::IsSupported; } @@ -72,7 +84,7 @@ WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( const WebString& mime_type) { FilePath::StringType file_extension; - net::GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type), + net::GetPreferredExtensionForMimeType(AsASCII(mime_type), &file_extension); return FilePathStringToWebString(file_extension); } |