Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: webkit/glue/simple_webmimeregistry_impl.cc

Issue 160363: Fix a DCHECK we hit when a mime type isn't ASCII. (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/simple_webmimeregistry_impl.cc
diff --git a/webkit/glue/simple_webmimeregistry_impl.cc b/webkit/glue/simple_webmimeregistry_impl.cc
index 29296ff13151539c3e3bf3ee0874c8f802d24237..63c11653bb25ee23674c39f8f23da075527bed06 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.
+const 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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698