summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-06-28 10:25:04 +0100
committerSteve Block <steveblock@google.com>2010-06-29 12:29:10 +0100
commite07f6aabbe877315688b586c09a36cbe02b7a2a1 (patch)
tree4a8d4500cfb3b5781b3067305faeca3fbd8e58e9 /WebCore/platform
parenta3054d2b31d3e00563e3865d398ef93d25b8b2e0 (diff)
downloadexternal_webkit-e07f6aabbe877315688b586c09a36cbe02b7a2a1.zip
external_webkit-e07f6aabbe877315688b586c09a36cbe02b7a2a1.tar.gz
external_webkit-e07f6aabbe877315688b586c09a36cbe02b7a2a1.tar.bz2
Pass the WebView context to the GeolocationService from WebKit
Bug: 2798745 Change-Id: I429a1cb9fc6826419c62f1f30376692ede497085
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/android/GeolocationServiceAndroid.cpp11
-rw-r--r--WebCore/platform/android/GeolocationServiceBridge.cpp10
-rw-r--r--WebCore/platform/android/GeolocationServiceBridge.h5
3 files changed, 19 insertions, 7 deletions
diff --git a/WebCore/platform/android/GeolocationServiceAndroid.cpp b/WebCore/platform/android/GeolocationServiceAndroid.cpp
index 12a9098..64f68f1 100644
--- a/WebCore/platform/android/GeolocationServiceAndroid.cpp
+++ b/WebCore/platform/android/GeolocationServiceAndroid.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "GeolocationServiceAndroid.h"
+#include "Geolocation.h"
#include "GeolocationServiceBridge.h"
#include "Geoposition.h"
#include "PositionError.h"
@@ -69,6 +70,14 @@ GeolocationServiceAndroid::GeolocationServiceAndroid(GeolocationServiceClient* c
// TODO: Upstream to webkit.org. See https://bugs.webkit.org/show_bug.cgi?id=34082
bool GeolocationServiceAndroid::startUpdating(PositionOptions* options, bool suspend)
{
+ // ANDROID
+ // This is an ugly hack. A correct fix would require a change to WebCore,
+ // but this isn't worth the effort as we're in the process of switching to a
+ // client-based implementation. See https://bugs.webkit.org/show_bug.cgi?id=40373
+ Frame* frame = reinterpret_cast<Geolocation*>(geolocationServiceClient())->frame();
+ if (!frame)
+ return false;
+
// This method is called every time a new watch or one-shot position request
// is started. If we already have a position or an error, call back
// immediately.
@@ -80,7 +89,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));
+ m_javaBridge.set(new GeolocationServiceBridge(this, frame));
ASSERT(m_javaBridge);
// On Android, high power == GPS. Set whether to use GPS before we start the
diff --git a/WebCore/platform/android/GeolocationServiceBridge.cpp b/WebCore/platform/android/GeolocationServiceBridge.cpp
index be68193..837b338 100644
--- a/WebCore/platform/android/GeolocationServiceBridge.cpp
+++ b/WebCore/platform/android/GeolocationServiceBridge.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "GeolocationServiceBridge.h"
+#include "Frame.h"
#include "GeolocationServiceAndroid.h"
#include "Geoposition.h"
#include "PositionError.h"
@@ -70,12 +71,12 @@ enum javaLocationClassMethods {
};
static jmethodID javaLocationClassMethodIDs[LocationMethodCount];
-GeolocationServiceBridge::GeolocationServiceBridge(ListenerInterface* listener)
+GeolocationServiceBridge::GeolocationServiceBridge(ListenerInterface* listener, Frame* frame)
: m_listener(listener)
, m_javaGeolocationServiceObject(0)
{
ASSERT(m_listener);
- startJavaImplementation();
+ startJavaImplementation(frame);
}
GeolocationServiceBridge::~GeolocationServiceBridge()
@@ -165,7 +166,7 @@ PassRefPtr<Geoposition> GeolocationServiceBridge::toGeoposition(JNIEnv *env, con
env->CallLongMethod(location, javaLocationClassMethodIDs[LocationMethodGetTime]));
}
-void GeolocationServiceBridge::startJavaImplementation()
+void GeolocationServiceBridge::startJavaImplementation(Frame* frame)
{
JNIEnv* env = getJNIEnv();
@@ -175,7 +176,7 @@ void GeolocationServiceBridge::startJavaImplementation()
// Set up the methods we wish to call on the Java GeolocationService class.
javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodInit] =
- env->GetMethodID(javaGeolocationServiceClass, "<init>", "(J)V");
+ env->GetMethodID(javaGeolocationServiceClass, "<init>", "(Landroid/content/Context;J)V");
javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodStart] =
env->GetMethodID(javaGeolocationServiceClass, "start", "()Z");
javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodStop] =
@@ -187,6 +188,7 @@ void GeolocationServiceBridge::startJavaImplementation()
jlong nativeObject = reinterpret_cast<jlong>(this);
jobject object = env->NewObject(javaGeolocationServiceClass,
javaGeolocationServiceClassMethodIDs[GeolocationServiceMethodInit],
+ android::WebViewCore::getWebViewCore(frame->view())->getContext(),
nativeObject);
m_javaGeolocationServiceObject = getJNIEnv()->NewGlobalRef(object);
diff --git a/WebCore/platform/android/GeolocationServiceBridge.h b/WebCore/platform/android/GeolocationServiceBridge.h
index 5d26142..3997d65 100644
--- a/WebCore/platform/android/GeolocationServiceBridge.h
+++ b/WebCore/platform/android/GeolocationServiceBridge.h
@@ -31,6 +31,7 @@
namespace WebCore {
+class Frame;
class GeolocationServiceAndroid;
class Geoposition;
@@ -40,7 +41,7 @@ class Geoposition;
class GeolocationServiceBridge {
public:
typedef GeolocationServiceAndroid ListenerInterface;
- GeolocationServiceBridge(ListenerInterface* listener);
+ GeolocationServiceBridge(ListenerInterface* listener, Frame* frame);
~GeolocationServiceBridge();
bool start();
@@ -53,7 +54,7 @@ public:
static PassRefPtr<Geoposition> toGeoposition(JNIEnv *env, const jobject &location);
private:
- void startJavaImplementation();
+ void startJavaImplementation(Frame* frame);
void stopJavaImplementation();
ListenerInterface* m_listener;