diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-18 19:35:24 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-18 19:35:24 +0000 |
commit | 3d6293398e26ec2e70f839c4cbba56ba43481f62 (patch) | |
tree | 22fe75c93b51361c4139c5a5625eb54209c7f4b6 | |
parent | 468114936d12d25f5dcd3a97be5ab091761b7561 (diff) | |
download | chromium_src-3d6293398e26ec2e70f839c4cbba56ba43481f62.zip chromium_src-3d6293398e26ec2e70f839c4cbba56ba43481f62.tar.gz chromium_src-3d6293398e26ec2e70f839c4cbba56ba43481f62.tar.bz2 |
Kill our forked copy of MIMETypeRegistry.cpp by moving the customized methods
into MimeTypeRegistryChromium.cpp, and stop building MIMETypeRegistry.cpp. It
turns out that there just isn't enough of that file that we have in common to
make it worth sharing.
R=dglazkov
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7246 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/build/WebCore/SConscript | 1 | ||||
-rw-r--r-- | webkit/build/WebCore/WebCore.vcproj | 12 | ||||
-rw-r--r-- | webkit/port/bridge/chromium/PluginsChromium.cpp | 6 | ||||
-rw-r--r-- | webkit/port/platform/MIMETypeRegistry.cpp | 123 | ||||
-rw-r--r-- | webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp | 106 |
5 files changed, 98 insertions, 150 deletions
diff --git a/webkit/build/WebCore/SConscript b/webkit/build/WebCore/SConscript index 367cdbb..4f9a1ef3 100644 --- a/webkit/build/WebCore/SConscript +++ b/webkit/build/WebCore/SConscript @@ -407,7 +407,6 @@ input_files = [ '$WEBCORE_DIR/platform/Length.cpp', '$WEBCORE_DIR/platform/LinkHash.cpp', '$WEBCORE_DIR/platform/Logging.cpp', - '$PORT_DIR/platform/MIMETypeRegistry.cpp', '$WEBCORE_DIR/platform/Scrollbar.cpp', '$WEBCORE_DIR/platform/ScrollbarThemeComposite.cpp', '$WEBCORE_DIR/platform/ScrollView.cpp', diff --git a/webkit/build/WebCore/WebCore.vcproj b/webkit/build/WebCore/WebCore.vcproj index d7cf4c4..b082719 100644 --- a/webkit/build/WebCore/WebCore.vcproj +++ b/webkit/build/WebCore/WebCore.vcproj @@ -930,10 +930,6 @@ > </File> <File - RelativePath="..\..\..\third_party\WebKit\WebCore\platform\graphics\FontFastPath.cpp" - > - </File> - <File RelativePath="..\..\..\third_party\WebKit\WebCore\platform\graphics\Font.cpp" > </File> @@ -974,6 +970,10 @@ > </File> <File + RelativePath="..\..\..\third_party\WebKit\WebCore\platform\graphics\FontFastPath.cpp" + > + </File> + <File RelativePath="..\..\..\third_party\WebKit\WebCore\platform\graphics\FontSelector.h" > </File> @@ -1046,10 +1046,6 @@ > </File> <File - RelativePath="..\..\port\platform\MIMETypeRegistry.cpp" - > - </File> - <File RelativePath="..\..\..\third_party\WebKit\WebCore\platform\MIMETypeRegistry.h" > </File> diff --git a/webkit/port/bridge/chromium/PluginsChromium.cpp b/webkit/port/bridge/chromium/PluginsChromium.cpp index b953163..d73e9476 100644 --- a/webkit/port/bridge/chromium/PluginsChromium.cpp +++ b/webkit/port/bridge/chromium/PluginsChromium.cpp @@ -124,7 +124,7 @@ public: return false; } - String GetPluginMimeTypeFromExtension(const String& extension) + String getPluginMimeTypeFromExtension(const String& extension) { #if !defined(__linux__) // TODO(port): unstub once we have plugin support for Linux @@ -176,9 +176,9 @@ void refreshPlugins(bool) pluginCache.load(true); } -String GetPluginMimeTypeFromExtension(const String& extension) +String getPluginMimeTypeFromExtension(const String& extension) { - return pluginCache.GetPluginMimeTypeFromExtension(extension); + return pluginCache.getPluginMimeTypeFromExtension(extension); } } // namespace WebCore diff --git a/webkit/port/platform/MIMETypeRegistry.cpp b/webkit/port/platform/MIMETypeRegistry.cpp index 0918814..e18a5d6 100644 --- a/webkit/port/platform/MIMETypeRegistry.cpp +++ b/webkit/port/platform/MIMETypeRegistry.cpp @@ -1,122 +1 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "ChromiumBridge.h" -#include "CString.h" -#include "MIMETypeRegistry.h" -#include "MediaPlayer.h" -#include "StringHash.h" -#include <wtf/HashMap.h> -#include <wtf/HashSet.h> - -namespace WebCore -{ - -// NOTE: the following methods are unimplemented -// (and will give linker error if used): -// HashSet<String> &MIMETypeRegistry::getSupportedImageMIMETypes() -// HashSet<String> &MIMETypeRegistry::getSupportedImageResourceMIMETypes() -// These methods are referenced by WebKit but not WebCore. -// Therefore defering their implementation until necessary. -// Since the returned HashSet is mutable, chrome would need to synchronize -// the mime type registry between renderer/browser. This one is called, but we -// currently stub it out until this can be resolved. -HashSet<String>& MIMETypeRegistry::getSupportedNonImageMIMETypes() -{ - static HashSet<String> supportedNonImageMIMETypes; - return supportedNonImageMIMETypes; -} - - -// Checks if any of the plugins handle this extension, and if so returns the -// plugin's mime type for this extension. Otherwise returns an empty string. -String GetPluginMimeTypeFromExtension(const String& extension); - -String MIMETypeRegistry::getMIMETypeForPath(const String& path) -{ - int pos = path.reverseFind('.'); - if (pos < 0) - return "application/octet-stream"; - String extension = path.substring(pos + 1); - String mimeType = getMIMETypeForExtension(extension); - if (mimeType.isEmpty()) { - // If there's no mimetype registered for the extension, check to see - // if a plugin can handle the extension. - mimeType = GetPluginMimeTypeFromExtension(extension); - } - return mimeType; -} - -bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType) -{ - return !mimeType.isEmpty() - && ChromiumBridge::isSupportedImageMIMEType(mimeType.latin1().data()); -} - -bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType) -{ - // TODO(brettw) fill this out. See: http://trac.webkit.org/changeset/30888 - return isSupportedImageMIMEType(mimeType); -} - -bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType) -{ - return !mimeType.isEmpty() - && ChromiumBridge::isSupportedJavascriptMIMEType(mimeType.latin1().data()); -} - -bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType) -{ - return isSupportedImageMIMEType(mimeType); -} - -bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType) -{ - return !mimeType.isEmpty() - && ChromiumBridge::isSupportedNonImageMIMEType(mimeType.latin1().data()); -} - -bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType) -{ - HashSet<String> supportedMediaMIMETypes;
-#if ENABLE(VIDEO)
- MediaPlayer::getSupportedTypes(supportedMediaMIMETypes);
-#endif
- return !mimeType.isEmpty() && supportedMediaMIMETypes.contains(mimeType);
-} - -bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType) -{ - // Since this set is very limited and is likely to remain so we won't bother with the overhead - // of using a hash set. - // Any of the MIME types below may be followed by any number of specific versions of the JVM, - // which is why we use startsWith() - return mimeType.startsWith("application/x-java-applet", false) - || mimeType.startsWith("application/x-java-bean", false) - || mimeType.startsWith("application/x-java-vm", false); -} - -} // namespace WebCore +// TODO(darin): remove this file once xcode projects are fixed. diff --git a/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp b/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp index 5afa05ed..7f83d90 100644 --- a/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp +++ b/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp @@ -28,30 +28,31 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "config.h" -#include "ChromiumBridge.h" #include "MIMETypeRegistry.h" +#include "ChromiumBridge.h" +#include "CString.h" +#include "MediaPlayer.h" + +// NOTE: Unlike other ports, we don't use the shared implementation bits in +// MIMETypeRegistry.cpp. Instead, we need to route most functions via the +// ChromiumBridge to the embedder. + namespace WebCore { -// From MIMETypeRegistryMac.mm. -#if PLATFORM(DARWIN) && PLATFORM(CG) -String getMIMETypeForUTI(const String & uti) +// Checks if any of the plugins handle this extension, and if so returns the +// plugin's mime type for this extension. Otherwise returns an empty string. +// See PluginsChromium.cpp for the implementation of this function. +String getPluginMimeTypeFromExtension(const String& extension); + +String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) { - CFStringRef utiref = uti.createCFString(); - CFStringRef mime = UTTypeCopyPreferredTagWithClass(utiref, kUTTagClassMIMEType); - String mimeType = mime; - if (mime) - CFRelease(mime); - CFRelease(utiref); - return mimeType; + return ChromiumBridge::mimeTypeForExtension(ext); } -#endif // Returns the file extension if one is found. Does not include the dot in the // filename. E.g., 'html'. -// NOTE: This does not work in the sandbox because the renderer doesn't have -// access to the Windows Registry. String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type) { // Prune out any parameters in case they happen to have snuck in there... @@ -65,9 +66,82 @@ String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type) return ext; } -String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) +String MIMETypeRegistry::getMIMETypeForPath(const String& path) { - return ChromiumBridge::mimeTypeForExtension(ext); + int pos = path.reverseFind('.'); + if (pos < 0) + return "application/octet-stream"; + String extension = path.substring(pos + 1); + String mimeType = getMIMETypeForExtension(extension); + if (mimeType.isEmpty()) { + // If there's no mimetype registered for the extension, check to see + // if a plugin can handle the extension. + mimeType = getPluginMimeTypeFromExtension(extension); + } + return mimeType; +} + +bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType) +{ + return !mimeType.isEmpty() + && ChromiumBridge::isSupportedImageMIMEType(mimeType.latin1().data()); } +bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType) +{ + return isSupportedImageMIMEType(mimeType); +} + +bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType) +{ + // TODO(brettw) fill this out. See: http://trac.webkit.org/changeset/30888 + return isSupportedImageMIMEType(mimeType); +} + +bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType) +{ + return !mimeType.isEmpty() + && ChromiumBridge::isSupportedJavascriptMIMEType(mimeType.latin1().data()); +} + +bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType) +{ + return !mimeType.isEmpty() + && ChromiumBridge::isSupportedNonImageMIMEType(mimeType.latin1().data()); +} + +bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType) +{ + HashSet<String> supportedMediaMIMETypes; +#if ENABLE(VIDEO) + MediaPlayer::getSupportedTypes(supportedMediaMIMETypes); +#endif + return !mimeType.isEmpty() && supportedMediaMIMETypes.contains(mimeType); +} + +bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType) +{ + // Since this set is very limited and is likely to remain so we won't bother with the overhead + // of using a hash set. + // Any of the MIME types below may be followed by any number of specific versions of the JVM, + // which is why we use startsWith() + return mimeType.startsWith("application/x-java-applet", false) + || mimeType.startsWith("application/x-java-bean", false) + || mimeType.startsWith("application/x-java-vm", false); +} + +static HashSet<String>& dummyHashSet() +{ + ASSERT_NOT_REACHED(); + static HashSet<String> dummy; + return dummy; +} + +// NOTE: the following methods should never be reached +HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypes() { return dummyHashSet(); } +HashSet<String>& MIMETypeRegistry::getSupportedImageResourceMIMETypes() { return dummyHashSet(); } +HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding() { return dummyHashSet(); } +HashSet<String>& MIMETypeRegistry::getSupportedNonImageMIMETypes() { return dummyHashSet(); } +HashSet<String>& MIMETypeRegistry::getSupportedMediaMIMETypes() { return dummyHashSet(); } + } |