diff options
author | Steve Block <steveblock@google.com> | 2012-05-17 18:36:32 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2012-05-18 12:16:12 +0100 |
commit | 0769e328661adb91472349fbfa3a5474a1f7ee0d (patch) | |
tree | 6ce8f5d3ab3c6f3cfd2fb3c18826092f1bdae9ff /Source | |
parent | 084a2f00a6b30ce87ec8a8eabbea3ac9cbfa6e7e (diff) | |
download | external_webkit-0769e328661adb91472349fbfa3a5474a1f7ee0d.zip external_webkit-0769e328661adb91472349fbfa3a5474a1f7ee0d.tar.gz external_webkit-0769e328661adb91472349fbfa3a5474a1f7ee0d.tar.bz2 |
Move GeolocationServiceBridge to WebKit/android/jni and extract Listener interface
Also modify GeolocationServiceBridge to take a WebViewCore rather than a Frame.
This will simplify the transition to client-based implementation, which will
re-use GeolocationServiceBridge.
No functional change.
Bug: 6511338
Change-Id: I2de9dfed51d785c85b40f362f20189f208adf6ec
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/Android.mk | 1 | ||||
-rw-r--r-- | Source/WebCore/platform/android/GeolocationServiceAndroid.cpp | 8 | ||||
-rw-r--r-- | Source/WebCore/platform/android/GeolocationServiceAndroid.h | 21 | ||||
-rw-r--r-- | Source/WebKit/Android.mk | 1 | ||||
-rw-r--r-- | Source/WebKit/android/jni/GeolocationServiceBridge.cpp (renamed from Source/WebCore/platform/android/GeolocationServiceBridge.cpp) | 27 | ||||
-rw-r--r-- | Source/WebKit/android/jni/GeolocationServiceBridge.h (renamed from Source/WebCore/platform/android/GeolocationServiceBridge.h) | 31 |
6 files changed, 51 insertions, 38 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk index 742fade..677da4b 100644 --- a/Source/WebCore/Android.mk +++ b/Source/WebCore/Android.mk @@ -577,7 +577,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/android/FileChooserAndroid.cpp \ platform/android/FileSystemAndroid.cpp \ platform/android/GeolocationServiceAndroid.cpp \ - platform/android/GeolocationServiceBridge.cpp \ platform/android/KeyEventAndroid.cpp \ platform/android/LanguageAndroid.cpp \ platform/android/LocalizedStringsAndroid.cpp \ diff --git a/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp b/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp index 0f07722..9ea0362 100644 --- a/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp +++ b/Source/WebCore/platform/android/GeolocationServiceAndroid.cpp @@ -26,12 +26,14 @@ #include "config.h" #include "GeolocationServiceAndroid.h" +#include "Frame.h" #include "Geolocation.h" -#include "GeolocationServiceBridge.h" #include "Geoposition.h" #include "PositionError.h" #include "PositionOptions.h" +#include <WebViewCore.h> + #if PLATFORM(ANDROID) // Required for sim-eng build #include <math.h> @@ -39,6 +41,8 @@ #include <wtf/CurrentTime.h> using JSC::Bindings::getJNIEnv; +using android::GeolocationServiceBridge; +using android::WebViewCore; using namespace std; namespace WebCore { @@ -89,7 +93,7 @@ bool GeolocationServiceAndroid::startUpdating(PositionOptions* options, bool sus // Lazilly create the Java object. bool haveJavaBridge = m_javaBridge; if (!haveJavaBridge) - m_javaBridge.set(new GeolocationServiceBridge(this, frame)); + m_javaBridge.set(new GeolocationServiceBridge(this, WebViewCore::getWebViewCore(frame->view()))); ASSERT(m_javaBridge); // On Android, high power == GPS. Set whether to use GPS before we start the diff --git a/Source/WebCore/platform/android/GeolocationServiceAndroid.h b/Source/WebCore/platform/android/GeolocationServiceAndroid.h index 72532f6..47c3ffe 100644 --- a/Source/WebCore/platform/android/GeolocationServiceAndroid.h +++ b/Source/WebCore/platform/android/GeolocationServiceAndroid.h @@ -28,37 +28,34 @@ #include "GeolocationService.h" #include "Timer.h" + +#include <GeolocationServiceBridge.h> #include <wtf/OwnPtr.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> namespace WebCore { -// The GeolocationServiceBridge is the bridge to the Java implementation of -// the Geolocation service. It is an implementation detail of -// GeolocationServiceAndroid. -class GeolocationServiceBridge; - -class GeolocationServiceAndroid : public GeolocationService { +class GeolocationServiceAndroid : public GeolocationService, public android::GeolocationServiceBridge::Listener { public: static GeolocationService* create(GeolocationServiceClient*); virtual ~GeolocationServiceAndroid() { }; + // GeolocationService // ANDROID // TODO: Upstream to webkit.org. See https://bugs.webkit.org/show_bug.cgi?id=34082 virtual bool startUpdating(PositionOptions*, bool suspend); virtual void stopUpdating(); - virtual Geoposition* lastPosition() const { return m_lastPosition.get(); } virtual PositionError* lastError() const { return m_lastError.get(); } - virtual void suspend(); virtual void resume(); - // Android-specific - void newPositionAvailable(PassRefPtr<Geoposition>); - void newErrorAvailable(PassRefPtr<PositionError>); + // android::GeolocationServiceBridge::Listener + virtual void newPositionAvailable(PassRefPtr<Geoposition>); + virtual void newErrorAvailable(PassRefPtr<PositionError>); + void timerFired(Timer<GeolocationServiceAndroid>* timer); private: @@ -71,7 +68,7 @@ private: Timer<GeolocationServiceAndroid> m_timer; RefPtr<Geoposition> m_lastPosition; RefPtr<PositionError> m_lastError; - OwnPtr<GeolocationServiceBridge> m_javaBridge; + OwnPtr<android::GeolocationServiceBridge> m_javaBridge; }; } // namespace WebCore diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk index c3e9798..a27576b 100644 --- a/Source/WebKit/Android.mk +++ b/Source/WebKit/Android.mk @@ -61,6 +61,7 @@ LOCAL_SRC_FILES += \ android/jni/DeviceMotionClientImpl.cpp \ android/jni/DeviceOrientationClientImpl.cpp \ android/jni/GeolocationPermissionsBridge.cpp \ + android/jni/GeolocationServiceBridge.cpp \ android/jni/JavaBridge.cpp \ android/jni/JavaSharedClient.cpp \ android/jni/MIMETypeRegistry.cpp \ diff --git a/Source/WebCore/platform/android/GeolocationServiceBridge.cpp b/Source/WebKit/android/jni/GeolocationServiceBridge.cpp index 697b63b..044131f 100644 --- a/Source/WebCore/platform/android/GeolocationServiceBridge.cpp +++ b/Source/WebKit/android/jni/GeolocationServiceBridge.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, The Android Open Source Project + * Copyright 2012, The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,16 +26,19 @@ #include "config.h" #include "GeolocationServiceBridge.h" -#include "Frame.h" #include "GeolocationServiceAndroid.h" -#include "Geoposition.h" -#include "PositionError.h" #include "WebViewCore.h" -#include <JNIHelp.h> -namespace WebCore { +#include <Geoposition.h> +#include <JNIHelp.h> +#include <PositionError.h> using JSC::Bindings::getJNIEnv; +using WebCore::Coordinates; +using WebCore::Geoposition; +using WebCore::PositionError; + +namespace android { static const char* javaGeolocationServiceClassName = "android/webkit/GeolocationService"; enum javaGeolocationServiceClassMethods { @@ -71,12 +74,12 @@ enum javaLocationClassMethods { }; static jmethodID javaLocationClassMethodIDs[LocationMethodCount]; -GeolocationServiceBridge::GeolocationServiceBridge(ListenerInterface* listener, Frame* frame) +GeolocationServiceBridge::GeolocationServiceBridge(Listener* listener, WebViewCore* webViewCore) : m_listener(listener) , m_javaGeolocationServiceObject(0) { ASSERT(m_listener); - startJavaImplementation(frame); + startJavaImplementation(webViewCore); } GeolocationServiceBridge::~GeolocationServiceBridge() @@ -155,7 +158,7 @@ PassRefPtr<Geoposition> GeolocationServiceBridge::toGeoposition(JNIEnv *env, con env->CallFloatMethod(location, javaLocationClassMethodIDs[LocationMethodGetSpeed]) : 0.0; - RefPtr<Coordinates> newCoordinates = WebCore::Coordinates::create( + RefPtr<Coordinates> newCoordinates = Coordinates::create( env->CallDoubleMethod(location, javaLocationClassMethodIDs[LocationMethodGetLatitude]), env->CallDoubleMethod(location, javaLocationClassMethodIDs[LocationMethodGetLongitude]), hasAltitude, Altitude, @@ -164,12 +167,12 @@ PassRefPtr<Geoposition> GeolocationServiceBridge::toGeoposition(JNIEnv *env, con hasHeading, heading, hasSpeed, speed); - return WebCore::Geoposition::create( + return Geoposition::create( newCoordinates.release(), env->CallLongMethod(location, javaLocationClassMethodIDs[LocationMethodGetTime])); } -void GeolocationServiceBridge::startJavaImplementation(Frame* frame) +void GeolocationServiceBridge::startJavaImplementation(WebViewCore* webViewCore) { JNIEnv* env = getJNIEnv(); @@ -188,7 +191,7 @@ void GeolocationServiceBridge::startJavaImplementation(Frame* frame) env->GetMethodID(javaGeolocationServiceClass, "setEnableGps", "(Z)V"); // Create the Java GeolocationService object. - jobject context = android::WebViewCore::getWebViewCore(frame->view())->getContext(); + jobject context = webViewCore->getContext(); if (!context) return; jlong nativeObject = reinterpret_cast<jlong>(this); diff --git a/Source/WebCore/platform/android/GeolocationServiceBridge.h b/Source/WebKit/android/jni/GeolocationServiceBridge.h index 3997d65..1813984 100644 --- a/Source/WebCore/platform/android/GeolocationServiceBridge.h +++ b/Source/WebKit/android/jni/GeolocationServiceBridge.h @@ -1,5 +1,5 @@ /* - * Copyright 2009, The Android Open Source Project + * Copyright 2012, The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,22 +26,31 @@ #ifndef GeolocationServiceBridge_h #define GeolocationServiceBridge_h -#include "JNIUtility.h" +#include <JNIUtility.h> #include <wtf/PassRefPtr.h> namespace WebCore { - -class Frame; -class GeolocationServiceAndroid; class Geoposition; +class PositionError; +} + +namespace android { + +class WebViewCore; // GeolocationServiceBridge is the bridge to the Java implementation. It manages // the lifetime of the Java object. It is an implementation detail of // GeolocationServiceAndroid. class GeolocationServiceBridge { public: - typedef GeolocationServiceAndroid ListenerInterface; - GeolocationServiceBridge(ListenerInterface* listener, Frame* frame); + class Listener { + public: + virtual ~Listener() {} + virtual void newPositionAvailable(PassRefPtr<WebCore::Geoposition>) = 0; + virtual void newErrorAvailable(PassRefPtr<WebCore::PositionError>) = 0; + }; + + GeolocationServiceBridge(Listener*, WebViewCore*); ~GeolocationServiceBridge(); bool start(); @@ -51,16 +60,16 @@ public: // Static wrapper functions to hide JNI nastiness. static void newLocationAvailable(JNIEnv *env, jclass, jlong nativeObject, jobject location); static void newErrorAvailable(JNIEnv *env, jclass, jlong nativeObject, jstring message); - static PassRefPtr<Geoposition> toGeoposition(JNIEnv *env, const jobject &location); + static PassRefPtr<WebCore::Geoposition> toGeoposition(JNIEnv *env, const jobject &location); private: - void startJavaImplementation(Frame* frame); + void startJavaImplementation(WebViewCore*); void stopJavaImplementation(); - ListenerInterface* m_listener; + Listener* m_listener; jobject m_javaGeolocationServiceObject; }; -} // namespace WebCore +} // namespace android #endif // GeolocationServiceBridge_h |