 Chromium Code Reviews
 Chromium Code Reviews Issue 94893003:
  Support for json media types as (non-image) mime types.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 94893003:
  Support for json media types as (non-image) mime types.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/core/dom/DOMImplementation.cpp | 
| diff --git a/Source/core/dom/DOMImplementation.cpp b/Source/core/dom/DOMImplementation.cpp | 
| index 83885b3bf10f9d2f46ba4d3d4526b052b8891ba8..1682e5af5e778d6738691a9d0d1aa21b58edad6b 100644 | 
| --- a/Source/core/dom/DOMImplementation.cpp | 
| +++ b/Source/core/dom/DOMImplementation.cpp | 
| @@ -294,17 +294,34 @@ bool DOMImplementation::isXMLMIMEType(const String& mimeType) | 
| return true; | 
| } | 
| -bool DOMImplementation::isTextMIMEType(const String& mimeType) | 
| +bool DOMImplementation::isJSONMIMEType(const String& mimeType) | 
| 
tyoshino (SeeGerritForStatus)
2013/12/05 18:57:42
doesn't this return true for "application/foo+json
 
sof
2013/12/05 19:34:55
True enough. Better handle it & now done. Thanks :
 | 
| { | 
| - if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) | 
| - || mimeType == "application/json" // Render JSON as text/plain. | 
| - || (mimeType.startsWith("text/") && mimeType != "text/html" | 
| - && mimeType != "text/xml" && mimeType != "text/xsl")) | 
| + if (mimeType.startsWith("application/json", false)) | 
| return true; | 
| - | 
| + if (mimeType.startsWith("application/", false)) { | 
| + size_t subtype = mimeType.find("+json", 12, false); | 
| + if (subtype != kNotFound) { | 
| + // Just check that a parameter wasn't matched. | 
| + size_t parameterMarker = mimeType.find(";"); | 
| + return (parameterMarker == kNotFound || parameterMarker > subtype); | 
| 
pfeldman
2013/12/05 17:18:53
drop ()
 
sof
2013/12/05 19:32:44
Done.
 | 
| + } | 
| + } | 
| return false; | 
| } | 
| +static bool isTextPlainType(const String& mimeType) | 
| +{ | 
| + return (mimeType.startsWith("text/", false) | 
| 
pfeldman
2013/12/05 17:18:53
drop outmost ()
 
sof
2013/12/05 19:32:44
Done.
 | 
| + && !(equalIgnoringCase(mimeType, "text/html") | 
| + || equalIgnoringCase(mimeType, "text/xml") | 
| + || equalIgnoringCase(mimeType, "text/xsl"))); | 
| +} | 
| + | 
| +bool DOMImplementation::isTextMIMEType(const String& mimeType) | 
| +{ | 
| + return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || isJSONMIMEType(mimeType) || isTextPlainType(mimeType); | 
| +} | 
| + | 
| PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title) | 
| { | 
| DocumentInit init = DocumentInit::fromContext(m_document.contextDocument()) |