<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168430] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168430">168430</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2014-05-07 11:19:21 -0700 (Wed, 07 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Eliminate &quot;well known MIME type&quot; support
https://bugs.webkit.org/show_bug.cgi?id=132654

Reviewed by Anders Carlsson.

Vestiges of FileSystem API.

* dom/DataTransfer.cpp:
(WebCore::DataTransfer::files):
(WebCore::DataTransfer::hasFileOfType):
* fileapi/File.cpp:
(WebCore::File::File):
(WebCore::File::contentTypeFromFilePathOrName):
* fileapi/File.h:
* html/FileInputType.cpp:
(WebCore::FileInputType::createFileList):
* platform/MIMETypeRegistry.cpp:
(WebCore::initializeSupportedImageMIMETypes):
(WebCore::findMimeType): Deleted.
(WebCore::MIMETypeRegistry::getWellKnownMIMETypeForExtension): Deleted.
* platform/MIMETypeRegistry.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDataTransfercpp">trunk/Source/WebCore/dom/DataTransfer.cpp</a></li>
<li><a href="#trunkSourceWebCorefileapiFilecpp">trunk/Source/WebCore/fileapi/File.cpp</a></li>
<li><a href="#trunkSourceWebCorefileapiFileh">trunk/Source/WebCore/fileapi/File.h</a></li>
<li><a href="#trunkSourceWebCorehtmlFileInputTypecpp">trunk/Source/WebCore/html/FileInputType.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistrycpp">trunk/Source/WebCore/platform/MIMETypeRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistryh">trunk/Source/WebCore/platform/MIMETypeRegistry.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/ChangeLog        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-05-07  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        Eliminate &quot;well known MIME type&quot; support
+        https://bugs.webkit.org/show_bug.cgi?id=132654
+
+        Reviewed by Anders Carlsson.
+
+        Vestiges of FileSystem API.
+
+        * dom/DataTransfer.cpp:
+        (WebCore::DataTransfer::files):
+        (WebCore::DataTransfer::hasFileOfType):
+        * fileapi/File.cpp:
+        (WebCore::File::File):
+        (WebCore::File::contentTypeFromFilePathOrName):
+        * fileapi/File.h:
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::createFileList):
+        * platform/MIMETypeRegistry.cpp:
+        (WebCore::initializeSupportedImageMIMETypes):
+        (WebCore::findMimeType): Deleted.
+        (WebCore::MIMETypeRegistry::getWellKnownMIMETypeForExtension): Deleted.
+        * platform/MIMETypeRegistry.h:
+
</ins><span class="cx"> 2014-05-07  Christophe Dumez  &lt;ch.dumez@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [HTML] Default argument to HTMLTableElement.insertRow() should be -1
</span></span></pre></div>
<a id="trunkSourceWebCoredomDataTransfercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DataTransfer.cpp (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DataTransfer.cpp        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/dom/DataTransfer.cpp        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (newlyCreatedFileList) {
</span><span class="cx">         for (const String&amp; filename : m_pasteboard-&gt;readFilenames())
</span><del>-            m_fileList-&gt;append(File::create(filename, File::AllContentTypes));
</del><ins>+            m_fileList-&gt;append(File::create(filename));
</ins><span class="cx">     }
</span><span class="cx">     return m_fileList.get();
</span><span class="cx"> }
</span><span class="lines">@@ -189,7 +189,7 @@
</span><span class="cx">     ASSERT_WITH_SECURITY_IMPLICATION(canReadTypes());
</span><span class="cx"> 
</span><span class="cx">     for (const String&amp; filename : m_pasteboard-&gt;readFilenames()) {
</span><del>-        if (equalIgnoringCase(File::contentTypeFromFilePathOrName(filename, File::AllContentTypes), type))
</del><ins>+        if (equalIgnoringCase(File::contentTypeFromFilePathOrName(filename), type))
</ins><span class="cx">             return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiFilecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/fileapi/File.cpp (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/File.cpp        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/fileapi/File.cpp        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -37,24 +37,24 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-File::File(const String&amp; path, ContentTypeLookupPolicy policy)
</del><ins>+File::File(const String&amp; path)
</ins><span class="cx">     : Blob(uninitializedContructor)
</span><span class="cx">     , m_path(path)
</span><span class="cx">     , m_name(pathGetFileName(path))
</span><span class="cx"> {
</span><span class="cx">     m_internalURL = BlobURL::createInternalURL();
</span><del>-    m_type = contentTypeFromFilePathOrName(path, policy);
</del><ins>+    m_type = contentTypeFromFilePathOrName(path);
</ins><span class="cx">     m_size = -1;
</span><span class="cx">     ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-File::File(const String&amp; path, const String&amp; name, ContentTypeLookupPolicy policy)
</del><ins>+File::File(const String&amp; path, const String&amp; name)
</ins><span class="cx">     : Blob(uninitializedContructor)
</span><span class="cx">     , m_path(path)
</span><span class="cx">     , m_name(name)
</span><span class="cx"> {
</span><span class="cx">     m_internalURL = BlobURL::createInternalURL();
</span><del>-    m_type = contentTypeFromFilePathOrName(name, policy);
</del><ins>+    m_type = contentTypeFromFilePathOrName(name);
</ins><span class="cx">     m_size = -1;
</span><span class="cx">     ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
</span><span class="cx"> }
</span><span class="lines">@@ -87,17 +87,12 @@
</span><span class="cx">     return static_cast&lt;unsigned long long&gt;(size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String File::contentTypeFromFilePathOrName(const String&amp; name, File::ContentTypeLookupPolicy policy)
</del><ins>+String File::contentTypeFromFilePathOrName(const String&amp; name)
</ins><span class="cx"> {
</span><span class="cx">     String type;
</span><span class="cx">     int index = name.reverseFind('.');
</span><span class="cx">     if (index != -1) {
</span><del>-        if (policy == File::WellKnownContentTypes)
-            type = MIMETypeRegistry::getWellKnownMIMETypeForExtension(name.substring(index + 1));
-        else {
-            ASSERT(policy == File::AllContentTypes);
-            type = MIMETypeRegistry::getMIMETypeForExtension(name.substring(index + 1));
-        }
</del><ins>+        type = MIMETypeRegistry::getMIMETypeForExtension(name.substring(index + 1));
</ins><span class="cx">     }
</span><span class="cx">     return type;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiFileh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/fileapi/File.h (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/File.h        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/fileapi/File.h        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -36,16 +36,9 @@
</span><span class="cx"> 
</span><span class="cx"> class File final : public Blob {
</span><span class="cx"> public:
</span><del>-    // AllContentTypes should only be used when the full path/name are trusted; otherwise, it could
-    // allow arbitrary pages to determine what applications an user has installed.
-    enum ContentTypeLookupPolicy {
-        WellKnownContentTypes,
-        AllContentTypes,
-    };
-
-    static PassRefPtr&lt;File&gt; create(const String&amp; path, ContentTypeLookupPolicy policy = WellKnownContentTypes)
</del><ins>+    static PassRefPtr&lt;File&gt; create(const String&amp; path)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new File(path, policy));
</del><ins>+        return adoptRef(new File(path));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static PassRefPtr&lt;File&gt; deserialize(const String&amp; path, const URL&amp; srcURL, const String&amp; type)
</span><span class="lines">@@ -54,11 +47,11 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Create a file with a name exposed to the author (via File.name and associated DOM properties) that differs from the one provided in the path.
</span><del>-    static PassRefPtr&lt;File&gt; createWithName(const String&amp; path, const String&amp; name, ContentTypeLookupPolicy policy = WellKnownContentTypes)
</del><ins>+    static PassRefPtr&lt;File&gt; createWithName(const String&amp; path, const String&amp; name)
</ins><span class="cx">     {
</span><span class="cx">         if (name.isEmpty())
</span><del>-            return adoptRef(new File(path, policy));
-        return adoptRef(new File(path, name, policy));
</del><ins>+            return adoptRef(new File(path));
+        return adoptRef(new File(path, name));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     virtual unsigned long long size() const override;
</span><span class="lines">@@ -70,11 +63,11 @@
</span><span class="cx">     // This returns the current date and time if the file's last modifiecation date is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate).
</span><span class="cx">     double lastModifiedDate() const;
</span><span class="cx"> 
</span><del>-    static String contentTypeFromFilePathOrName(const String&amp;, ContentTypeLookupPolicy);
</del><ins>+    static String contentTypeFromFilePathOrName(const String&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    File(const String&amp; path, ContentTypeLookupPolicy);
-    File(const String&amp; path, const String&amp; name, ContentTypeLookupPolicy);
</del><ins>+    explicit File(const String&amp; path);
+    File(const String&amp; path, const String&amp; name);
</ins><span class="cx"> 
</span><span class="cx">     File(DeserializationContructor, const String&amp; path, const URL&amp; srcURL, const String&amp; type);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlFileInputTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/FileInputType.cpp (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/FileInputType.cpp        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/html/FileInputType.cpp        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -266,7 +266,7 @@
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;RefPtr&lt;File&gt;&gt; fileObjects;
</span><span class="cx">     for (const FileChooserFileInfo&amp; info : files)
</span><del>-        fileObjects.append(File::createWithName(info.path, info.displayName, File::AllContentTypes));
</del><ins>+        fileObjects.append(File::createWithName(info.path, info.displayName));
</ins><span class="cx"> 
</span><span class="cx">     return FileList::create(std::move(fileObjects));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -144,43 +144,6 @@
</span><span class="cx"> static const char imageJpeg[] = &quot;image/jpeg&quot;;
</span><span class="cx"> static const char octetStream[] = &quot;application/octet-stream&quot;;
</span><span class="cx"> 
</span><del>-// A table of well known MIME types used when we don't want to leak to the
-// caller information about types known to underlying platform.
-static const TypeExtensionPair wellKnownMimeTypes[] = {
-    { textPlain, &quot;txt&quot; },
-    { textPlain, &quot;text&quot; },
-    { textHtml, &quot;html&quot; },
-    { textHtml, &quot;htm&quot; },
-    { &quot;text/css&quot;, &quot;css&quot; },
-    { &quot;text/xml&quot;, &quot;xml&quot; },
-    { &quot;text/xsl&quot;, &quot;xsl&quot; },
-    { &quot;image/gif&quot;, &quot;gif&quot; },
-    { &quot;image/png&quot;, &quot;png&quot; },
-    { imageJpeg, &quot;jpeg&quot; },
-    { imageJpeg, &quot;jpg&quot; },
-    { imageJpeg, &quot;jfif&quot; },
-    { imageJpeg, &quot;pjpeg&quot; },
-    { &quot;image/webp&quot;, &quot;webp&quot; },
-    { &quot;image/bmp&quot;, &quot;bmp&quot; },
-    { &quot;application/xhtml+xml&quot;, &quot;xhtml&quot; },
-    { &quot;application/x-javascript&quot;, &quot;js&quot; },
-    { &quot;application/json&quot;, &quot;json&quot; },
-    { octetStream, &quot;exe&quot; },
-    { octetStream, &quot;com&quot; },
-    { octetStream, &quot;bin&quot; },
-    { &quot;application/zip&quot;, &quot;zip&quot; },
-    { &quot;application/gzip&quot;, &quot;gz&quot; },
-    { &quot;application/pdf&quot;, &quot;pdf&quot; },
-    { &quot;application/postscript&quot;, &quot;ps&quot; },
-    { &quot;image/x-icon&quot;, &quot;ico&quot; },
-    { &quot;image/tiff&quot;, &quot;tiff&quot; },
-    { &quot;image/x-xbitmap&quot;, &quot;xbm&quot; },
-    { &quot;image/svg+xml&quot;, &quot;svg&quot; },
-    { &quot;application/rss+xml&quot;, &quot;rss&quot; },
-    { &quot;application/rdf+xml&quot;, &quot;rdf&quot; },
-    { &quot;application/x-shockwave-flash&quot;, &quot;swf&quot; },
-};
-
</del><span class="cx"> static HashSet&lt;String&gt;* supportedImageResourceMIMETypes;
</span><span class="cx"> static HashSet&lt;String&gt;* supportedImageMIMETypes;
</span><span class="cx"> static HashSet&lt;String&gt;* supportedImageMIMETypesForEncoding;
</span><span class="lines">@@ -506,26 +469,6 @@
</span><span class="cx">     initializeUnsupportedTextMIMETypes();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static String findMimeType(const TypeExtensionPair* pairs, unsigned numPairs, const String&amp; extension)
-{
-    if (!extension.isEmpty()) {
-      for (unsigned i = 0; i &lt; numPairs; ++i, ++pairs) {
-          if (equalIgnoringCase(extension, pairs-&gt;extension))
-              return String(pairs-&gt;type);
-      }
-    }
-    return String();
-}
-
-String MIMETypeRegistry::getWellKnownMIMETypeForExtension(const String&amp; extension)
-{
-    // This method must be thread safe and should not consult the OS/registry.
-    String found = findMimeType(wellKnownMimeTypes, sizeof(wellKnownMimeTypes) / sizeof(wellKnownMimeTypes[0]), extension);
-    if (!found.isEmpty())
-        return found;
-    return findMimeType(commonMediaTypes, sizeof(commonMediaTypes) / sizeof(commonMediaTypes[0]), extension);
-}
-
</del><span class="cx"> String MIMETypeRegistry::getMIMETypeForPath(const String&amp; path)
</span><span class="cx"> {
</span><span class="cx">     size_t pos = path.reverseFind('.');
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (168429 => 168430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.h        2014-05-07 18:13:04 UTC (rev 168429)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h        2014-05-07 18:19:21 UTC (rev 168430)
</span><span class="lines">@@ -36,7 +36,6 @@
</span><span class="cx"> class MIMETypeRegistry {
</span><span class="cx"> public:
</span><span class="cx">     static String getMIMETypeForExtension(const String&amp; extension);
</span><del>-    static String getWellKnownMIMETypeForExtension(const String&amp; extension);
</del><span class="cx"> 
</span><span class="cx">     static Vector&lt;String&gt; getExtensionsForMIMEType(const String&amp; type);
</span><span class="cx">     static String getPreferredExtensionForMIMEType(const String&amp; type);
</span></span></pre>
</div>
</div>

</body>
</html>