diff options
-rw-r--r-- | WebCore/platform/android/TemporaryLinkStubs.cpp | 7 | ||||
-rw-r--r-- | WebKit/Android.mk | 1 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 30 | ||||
-rw-r--r-- | WebKit/android/jni/MIMETypeRegistry.cpp | 65 |
4 files changed, 67 insertions, 36 deletions
diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp index 3e71689..fb9293c 100644 --- a/WebCore/platform/android/TemporaryLinkStubs.cpp +++ b/WebCore/platform/android/TemporaryLinkStubs.cpp @@ -60,7 +60,6 @@ #include "KURL.h" #include "Language.h" #include "LocalizedStrings.h" -#include "MIMETypeRegistry.h" #include "MainResourceLoader.h" #include "Node.h" #include "NotImplemented.h" @@ -354,12 +353,6 @@ void* WebCore::Frame::dragImageForSelection() return 0; } - -WebCore::String WebCore::MIMETypeRegistry::getMIMETypeForExtension(WebCore::String const&) -{ - return WebCore::String(); -} - void WebCore::Pasteboard::writeImage(WebCore::Node*, WebCore::KURL const&, WebCore::String const&) {} namespace WebCore { diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 7123df2..16ba925 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \ android/jni/GeolocationPermissionsBridge.cpp \ android/jni/JavaBridge.cpp \ android/jni/JavaSharedClient.cpp \ + android/jni/MIMETypeRegistry.cpp \ android/jni/MockGeolocation.cpp \ android/jni/PictureSet.cpp \ android/jni/WebCoreFrameBridge.cpp \ diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index c928d46..cb361bf 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -1033,35 +1033,7 @@ WTF::PassRefPtr<Widget> FrameLoaderClientAndroid::createJavaAppletWidget(const I // the contents and work out if it can render it. ObjectContentType FrameLoaderClientAndroid::objectContentType(const KURL& url, const String& mimeType) { - if (mimeType.length() == 0) - { - // Guess the mimeType from the extension - if (url.hasPath()) - { - String path = url.path(); - int lastIndex = path.reverseFind('.'); - static const String image("image/"); - if (lastIndex >= 0) - { - String mime(path.substring(lastIndex + 1)); - mime.insert(image, 0); - if (Image::supportsType(mime)) - return ObjectContentImage; - } - } - return ObjectContentFrame; - } - - if (Image::supportsType(mimeType)) - return ObjectContentImage; - - if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) - return ObjectContentOtherPlugin; - - if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) - return ObjectContentFrame; - - return ObjectContentNone; + return FrameLoader::defaultObjectContentType(url, mimeType); } // This function allows the application to set the correct CSS media diff --git a/WebKit/android/jni/MIMETypeRegistry.cpp b/WebKit/android/jni/MIMETypeRegistry.cpp new file mode 100644 index 0000000..4e9ae68 --- /dev/null +++ b/WebKit/android/jni/MIMETypeRegistry.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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. + */ + +#define LOG_TAG "WebCore" + +#include "config.h" + +#include "MIMETypeRegistry.h" +#include "PlatformString.h" +#include "jni_utility.h" +#include "WebCoreJni.h" + +#include <jni.h> +#include <utils/Log.h> + +namespace WebCore { + +static jmethodID gMimeTypeFromExtension; +static jclass gMimeClass; + +String MIMETypeRegistry::getMIMETypeForExtension(const String& ext) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + if (!gMimeTypeFromExtension) { + gMimeClass = env->FindClass("android/webkit/MimeTypeMap"); + LOG_ASSERT(gMimeClass, "Could not find class MimeTypeMap"); + gMimeTypeFromExtension = env->GetStaticMethodID(gMimeClass, + "mimeTypeFromExtension", + "(Ljava/lang/String;)Ljava/lang/String;"); + LOG_ASSERT(gMimeTypeFromExtension, + "Could not find method mimeTypeFromExtension"); + } + jstring extString = + env->NewString((const jchar*) ext.characters(), ext.length()); + jobject mimeType = env->CallStaticObjectMethod(gMimeClass, + gMimeTypeFromExtension, extString); + String result = android::to_string(env, (jstring) mimeType); + env->DeleteLocalRef(extString); + env->DeleteLocalRef(mimeType); + return result; +} + +} |