diff options
author | Ben Murdoch <benm@google.com> | 2010-05-28 11:08:34 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-06-02 11:22:40 +0100 |
commit | 10bcdb2eab81b5b9c893faf90f5bd9f396edeb4a (patch) | |
tree | 6a2fd233d940d82cbb96bc1be23b09860af5811d | |
parent | c05b3a990126a5a1de357c025e25e6acd4e4e185 (diff) | |
download | external_webkit-10bcdb2eab81b5b9c893faf90f5bd9f396edeb4a.zip external_webkit-10bcdb2eab81b5b9c893faf90f5bd9f396edeb4a.tar.gz external_webkit-10bcdb2eab81b5b9c893faf90f5bd9f396edeb4a.tar.bz2 |
Enable File Reader and blob.slice APIs.
Notes:
- the change to WebCore/html/FileStream.cpp is a cherry pick of http://trac.webkit.org/changeset/60325
- the change to WebCore/platform/posix/FileSystemPOSIX.cpp is a cherry pick of http://trac.webkit.org/changeset/60374
- this needs a corresponding frameworks/base change
Change-Id: I05d1496e1e95adf1c6a61c6f07bbf62e9bc92820
-rw-r--r-- | CleanSpec.mk | 1 | ||||
-rw-r--r-- | WebCore/Android.derived.jscbindings.mk | 2 | ||||
-rw-r--r-- | WebCore/Android.derived.v8bindings.mk | 2 | ||||
-rw-r--r-- | WebCore/Android.mk | 4 | ||||
-rw-r--r-- | WebCore/config.h | 4 | ||||
-rw-r--r-- | WebCore/html/FileStream.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/android/FileSystemAndroid.cpp | 18 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 2 | ||||
-rw-r--r-- | WebCore/platform/posix/FileSystemPOSIX.cpp | 7 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FileSystemClient.h | 2 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/PlatformBridge.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/jni/JavaBridge.cpp | 10 |
12 files changed, 40 insertions, 18 deletions
diff --git a/CleanSpec.mk b/CleanSpec.mk index ebb3f75..78ff4dc 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -53,6 +53,7 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_int $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libwebcore_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libwebcore_intermediates) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST diff --git a/WebCore/Android.derived.jscbindings.mk b/WebCore/Android.derived.jscbindings.mk index 70ef7cd..001472e 100644 --- a/WebCore/Android.derived.jscbindings.mk +++ b/WebCore/Android.derived.jscbindings.mk @@ -49,7 +49,7 @@ js_binding_scripts := $(addprefix $(LOCAL_PATH)/,\ bindings/scripts/generate-bindings.pl \ ) -FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 ENABLE_XPATH=1 ENABLE_XSLT=1 ENABLE_DEVICE_ORIENTATION=1 +FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 ENABLE_XPATH=1 ENABLE_XSLT=1 ENABLE_DEVICE_ORIENTATION=1 ENABLE_FILE_READER=1 ENABLE_BLOB_SLICE=1 # CSS GEN := \ diff --git a/WebCore/Android.derived.v8bindings.mk b/WebCore/Android.derived.v8bindings.mk index 4b06dd2..4788f00 100644 --- a/WebCore/Android.derived.v8bindings.mk +++ b/WebCore/Android.derived.v8bindings.mk @@ -32,7 +32,7 @@ js_binding_scripts := \ # Add ACCELERATED_COMPOSITING=1 and ENABLE_3D_RENDERING=1 for layers support FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 ENABLE_XPATH=1 ENABLE_XSLT=1 ENABLE_DEVICE_ORIENTATION=1 -FEATURE_DEFINES += V8_BINDING +FEATURE_DEFINES += V8_BINDING ENABLE_FILE_READER=1 ENABLE_BLOB_SLICE=1 # CSS GEN := \ diff --git a/WebCore/Android.mk b/WebCore/Android.mk index 98b7b16..373c70f 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -253,6 +253,9 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ html/File.cpp \ html/FileList.cpp \ html/FileReader.cpp \ + html/FileStream.cpp \ + html/FileStreamProxy.cpp \ + html/FileThread.cpp \ html/FormDataList.cpp \ html/HTML5Lexer.cpp \ html/HTML5Tokenizer.cpp \ @@ -408,6 +411,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/ThreadGlobalData.cpp \ platform/ThreadTimers.cpp \ platform/Timer.cpp \ + platform/UUID.cpp \ platform/Widget.cpp \ \ platform/android/ClipboardAndroid.cpp \ diff --git a/WebCore/config.h b/WebCore/config.h index 6fa0c73..48f9543 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -130,6 +130,9 @@ #undef ENABLE_COMPOSITED_FIXED_ELEMENTS // Disabled by default in Platform.h #define ENABLE_COMPOSITED_FIXED_ELEMENTS 1 +#define ENABLE_FILE_READER 1 +#define ENABLE_BLOB_SLICE 1 + #define ANDROID_FLATTEN_FRAMESET #define ANDROID_FLATTEN_IFRAME @@ -200,6 +203,7 @@ // Enable hit test with point plus a size #define ANDROID_HITTEST_WITHSIZE + #endif /* PLATFORM(ANDROID) */ #ifdef __cplusplus diff --git a/WebCore/html/FileStream.cpp b/WebCore/html/FileStream.cpp index 7089f61..9a06eed 100644 --- a/WebCore/html/FileStream.cpp +++ b/WebCore/html/FileStream.cpp @@ -111,7 +111,7 @@ void FileStream::openForRead(Blob* blob) if (m_totalBytesToRead == Blob::toEndOfFile) m_totalBytesToRead = blob->size() - blob->start(); #else - m_total = blob->size(); + m_totalBytesToRead = blob->size(); #endif m_client->didGetSize(m_totalBytesToRead); diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp index cf9830e..3513958 100644 --- a/WebCore/platform/android/FileSystemAndroid.cpp +++ b/WebCore/platform/android/FileSystemAndroid.cpp @@ -46,6 +46,12 @@ String sPluginPath; CString fileSystemRepresentation(const String& path) { + // If the path is a content:// URI then ask Java to resolve it for us. + if (path.startsWith("content://")) + return PlatformBridge::resolveFilePathForContentUri(path).utf8(); + else if (path.startsWith("file://")) + return path.substring(strlen("file://")).utf8(); + return path.utf8(); } @@ -107,13 +113,15 @@ Vector<String> listDirectory(const String& path, const String& filter) return entries; } +// We define our own pathGetFileName rather than use the POSIX versions as we +// may get passed a content URI representing the path to the file. We pass +// the input through fileSystemRepresentation before using it to resolve it if +// it is a content URI. String pathGetFileName(const String& path) { - // If the path is a content:// URI then ask Java to resolve it for us. - if (path.startsWith("content://")) - return PlatformBridge::resolveFileNameForContentUri(path); - else - return path.substring(path.reverseFind('/') + 1); + CString fsRep = fileSystemRepresentation(path); + String fsPath = String(fsRep.data()); + return fsPath.substring(fsPath.reverseFind('/') + 1); } diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index 64984db..80aada6 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -136,7 +136,7 @@ public: static bool isWebViewPaused(const FrameView*); static bool canScroll(const FrameView*); - static String resolveFileNameForContentUri(const String&); + static String resolveFilePathForContentUri(const String&); }; } diff --git a/WebCore/platform/posix/FileSystemPOSIX.cpp b/WebCore/platform/posix/FileSystemPOSIX.cpp index b7fcd71..c035310 100644 --- a/WebCore/platform/posix/FileSystemPOSIX.cpp +++ b/WebCore/platform/posix/FileSystemPOSIX.cpp @@ -75,12 +75,17 @@ bool deleteFile(const String& path) PlatformFileHandle openFile(const String& path, FileOpenMode mode) { + CString fsRep = fileSystemRepresentation(path); + + if (fsRep.isNull()) + return invalidPlatformFileHandle; + int platformFlag = 0; if (mode == OpenForRead) platformFlag |= O_RDONLY; else if (mode == OpenForWrite) platformFlag |= (O_WRONLY | O_CREAT | O_TRUNC); - return open(path.utf8().data(), platformFlag, 0666); + return open(fsRep.data(), platformFlag, 0666); } void closeFile(PlatformFileHandle& handle) diff --git a/WebKit/android/WebCoreSupport/FileSystemClient.h b/WebKit/android/WebCoreSupport/FileSystemClient.h index 8847bda..5bde18a 100644 --- a/WebKit/android/WebCoreSupport/FileSystemClient.h +++ b/WebKit/android/WebCoreSupport/FileSystemClient.h @@ -35,7 +35,7 @@ namespace android { class FileSystemClient { public: virtual ~FileSystemClient() { } - virtual String resolveFileNameForContentUri(const String&) = 0; + virtual String resolveFilePathForContentUri(const String&) = 0; }; } #endif diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 006f529..b75cdfc 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -142,10 +142,10 @@ bool PlatformBridge::popupsAllowed(NPP) return false; } -String PlatformBridge::resolveFileNameForContentUri(const String& contentUri) +String PlatformBridge::resolveFilePathForContentUri(const String& contentUri) { FileSystemClient* client = JavaSharedClient::GetFileSystemClient(); - return client->resolveFileNameForContentUri(contentUri); + return client->resolveFilePathForContentUri(contentUri); } } // namespace WebCore diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 2d95f87..6aceb1c 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -85,7 +85,7 @@ public: virtual WTF::Vector<String> getSupportedKeyStrengthList(); virtual WebCore::String getSignedPublicKeyAndChallengeString(unsigned index, const WebCore::String& challenge, const WebCore::KURL& url); - virtual WebCore::String resolveFileNameForContentUri(const WebCore::String& uri); + virtual WebCore::String resolveFilePathForContentUri(const WebCore::String& uri); //////////////////////////////////////////// @@ -122,7 +122,7 @@ private: jmethodID mSignalFuncPtrQueue; jmethodID mGetKeyStrengthList; jmethodID mGetSignedPublicKey; - jmethodID mResolveFileNameForContentUri; + jmethodID mResolveFilePathForContentUri; }; static void (*sSharedTimerFiredCallback)(); @@ -142,7 +142,7 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) mSignalFuncPtrQueue = env->GetMethodID(clazz, "signalServiceFuncPtrQueue", "()V"); mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;"); mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); - mResolveFileNameForContentUri = env->GetMethodID(clazz, "resolveFileNameForContentUri", "(Ljava/lang/String;)Ljava/lang/String;"); + mResolveFilePathForContentUri = env->GetMethodID(clazz, "resolveFilePathForContentUri", "(Ljava/lang/String;)Ljava/lang/String;"); LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer"); LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer"); @@ -314,11 +314,11 @@ WebCore::String JavaBridge::getSignedPublicKeyAndChallengeString(unsigned index, return ret; } -WebCore::String JavaBridge::resolveFileNameForContentUri(const WebCore::String& uri) { +WebCore::String JavaBridge::resolveFilePathForContentUri(const WebCore::String& uri) { JNIEnv* env = JSC::Bindings::getJNIEnv(); jstring jUri = env->NewString(uri.characters(), uri.length()); AutoJObject obj = getRealObject(env, mJavaObject); - jstring path = static_cast<jstring>(env->CallObjectMethod(obj.get(), mResolveFileNameForContentUri, jUri)); + jstring path = static_cast<jstring>(env->CallObjectMethod(obj.get(), mResolveFilePathForContentUri, jUri)); WebCore::String ret = to_string(env, path); env->DeleteLocalRef(jUri); env->DeleteLocalRef(path); |