Don't try to guess plugin MIME type from a file extension in a URL (no observable...
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 06:08:11 +0000 (06:08 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 06:08:11 +0000 (06:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178333

Reviewed by Darin Adler.

Source/WebCore:

No test cases because I could not find an observable behavior difference,
even after trying many different plugin loading scenarios.

* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): loadedMIMEType --> serviceType
(WebCore::HTMLPlugInImageElement::restartSimilarPlugIns): ditto
(WebCore::HTMLPlugInImageElement::userDidClickSnapshot): ditto
(WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): ditto
* html/HTMLPlugInImageElement.h:
(WebCore::HTMLPlugInImageElement::loadedMimeType const): Deleted. This was the one call site
for mimeTypeFromURL, and is otherwise just a wrapper for SerciceType()
* platform/URL.cpp:
(WebCore::mimeTypeFromURL): Deleted. This was the only use of MIMETypeDatabase in URL.
* platform/URL.h: Removed declaration for mimeTypeFromURL.
* WebCore.order: Removed mimeTypeFromURL.

Source/WebKit:

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::pluginDidReceiveUserInteraction): loadedMIMEType --> serviceType
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::determinePrimarySnapshottedPlugIn): ditto

Source/WebKitLegacy/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::objectContentType): Remove unnecessary call to mimeTypeFromURL

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224387 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.order
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/URL.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Plugins/PluginView.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp

index 2c79438..ef2e11f 100644 (file)
@@ -1,3 +1,26 @@
+2017-11-02  Maciej Stachowiak  <mjs@apple.com>
+
+        Don't try to guess plugin MIME type from a file extension in a URL (no observable effect)
+        https://bugs.webkit.org/show_bug.cgi?id=178333
+
+        Reviewed by Darin Adler.
+
+        No test cases because I could not find an observable behavior difference,
+        even after trying many different plugin loading scenarios.
+        
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): loadedMIMEType --> serviceType
+        (WebCore::HTMLPlugInImageElement::restartSimilarPlugIns): ditto
+        (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): ditto
+        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): ditto
+        * html/HTMLPlugInImageElement.h:
+        (WebCore::HTMLPlugInImageElement::loadedMimeType const): Deleted. This was the one call site
+        for mimeTypeFromURL, and is otherwise just a wrapper for SerciceType()
+        * platform/URL.cpp:
+        (WebCore::mimeTypeFromURL): Deleted. This was the only use of MIMETypeDatabase in URL.
+        * platform/URL.h: Removed declaration for mimeTypeFromURL.
+        * WebCore.order: Removed mimeTypeFromURL.
+
 2017-11-02  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
         [Curl] Fix cancellation process implementation
index 6322c63..aa2086c 100644 (file)
@@ -15563,7 +15563,6 @@ __ZN7WebCore15jsAttrSpecifiedEPN3JSC9ExecStateENS0_7JSValueENS0_12PropertyNameE
 __ZN7WebCore18jsHTMLElementTitleEPN3JSC9ExecStateENS0_7JSValueENS0_12PropertyNameE
 __ZN7WebCore9InlineBox11extractLineEv
 __ZN7WebCore9InlineBox10attachLineEv
-__ZN7WebCore15mimeTypeFromURLERKNS_4KURLE
 __ZN7WebCore22HTMLPlugInImageElement15setDisplayStateENS_17HTMLPlugInElement12DisplayStateE
 __ZN7WebCore16HTMLQuoteElementD0Ev
 __ZN7WebCore15PlatformCALayer18removeAllSublayersEv
index 07bde13..af04177 100644 (file)
@@ -356,7 +356,7 @@ void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot& root)
     // the look-and-feel of the snapshotted plug-in overlay. 
     root.setResetStyleInheritance(true);
     
-    String mimeType = loadedMimeType();
+    String mimeType = serviceType();
 
     auto& isolatedWorld = plugInImageElementIsolatedWorld();
     document().ensurePlugInsInjectedScript(isolatedWorld);
@@ -425,7 +425,7 @@ void HTMLPlugInImageElement::restartSimilarPlugIns()
     // may be in different frames, so traverse from the top of the document.
 
     String plugInOrigin = m_loadedUrl.host();
-    String mimeType = loadedMimeType();
+    String mimeType = serviceType();
     Vector<Ref<HTMLPlugInImageElement>> similarPlugins;
 
     if (!document().page())
@@ -439,7 +439,7 @@ void HTMLPlugInImageElement::restartSimilarPlugIns()
             continue;
 
         for (auto& element : descendantsOfType<HTMLPlugInImageElement>(*frame->document())) {
-            if (plugInOrigin == element.loadedUrl().host() && mimeType == element.loadedMimeType())
+            if (plugInOrigin == element.loadedUrl().host() && mimeType == element.serviceType())
                 similarPlugins.append(element);
         }
     }
@@ -460,7 +460,7 @@ void HTMLPlugInImageElement::userDidClickSnapshot(MouseEvent& event, bool forwar
 
     String plugInOrigin = m_loadedUrl.host();
     if (document().page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document().page()->mainFrame().document()->baseURL().protocol().toStringWithoutCopying()) && document().page()->settings().autostartOriginPlugInSnapshottingEnabled())
-        document().page()->plugInClient()->didStartFromOrigin(document().page()->mainFrame().document()->baseURL().host(), plugInOrigin, loadedMimeType(), document().page()->sessionID());
+        document().page()->plugInClient()->didStartFromOrigin(document().page()->mainFrame().document()->baseURL().host(), plugInOrigin, serviceType(), document().page()->sessionID());
 
     LOG(Plugins, "%p User clicked on snapshotted plug-in. Restart.", this);
     restartSnapshottedPlugIn();
@@ -602,7 +602,7 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const URL& url)
 {
     LOG(Plugins, "%p Plug-in URL: %s", this, m_url.utf8().data());
     LOG(Plugins, "   Actual URL: %s", url.string().utf8().data());
-    LOG(Plugins, "   MIME type: %s", loadedMimeType().utf8().data());
+    LOG(Plugins, "   MIME type: %s", serviceType().utf8().data());
 
     m_loadedUrl = url;
     m_plugInWasCreated = false;
@@ -664,14 +664,14 @@ void HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn(const URL& url)
         return;
     }
 
-    if (document().page()->settings().autostartOriginPlugInSnapshottingEnabled() && document().page()->plugInClient() && document().page()->plugInClient()->shouldAutoStartFromOrigin(document().page()->mainFrame().document()->baseURL().host(), url.host(), loadedMimeType())) {
+    if (document().page()->settings().autostartOriginPlugInSnapshottingEnabled() && document().page()->plugInClient() && document().page()->plugInClient()->shouldAutoStartFromOrigin(document().page()->mainFrame().document()->baseURL().host(), url.host(), serviceType())) {
         LOG(Plugins, "%p Plug-in from (%s, %s) is marked to auto-start, set to play", this, document().page()->mainFrame().document()->baseURL().host().utf8().data(), url.host().utf8().data());
         m_snapshotDecision = NeverSnapshot;
         return;
     }
 
-    if (m_loadedUrl.isEmpty() && !loadedMimeType().isEmpty()) {
-        LOG(Plugins, "%p Plug-in has no src URL but does have a valid mime type %s, set to play", this, loadedMimeType().utf8().data());
+    if (m_loadedUrl.isEmpty() && !serviceType().isEmpty()) {
+        LOG(Plugins, "%p Plug-in has no src URL but does have a valid mime type %s, set to play", this, serviceType().utf8().data());
         m_snapshotDecision = MaySnapshotWhenContentIsSet;
         return;
     }
index e3f0396..377997a 100644 (file)
@@ -43,14 +43,6 @@ public:
     const String& url() const { return m_url; }
     const URL& loadedUrl() const { return m_loadedUrl; }
 
-    String loadedMimeType() const
-    {
-        String mimeType = serviceType();
-        if (mimeType.isEmpty())
-            mimeType = mimeTypeFromURL(m_loadedUrl);
-        return mimeType;
-    }
-
     // Public for FrameView::addWidgetToUpdate()
     bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
     void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
index 4a62705..e7a07ef 100644 (file)
@@ -28,7 +28,6 @@
 #include "URL.h"
 
 #include "DecodeEscapeSequences.h"
-#include "MIMETypeRegistry.h"
 #include "TextEncoding.h"
 #include "URLParser.h"
 #include <stdio.h>
@@ -1321,15 +1320,6 @@ String mimeTypeFromDataURL(const String& url)
     return url.substring(5, index - 5).convertToASCIILowercase();
 }
 
-String mimeTypeFromURL(const URL& url)
-{
-    String decodedPath = decodeURLEscapeSequences(url.path());
-    String extension = decodedPath.substring(decodedPath.reverseFind('.') + 1);
-
-    // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure
-    return MIMETypeRegistry::getMIMETypeForExtension(extension);
-}
-
 String URL::stringCenterEllipsizedToLength(unsigned length) const
 {
     if (string().length() <= length)
index 68552ee..7766629 100644 (file)
@@ -339,7 +339,6 @@ WEBCORE_EXPORT void clearDefaultPortForProtocolMapForTesting();
 bool isValidProtocol(const String&);
 
 String mimeTypeFromDataURL(const String& url);
-WEBCORE_EXPORT String mimeTypeFromURL(const URL&);
 
 // Unescapes the given string using URL escaping rules, given an optional
 // encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00"
index 12896b4..2a35622 100644 (file)
@@ -1,3 +1,15 @@
+2017-11-02  Maciej Stachowiak  <mjs@apple.com>
+
+        Don't try to guess plugin MIME type from a file extension in a URL (no observable effect)
+        https://bugs.webkit.org/show_bug.cgi?id=178333
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::pluginDidReceiveUserInteraction): loadedMIMEType --> serviceType
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::determinePrimarySnapshottedPlugIn): ditto
+
 2017-11-02  Brady Eidson  <beidson@apple.com>
 
         SW: Implement "Update Registration State" algorithm (unused for now)
index 6a39ebb..956984b 100644 (file)
@@ -1838,7 +1838,7 @@ void PluginView::pluginDidReceiveUserInteraction()
     HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(*m_pluginElement);
     String pageOrigin = plugInImageElement.document().page()->mainFrame().document()->baseURL().host();
     String pluginOrigin = plugInImageElement.loadedUrl().host();
-    String mimeType = plugInImageElement.loadedMimeType();
+    String mimeType = plugInImageElement.serviceType();
 
     WebProcess::singleton().plugInDidReceiveUserInteraction(pageOrigin, pluginOrigin, mimeType, plugInImageElement.document().page()->sessionID());
 }
index 037bbfc..9711b90 100644 (file)
@@ -5250,7 +5250,7 @@ void WebPage::determinePrimarySnapshottedPlugIn()
     m_didFindPrimarySnapshottedPlugin = true;
     m_primaryPlugInPageOrigin = m_page->mainFrame().document()->baseURL().host();
     m_primaryPlugInOrigin = candidatePlugIn->loadedUrl().host();
-    m_primaryPlugInMimeType = candidatePlugIn->loadedMimeType();
+    m_primaryPlugInMimeType = candidatePlugIn->serviceType();
 
     candidatePlugIn->setIsPrimarySnapshottedPlugIn(true);
 }
index 731a9ce..7796a4a 100644 (file)
@@ -1,3 +1,13 @@
+2017-11-02  Maciej Stachowiak  <mjs@apple.com>
+
+        Don't try to guess plugin MIME type from a file extension in a URL (no observable effect)
+        https://bugs.webkit.org/show_bug.cgi?id=178333
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::objectContentType): Remove unnecessary call to mimeTypeFromURL
+
 2017-11-02  Alex Christensen  <achristensen@webkit.org>
 
         Use CompletionHandlers for redirects
index bf0ddd3..558e644 100644 (file)
@@ -1054,9 +1054,6 @@ ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const
 {
     String mimeType = mimeTypeIn;
 
-    if (mimeType.isEmpty())
-        mimeType = mimeTypeFromURL(url);
-
     if (mimeType.isEmpty()) {
         String decodedPath = decodeURLEscapeSequences(url.path());
         mimeType = PluginDatabase::installedPlugins()->MIMETypeForExtension(decodedPath.substring(decodedPath.reverseFind('.') + 1));