Title: [218165] trunk/Source/WebKit2
Revision
218165
Author
carlo...@webkit.org
Date
2017-06-12 23:59:23 -0700 (Mon, 12 Jun 2017)

Log Message

Add API::GeolocationProvider
https://bugs.webkit.org/show_bug.cgi?id=173150

Reviewed by Alex Christensen.

It will be used by GTK+ port instead of the C API.

* UIProcess/API/APIGeolocationProvider.h: Added.
(API::GeolocationProvider::~GeolocationProvider):
(API::GeolocationProvider::startUpdating):
(API::GeolocationProvider::stopUpdating):
(API::GeolocationProvider::setEnableHighAccuracy):
* UIProcess/API/C/WKGeolocationManager.cpp:
(WKGeolocationManagerSetProvider):
* UIProcess/WebGeolocationManagerProxy.cpp:
(WebKit::WebGeolocationManagerProxy::WebGeolocationManagerProxy):
(WebKit::WebGeolocationManagerProxy::setProvider):
(WebKit::WebGeolocationManagerProxy::processPoolDestroyed):
(WebKit::WebGeolocationManagerProxy::startUpdating):
(WebKit::WebGeolocationManagerProxy::removeRequester):
(WebKit::WebGeolocationManagerProxy::setEnableHighAccuracy):
* UIProcess/WebGeolocationManagerProxy.h:
* UIProcess/WebGeolocationProvider.cpp:
(WebKit::WebGeolocationProvider::WebGeolocationProvider):
(WebKit::WebGeolocationProvider::startUpdating):
(WebKit::WebGeolocationProvider::stopUpdating):
(WebKit::WebGeolocationProvider::setEnableHighAccuracy):
* UIProcess/WebGeolocationProvider.h:
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218164 => 218165)


--- trunk/Source/WebKit2/ChangeLog	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-13 06:59:23 UTC (rev 218165)
@@ -1,5 +1,37 @@
 2017-06-12  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        Add API::GeolocationProvider
+        https://bugs.webkit.org/show_bug.cgi?id=173150
+
+        Reviewed by Alex Christensen.
+
+        It will be used by GTK+ port instead of the C API.
+
+        * UIProcess/API/APIGeolocationProvider.h: Added.
+        (API::GeolocationProvider::~GeolocationProvider):
+        (API::GeolocationProvider::startUpdating):
+        (API::GeolocationProvider::stopUpdating):
+        (API::GeolocationProvider::setEnableHighAccuracy):
+        * UIProcess/API/C/WKGeolocationManager.cpp:
+        (WKGeolocationManagerSetProvider):
+        * UIProcess/WebGeolocationManagerProxy.cpp:
+        (WebKit::WebGeolocationManagerProxy::WebGeolocationManagerProxy):
+        (WebKit::WebGeolocationManagerProxy::setProvider):
+        (WebKit::WebGeolocationManagerProxy::processPoolDestroyed):
+        (WebKit::WebGeolocationManagerProxy::startUpdating):
+        (WebKit::WebGeolocationManagerProxy::removeRequester):
+        (WebKit::WebGeolocationManagerProxy::setEnableHighAccuracy):
+        * UIProcess/WebGeolocationManagerProxy.h:
+        * UIProcess/WebGeolocationProvider.cpp:
+        (WebKit::WebGeolocationProvider::WebGeolocationProvider):
+        (WebKit::WebGeolocationProvider::startUpdating):
+        (WebKit::WebGeolocationProvider::stopUpdating):
+        (WebKit::WebGeolocationProvider::setEnableHighAccuracy):
+        * UIProcess/WebGeolocationProvider.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+
+2017-06-12  Carlos Garcia Campos  <cgar...@igalia.com>
+
         Add API::InjectedBundle::PageLoaderClient
         https://bugs.webkit.org/show_bug.cgi?id=173265
 

Copied: trunk/Source/WebKit2/UIProcess/API/APIGeolocationProvider.h (from rev 218164, trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.h) (0 => 218165)


--- trunk/Source/WebKit2/UIProcess/API/APIGeolocationProvider.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/APIGeolocationProvider.h	2017-06-13 06:59:23 UTC (rev 218165)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+
+namespace WebKit {
+class WebGeolocationManagerProxy;
+}
+
+namespace API {
+
+class GeolocationProvider {
+public:
+    virtual ~GeolocationProvider() { }
+
+    virtual void startUpdating(WebKit::WebGeolocationManagerProxy&) { };
+    virtual void stopUpdating(WebKit::WebGeolocationManagerProxy&) { };
+    virtual void setEnableHighAccuracy(WebKit::WebGeolocationManagerProxy&, bool) { };
+};
+
+} // namespace API

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp (218164 => 218165)


--- trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp	2017-06-13 06:59:23 UTC (rev 218165)
@@ -29,6 +29,7 @@
 #include "WKAPICast.h"
 #include "WebGeolocationManagerProxy.h"
 #include "WebGeolocationPosition.h"
+#include "WebGeolocationProvider.h"
 
 using namespace WebKit;
 
@@ -39,7 +40,7 @@
 
 void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManagerRef, const WKGeolocationProviderBase* wkProvider)
 {
-    toImpl(geolocationManagerRef)->initializeProvider(wkProvider);
+    toImpl(geolocationManagerRef)->setProvider(std::make_unique<WebGeolocationProvider>(wkProvider));
 }
 
 void WKGeolocationManagerProviderDidChangePosition(WKGeolocationManagerRef geolocationManagerRef, WKGeolocationPositionRef positionRef)

Modified: trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp (218164 => 218165)


--- trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp	2017-06-13 06:59:23 UTC (rev 218165)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebGeolocationManagerProxy.h"
 
+#include "APIGeolocationProvider.h"
 #include "WebGeolocationManagerMessages.h"
 #include "WebGeolocationManagerProxyMessages.h"
 #include "WebProcessPool.h"
@@ -44,13 +45,17 @@
 
 WebGeolocationManagerProxy::WebGeolocationManagerProxy(WebProcessPool* processPool)
     : WebContextSupplement(processPool)
+    , m_provider(std::make_unique<API::GeolocationProvider>())
 {
     WebContextSupplement::processPool()->addMessageReceiver(Messages::WebGeolocationManagerProxy::messageReceiverName(), *this);
 }
 
-void WebGeolocationManagerProxy::initializeProvider(const WKGeolocationProviderBase* provider)
+void WebGeolocationManagerProxy::setProvider(std::unique_ptr<API::GeolocationProvider> provider)
 {
-    m_provider.initialize(provider);
+    if (!provider)
+        m_provider = std::make_unique<API::GeolocationProvider>();
+    else
+        m_provider = WTFMove(provider);
 }
 
 // WebContextSupplement
@@ -62,7 +67,7 @@
 
     ASSERT(!isUpdating());
     if (wasUpdating)
-        m_provider.stopUpdating(this);
+        m_provider->stopUpdating(*this);
 }
 
 void WebGeolocationManagerProxy::processDidClose(WebProcessProxy* webProcessProxy)
@@ -108,8 +113,8 @@
     bool wasUpdating = isUpdating();
     m_updateRequesters.add(&connection.client());
     if (!wasUpdating) {
-        m_provider.setEnableHighAccuracy(this, isHighAccuracyEnabled());
-        m_provider.startUpdating(this);
+        m_provider->setEnableHighAccuracy(*this, isHighAccuracyEnabled());
+        m_provider->startUpdating(*this);
     }
 }
 
@@ -127,11 +132,11 @@
     m_updateRequesters.remove(client);
 
     if (wasUpdating && !isUpdating())
-        m_provider.stopUpdating(this);
+        m_provider->stopUpdating(*this);
     else {
         bool highAccuracyShouldBeEnabled = isHighAccuracyEnabled();
         if (highAccuracyShouldBeEnabled != highAccuracyWasEnabled)
-            m_provider.setEnableHighAccuracy(this, highAccuracyShouldBeEnabled);
+            m_provider->setEnableHighAccuracy(*this, highAccuracyShouldBeEnabled);
     }
 }
 
@@ -146,7 +151,7 @@
 
     bool highAccuracyShouldBeEnabled = isHighAccuracyEnabled();
     if (isUpdating() && highAccuracyWasEnabled != highAccuracyShouldBeEnabled)
-        m_provider.setEnableHighAccuracy(this, highAccuracyShouldBeEnabled);
+        m_provider->setEnableHighAccuracy(*this, highAccuracyShouldBeEnabled);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h (218164 => 218165)


--- trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h	2017-06-13 06:59:23 UTC (rev 218165)
@@ -29,10 +29,13 @@
 #include "Connection.h"
 #include "MessageReceiver.h"
 #include "WebContextSupplement.h"
-#include "WebGeolocationProvider.h"
 #include <wtf/HashSet.h>
 #include <wtf/text/WTFString.h>
 
+namespace API {
+class GeolocationProvider;
+}
+
 namespace WebKit {
 
 class WebGeolocationPosition;
@@ -44,7 +47,7 @@
 
     static Ref<WebGeolocationManagerProxy> create(WebProcessPool*);
 
-    void initializeProvider(const WKGeolocationProviderBase*);
+    void setProvider(std::unique_ptr<API::GeolocationProvider>);
 
     void providerDidChangePosition(WebGeolocationPosition*);
     void providerDidFailToDeterminePosition(const String& errorMessage = String());
@@ -78,7 +81,7 @@
     HashSet<const IPC::Connection::Client*> m_updateRequesters;
     HashSet<const IPC::Connection::Client*> m_highAccuracyRequesters;
 
-    WebGeolocationProvider m_provider;
+    std::unique_ptr<API::GeolocationProvider> m_provider;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp (218164 => 218165)


--- trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp	2017-06-13 06:59:23 UTC (rev 218165)
@@ -31,28 +31,33 @@
 
 namespace WebKit {
 
-void WebGeolocationProvider::startUpdating(WebGeolocationManagerProxy* geolocationManager)
+WebGeolocationProvider::WebGeolocationProvider(const WKGeolocationProviderBase* provider)
 {
+    initialize(provider);
+}
+
+void WebGeolocationProvider::startUpdating(WebGeolocationManagerProxy& geolocationManager)
+{
     if (!m_client.startUpdating)
         return;
 
-    m_client.startUpdating(toAPI(geolocationManager), m_client.base.clientInfo);
+    m_client.startUpdating(toAPI(&geolocationManager), m_client.base.clientInfo);
 }
 
-void WebGeolocationProvider::stopUpdating(WebGeolocationManagerProxy* geolocationManager)
+void WebGeolocationProvider::stopUpdating(WebGeolocationManagerProxy& geolocationManager)
 {
     if (!m_client.stopUpdating)
         return;
 
-    m_client.stopUpdating(toAPI(geolocationManager), m_client.base.clientInfo);
+    m_client.stopUpdating(toAPI(&geolocationManager), m_client.base.clientInfo);
 }
 
-void WebGeolocationProvider::setEnableHighAccuracy(WebGeolocationManagerProxy* geolocationManager, bool enabled)
+void WebGeolocationProvider::setEnableHighAccuracy(WebGeolocationManagerProxy& geolocationManager, bool enabled)
 {
     if (!m_client.setEnableHighAccuracy)
         return;
 
-    m_client.setEnableHighAccuracy(toAPI(geolocationManager), enabled, m_client.base.clientInfo);
+    m_client.setEnableHighAccuracy(toAPI(&geolocationManager), enabled, m_client.base.clientInfo);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.h (218164 => 218165)


--- trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.h	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.h	2017-06-13 06:59:23 UTC (rev 218165)
@@ -27,6 +27,7 @@
 #define WebGeolocationProvider_h
 
 #include "APIClient.h"
+#include "APIGeolocationProvider.h"
 #include "WKGeolocationManager.h"
 #include <wtf/Forward.h>
 
@@ -40,11 +41,13 @@
 
 class WebGeolocationManagerProxy;
 
-class WebGeolocationProvider : public API::Client<WKGeolocationProviderBase> {
+class WebGeolocationProvider : public API::GeolocationProvider, API::Client<WKGeolocationProviderBase> {
 public:
-    void startUpdating(WebGeolocationManagerProxy*);
-    void stopUpdating(WebGeolocationManagerProxy*);
-    void setEnableHighAccuracy(WebGeolocationManagerProxy*, bool);
+    explicit WebGeolocationProvider(const WKGeolocationProviderBase*);
+
+    void startUpdating(WebGeolocationManagerProxy&) override;
+    void stopUpdating(WebGeolocationManagerProxy&) override;
+    void setEnableHighAccuracy(WebGeolocationManagerProxy&, bool) override;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm (218164 => 218165)


--- trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm	2017-06-13 06:59:23 UTC (rev 218165)
@@ -33,6 +33,7 @@
 #import "CompletionHandlerCallChecker.h"
 #import "GeolocationPermissionRequestProxy.h"
 #import "WKFrameInfoInternal.h"
+#import "WKGeolocationManager.h"
 #import "WKProcessPoolInternal.h"
 #import "WKUIDelegatePrivate.h"
 #import "WKWebView.h"
@@ -161,7 +162,7 @@
         stopUpdatingCallback,
         setEnableHighAccuracy
     };
-    _geolocationManager->initializeProvider(reinterpret_cast<WKGeolocationProviderBase*>(&providerCallback));
+    WKGeolocationManagerSetProvider(toAPI(_geolocationManager.get()), &providerCallback.base);
     _coreLocationProvider = wrapper(processPool)._coreLocationProvider ?: adoptNS(static_cast<id <_WKGeolocationCoreLocationProvider>>([[WKLegacyCoreLocationProvider alloc] init]));
     [_coreLocationProvider setListener:self];
     return self;

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (218164 => 218165)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-06-13 06:28:48 UTC (rev 218164)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-06-13 06:59:23 UTC (rev 218165)
@@ -1218,6 +1218,7 @@
 		7A821F501E2F7A7500604577 /* APICustomProtocolManagerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */; };
 		7AAD175F1EA6AF99003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AAD175E1EA6AF37003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm */; };
 		7AB6EA451EEAAE3800037B2B /* APIIconDatabaseClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB6EA441EEAAE2300037B2B /* APIIconDatabaseClient.h */; };
+		7AB6EA471EEAB6B800037B2B /* APIGeolocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */; };
 		7AF236201E79A3E400438A05 /* WebErrors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF2361E1E79A3B400438A05 /* WebErrors.cpp */; };
 		7AF236211E79A40800438A05 /* WebErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF2361F1E79A3D800438A05 /* WebErrors.h */; };
 		7AF236231E79A44400438A05 /* WebErrorsCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AF236221E79A43100438A05 /* WebErrorsCocoa.mm */; };
@@ -3506,6 +3507,7 @@
 		7A9CD8C21C779AD600D9F6C7 /* WebResourceLoadStatisticsStore.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebResourceLoadStatisticsStore.messages.in; sourceTree = "<group>"; };
 		7AAD175E1EA6AF37003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebResourceLoadStatisticsStoreCocoa.mm; sourceTree = "<group>"; };
 		7AB6EA441EEAAE2300037B2B /* APIIconDatabaseClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIIconDatabaseClient.h; sourceTree = "<group>"; };
+		7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIGeolocationProvider.h; sourceTree = "<group>"; };
 		7AF2361E1E79A3B400438A05 /* WebErrors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebErrors.cpp; sourceTree = "<group>"; };
 		7AF2361F1E79A3D800438A05 /* WebErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebErrors.h; sourceTree = "<group>"; };
 		7AF236221E79A43100438A05 /* WebErrorsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebErrorsCocoa.mm; sourceTree = "<group>"; };
@@ -6883,6 +6885,7 @@
 				2DF9EEE31A781FB400B6CFBE /* APIFrameInfo.cpp */,
 				2DF9EEE41A781FB400B6CFBE /* APIFrameInfo.h */,
 				CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */,
+				7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */,
 				2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */,
 				93A88B421BC8828C00ABA5C2 /* APIHitTestResult.cpp */,
 				93A88B431BC8828C00ABA5C2 /* APIHitTestResult.h */,
@@ -9051,6 +9054,7 @@
 				512F58FC12A88A5400629530 /* WKProtectionSpace.h in Headers */,
 				5272D4C91E735F0900EB4290 /* WKProtectionSpaceNS.h in Headers */,
 				518ACAEA12AEE6BB00B04B83 /* WKProtectionSpaceTypes.h in Headers */,
+				7AB6EA471EEAB6B800037B2B /* APIGeolocationProvider.h in Headers */,
 				1AD01BCD1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.h in Headers */,
 				1A9E329B1822E1CC00F5D04C /* WKRemoteObject.h in Headers */,
 				1A9E329F1822FEDD00F5D04C /* WKRemoteObjectCoder.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to