summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-05-18 17:58:24 +0100
committerSteve Block <steveblock@google.com>2012-05-22 14:17:23 +0100
commitdbdd2da378a2c3d2baf2524694cb6e25419f8818 (patch)
tree69dac14113149a28575d9d323ba1b9061519a32b /Source/WebKit/android/WebCoreSupport
parentb80d1c52ad334f34843b52138f0ea684f2683904 (diff)
downloadexternal_webkit-dbdd2da378a2c3d2baf2524694cb6e25419f8818.zip
external_webkit-dbdd2da378a2c3d2baf2524694cb6e25419f8818.tar.gz
external_webkit-dbdd2da378a2c3d2baf2524694cb6e25419f8818.tar.bz2
Hook up client-based Geolocation mock
This simply involves updating GeolocationMock, which is called by DRT from Java, to call the GeolocationClientMock via GeolocationManager, rather than the old GeolocationServiceMock. Note that GeolocationClientMock is tied to a specific page, whereas GeolocationServiceMock had static methods, so we need to pass the WebViewCore from Java. We can now safely exclude the non-client-based files from the build. We pass all Geolocation LayoutTests, except for permission-denied-already-[error|success].html, which are flaky due to https://bugs.webkit.org/show_bug.cgi?id=87033. See corresponding framework change I6d88d5dce5c2148812b191a5b452718bf0854aeb. Bug: 6511338 Change-Id: Ib74a3c05991593e75c3138415d4ac0bf0c9aefa9
Diffstat (limited to 'Source/WebKit/android/WebCoreSupport')
-rw-r--r--Source/WebKit/android/WebCoreSupport/GeolocationManager.cpp43
-rw-r--r--Source/WebKit/android/WebCoreSupport/GeolocationManager.h11
2 files changed, 51 insertions, 3 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/GeolocationManager.cpp b/Source/WebKit/android/WebCoreSupport/GeolocationManager.cpp
index 8d0d6b5..cbf399d 100644
--- a/Source/WebKit/android/WebCoreSupport/GeolocationManager.cpp
+++ b/Source/WebKit/android/WebCoreSupport/GeolocationManager.cpp
@@ -29,22 +29,27 @@
#include "GeolocationClientImpl.h"
#include "WebViewCore.h"
+#include <Frame.h>
#include <GeolocationError.h>
#include <GeolocationPosition.h>
#include <JNIHelp.h>
+#include <Page.h>
using WebCore::GeolocationClient;
+using WebCore::GeolocationClientMock;
namespace android {
GeolocationManager::GeolocationManager(WebViewCore* webViewCore)
- : m_webViewCore(webViewCore)
+ : m_useMock(false)
+ , m_webViewCore(webViewCore)
{
}
GeolocationClient* GeolocationManager::client() const
{
- // TODO: Return the mock client when appropriate. See http://b/6511338.
+ if (m_useMock)
+ return mockClient();
return realClient();
}
@@ -76,6 +81,30 @@ void GeolocationManager::provideRealClientPermissionState(WTF::String origin, bo
m_realClient->providePermissionState(origin, allow, remember);
}
+void GeolocationManager::setUseMock()
+{
+ m_useMock = true;
+ m_mockClient.clear();
+}
+
+void GeolocationManager::setMockPosition(PassRefPtr<WebCore::GeolocationPosition> position)
+{
+ ASSERT(m_useMock);
+ mockClient()->setPosition(position);
+}
+
+void GeolocationManager::setMockError(PassRefPtr<WebCore::GeolocationError> error)
+{
+ ASSERT(m_useMock);
+ mockClient()->setError(error);
+}
+
+void GeolocationManager::setMockPermission(bool allowed)
+{
+ ASSERT(m_useMock);
+ mockClient()->setPermission(allowed);
+}
+
GeolocationClientImpl* GeolocationManager::realClient() const
{
if (!m_realClient)
@@ -83,4 +112,14 @@ GeolocationClientImpl* GeolocationManager::realClient() const
return m_realClient.get();
}
+GeolocationClientMock* GeolocationManager::mockClient() const
+{
+ ASSERT(m_useMock);
+ if (!m_mockClient) {
+ m_mockClient.set(new GeolocationClientMock);
+ m_mockClient->setController(m_webViewCore->mainFrame()->page()->geolocationController());
+ }
+ return m_mockClient.get();
+}
+
} // namespace android
diff --git a/Source/WebKit/android/WebCoreSupport/GeolocationManager.h b/Source/WebKit/android/WebCoreSupport/GeolocationManager.h
index 707cf6f..6459db1 100644
--- a/Source/WebKit/android/WebCoreSupport/GeolocationManager.h
+++ b/Source/WebKit/android/WebCoreSupport/GeolocationManager.h
@@ -28,6 +28,7 @@
#include "GeolocationClientImpl.h"
+#include <GeolocationClientMock.h>
#include <OwnPtr.h>
#include <PassRefPtr.h>
@@ -45,7 +46,6 @@ class WebViewCore;
// may be either the real implementation or a mock. It also handles setting the
// data on the mock client. This class is owned by WebViewCore and exists to
// keep cruft out of that class.
-// TODO: Add support for mock. See b/6511338.
class GeolocationManager {
public:
GeolocationManager(WebViewCore*);
@@ -59,11 +59,20 @@ public:
void resetRealClientTemporaryPermissionStates();
void provideRealClientPermissionState(WTF::String origin, bool allow, bool remember);
+ // Sets use of the Geolocation mock client. Also resets that client.
+ void setUseMock();
+ void setMockPosition(PassRefPtr<WebCore::GeolocationPosition>);
+ void setMockError(PassRefPtr<WebCore::GeolocationError>);
+ void setMockPermission(bool allowed);
+
private:
GeolocationClientImpl* realClient() const;
+ WebCore::GeolocationClientMock* mockClient() const;
+ bool m_useMock;
WebViewCore* m_webViewCore;
mutable OwnPtr<GeolocationClientImpl> m_realClient;
+ mutable OwnPtr<WebCore::GeolocationClientMock> m_mockClient;
};
} // namespace android