diff options
author | Andrei Popescu <andreip@google.com> | 2010-02-09 04:25:48 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-02-09 04:25:48 -0800 |
commit | ece0a38a9778edd2ae7a550df7dcd38d1e11e7d0 (patch) | |
tree | 68ebac8b5ff2d29cab406565aa5ad9f815204911 | |
parent | 354222b9bea6bc30d0639780b6d527ae7e9cfb76 (diff) | |
parent | 151150803320bb522017b71c36e1855764d640f8 (diff) | |
download | external_webkit-ece0a38a9778edd2ae7a550df7dcd38d1e11e7d0.zip external_webkit-ece0a38a9778edd2ae7a550df7dcd38d1e11e7d0.tar.gz external_webkit-ece0a38a9778edd2ae7a550df7dcd38d1e11e7d0.tar.bz2 |
Merge "Implement navigator.isApplicationInstalled() API"
-rw-r--r-- | WebCore/Android.derived.v8bindings.mk | 2 | ||||
-rw-r--r-- | WebCore/Android.v8bindings.mk | 1 | ||||
-rw-r--r-- | WebCore/bindings/v8/custom/V8NavigatorCustom.cpp | 48 | ||||
-rw-r--r-- | WebCore/config.h | 2 | ||||
-rw-r--r-- | WebCore/page/Navigator.cpp | 16 | ||||
-rw-r--r-- | WebCore/page/Navigator.h | 12 | ||||
-rw-r--r-- | WebCore/page/Navigator.idl | 5 |
7 files changed, 79 insertions, 7 deletions
diff --git a/WebCore/Android.derived.v8bindings.mk b/WebCore/Android.derived.v8bindings.mk index b598f7e..e4e6796 100644 --- a/WebCore/Android.derived.v8bindings.mk +++ b/WebCore/Android.derived.v8bindings.mk @@ -31,7 +31,7 @@ js_binding_scripts := \ $(LOCAL_PATH)/bindings/scripts/generate-bindings.pl # Add ACCELERATED_COMPOSITING=1 and ENABLE_3D_RENDERING=1 for layers support -FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 V8_BINDING ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_WORKERS=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 +FEATURE_DEFINES := ENABLE_ORIENTATION_EVENTS=1 ENABLE_TOUCH_EVENTS=1 V8_BINDING ENABLE_DATABASE=1 ENABLE_OFFLINE_WEB_APPLICATIONS=1 ENABLE_DOM_STORAGE=1 ENABLE_WORKERS=1 ENABLE_VIDEO=1 ENABLE_GEOLOCATION=1 ENABLE_CONNECTION=1 ENABLE_APPLICATION_INSTALLED=1 # CSS GEN := \ diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk index b7c9400..602185c 100644 --- a/WebCore/Android.v8bindings.mk +++ b/WebCore/Android.v8bindings.mk @@ -102,6 +102,7 @@ LOCAL_SRC_FILES += \ bindings/v8/custom/V8ClipboardCustom.cpp \ bindings/v8/custom/V8ConsoleCustom.cpp \ bindings/v8/custom/V8CoordinatesCustom.cpp \ + bindings/v8/custom/V8CustomApplicationInstalledCallback.cpp \ bindings/v8/custom/V8CustomEventListener.cpp \ bindings/v8/custom/V8CustomPositionCallback.cpp \ bindings/v8/custom/V8CustomPositionErrorCallback.cpp \ diff --git a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp index 266745d..c3c406e 100644 --- a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp @@ -32,6 +32,12 @@ #include "V8Navigator.h" #include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8Proxy.h" + +#if PLATFORM(ANDROID) +#include "V8CustomApplicationInstalledCallback.h" +#endif namespace WebCore { @@ -42,4 +48,46 @@ bool V8Navigator::GeolocationEnabled() } #endif +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) + +static PassRefPtr<ApplicationInstalledCallback> createApplicationInstalledCallback( + v8::Local<v8::Value> value, bool& succeeded) +{ + succeeded = true; + + if (!value->IsFunction()) { + succeeded = false; + throwError("The second argument should be a function"); + return 0; + } + + Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); + return V8CustomApplicationInstalledCallback::create(value, frame); +} + +v8::Handle<v8::Value> V8Navigator::isApplicationInstalledCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.isApplicationInstalled()"); + bool succeeded = false; + + if (args.Length() < 2) + return throwError("Two arguments required: an application name and a callback.", V8Proxy::SyntaxError); + + if (!args[0]->IsString()) + return throwError("The first argument should be a string."); + + RefPtr<ApplicationInstalledCallback> callback = + createApplicationInstalledCallback(args[1], succeeded); + if (!succeeded) + return v8::Undefined(); + + ASSERT(callback); + + Navigator* navigator = V8Navigator::toNative(args.Holder()); + navigator->isApplicationInstalled(toWebCoreString(args[0]), callback.release()); + return v8::Undefined(); +} + +#endif // PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) + } // namespace WebCore diff --git a/WebCore/config.h b/WebCore/config.h index b8f3a05..4a532b8 100644 --- a/WebCore/config.h +++ b/WebCore/config.h @@ -123,6 +123,8 @@ #undef ENABLE_INSPECTOR // Enabled by default in Platform.h #define ENABLE_INSPECTOR 0 #define ENABLE_EVENT_SOURCE 0 +#undef ENABLE_APPLICATION_INSTALLED +#define ENABLE_APPLICATION_INSTALLED 1 #define FLATTEN_FRAMESET #define FLATTEN_IFRAME diff --git a/WebCore/page/Navigator.cpp b/WebCore/page/Navigator.cpp index bcc302f..3c0424f 100644 --- a/WebCore/page/Navigator.cpp +++ b/WebCore/page/Navigator.cpp @@ -25,9 +25,6 @@ #include "Chrome.h" #include "CookieJar.h" -#if PLATFORM(ANDROID) -#include "Connection.h" -#endif #include "ExceptionCode.h" #include "Frame.h" #include "FrameLoader.h" @@ -45,6 +42,11 @@ #include "Settings.h" #include "StorageNamespace.h" +#if PLATFORM(ANDROID) +#include "ApplicationInstalledCallback.h" +#include "Connection.h" +#endif + namespace WebCore { Navigator::Navigator(Frame* frame) @@ -168,6 +170,14 @@ Connection* Navigator::connection() const } #endif +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) +void Navigator::isApplicationInstalled(const String& name, PassRefPtr<ApplicationInstalledCallback> callback) +{ + //TODO(implement); + callback->handleEvent(false); +} +#endif + #if ENABLE(DOM_STORAGE) void Navigator::getStorageUpdates() { diff --git a/WebCore/page/Navigator.h b/WebCore/page/Navigator.h index 9967fba..83ed83f 100644 --- a/WebCore/page/Navigator.h +++ b/WebCore/page/Navigator.h @@ -27,15 +27,17 @@ namespace WebCore { -#if PLATFORM(ANDROID) - class Connection; -#endif class Frame; class Geolocation; class MimeTypeArray; class PluginData; class PluginArray; class String; +#if PLATFORM(ANDROID) + class ApplicationInstalledCallback; + class Connection; +#endif + typedef int ExceptionCode; @@ -64,6 +66,10 @@ namespace WebCore { Connection* connection() const; #endif +#if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) + void isApplicationInstalled(const String& name, PassRefPtr<ApplicationInstalledCallback> callback); +#endif + #if ENABLE(DOM_STORAGE) // Relinquishes the storage lock, if one exists. void getStorageUpdates(); diff --git a/WebCore/page/Navigator.idl b/WebCore/page/Navigator.idl index 215316f..8eae9d6 100644 --- a/WebCore/page/Navigator.idl +++ b/WebCore/page/Navigator.idl @@ -45,6 +45,11 @@ module window { readonly attribute Connection connection; #endif +#if defined(ENABLE_APPLICATION_INSTALLED) && ENABLE_APPLICATION_INSTALLED + // ANDROID-only for now. + [Custom] void isApplicationInstalled(in DOMString applicationName, in ApplicationInstalledCallback callback); +#endif + #if defined(ENABLE_GEOLOCATION) && ENABLE_GEOLOCATION readonly attribute [EnabledAtRuntime] Geolocation geolocation; #endif |