Changeset 218165 in webkit


Ignore:
Timestamp:
Jun 12, 2017 11:59:23 PM (7 years ago)
Author:
Carlos Garcia Campos
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:
Location:
trunk/Source/WebKit2
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r218164 r218165  
     12017-06-12  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Add API::GeolocationProvider
     4        https://bugs.webkit.org/show_bug.cgi?id=173150
     5
     6        Reviewed by Alex Christensen.
     7
     8        It will be used by GTK+ port instead of the C API.
     9
     10        * UIProcess/API/APIGeolocationProvider.h: Added.
     11        (API::GeolocationProvider::~GeolocationProvider):
     12        (API::GeolocationProvider::startUpdating):
     13        (API::GeolocationProvider::stopUpdating):
     14        (API::GeolocationProvider::setEnableHighAccuracy):
     15        * UIProcess/API/C/WKGeolocationManager.cpp:
     16        (WKGeolocationManagerSetProvider):
     17        * UIProcess/WebGeolocationManagerProxy.cpp:
     18        (WebKit::WebGeolocationManagerProxy::WebGeolocationManagerProxy):
     19        (WebKit::WebGeolocationManagerProxy::setProvider):
     20        (WebKit::WebGeolocationManagerProxy::processPoolDestroyed):
     21        (WebKit::WebGeolocationManagerProxy::startUpdating):
     22        (WebKit::WebGeolocationManagerProxy::removeRequester):
     23        (WebKit::WebGeolocationManagerProxy::setEnableHighAccuracy):
     24        * UIProcess/WebGeolocationManagerProxy.h:
     25        * UIProcess/WebGeolocationProvider.cpp:
     26        (WebKit::WebGeolocationProvider::WebGeolocationProvider):
     27        (WebKit::WebGeolocationProvider::startUpdating):
     28        (WebKit::WebGeolocationProvider::stopUpdating):
     29        (WebKit::WebGeolocationProvider::setEnableHighAccuracy):
     30        * UIProcess/WebGeolocationProvider.h:
     31        * WebKit2.xcodeproj/project.pbxproj:
     32
    1332017-06-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    234
  • trunk/Source/WebKit2/UIProcess/API/APIGeolocationProvider.h

    r218164 r218165  
    11/*
    2  * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017 Igalia S.L.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef WebGeolocationProvider_h
    27 #define WebGeolocationProvider_h
     26#pragma once
    2827
    29 #include "APIClient.h"
    30 #include "WKGeolocationManager.h"
    3128#include <wtf/Forward.h>
    3229
    33 namespace API {
    34 template<> struct ClientTraits<WKGeolocationProviderBase> {
    35     typedef std::tuple<WKGeolocationProviderV0, WKGeolocationProviderV1> Versions;
    36 };
     30namespace WebKit {
     31class WebGeolocationManagerProxy;
    3732}
    3833
    39 namespace WebKit {
     34namespace API {
    4035
    41 class WebGeolocationManagerProxy;
     36class GeolocationProvider {
     37public:
     38    virtual ~GeolocationProvider() { }
    4239
    43 class WebGeolocationProvider : public API::Client<WKGeolocationProviderBase> {
    44 public:
    45     void startUpdating(WebGeolocationManagerProxy*);
    46     void stopUpdating(WebGeolocationManagerProxy*);
    47     void setEnableHighAccuracy(WebGeolocationManagerProxy*, bool);
     40    virtual void startUpdating(WebKit::WebGeolocationManagerProxy&) { };
     41    virtual void stopUpdating(WebKit::WebGeolocationManagerProxy&) { };
     42    virtual void setEnableHighAccuracy(WebKit::WebGeolocationManagerProxy&, bool) { };
    4843};
    4944
    50 } // namespace WebKit
    51 
    52 #endif // WebGeolocationProvider_h
     45} // namespace API
  • trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp

    r176829 r218165  
    3030#include "WebGeolocationManagerProxy.h"
    3131#include "WebGeolocationPosition.h"
     32#include "WebGeolocationProvider.h"
    3233
    3334using namespace WebKit;
     
    4041void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManagerRef, const WKGeolocationProviderBase* wkProvider)
    4142{
    42     toImpl(geolocationManagerRef)->initializeProvider(wkProvider);
     43    toImpl(geolocationManagerRef)->setProvider(std::make_unique<WebGeolocationProvider>(wkProvider));
    4344}
    4445
  • trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp

    r216473 r218165  
    2727#include "WebGeolocationManagerProxy.h"
    2828
     29#include "APIGeolocationProvider.h"
    2930#include "WebGeolocationManagerMessages.h"
    3031#include "WebGeolocationManagerProxyMessages.h"
     
    4546WebGeolocationManagerProxy::WebGeolocationManagerProxy(WebProcessPool* processPool)
    4647    : WebContextSupplement(processPool)
     48    , m_provider(std::make_unique<API::GeolocationProvider>())
    4749{
    4850    WebContextSupplement::processPool()->addMessageReceiver(Messages::WebGeolocationManagerProxy::messageReceiverName(), *this);
    4951}
    5052
    51 void WebGeolocationManagerProxy::initializeProvider(const WKGeolocationProviderBase* provider)
     53void WebGeolocationManagerProxy::setProvider(std::unique_ptr<API::GeolocationProvider> provider)
    5254{
    53     m_provider.initialize(provider);
     55    if (!provider)
     56        m_provider = std::make_unique<API::GeolocationProvider>();
     57    else
     58        m_provider = WTFMove(provider);
    5459}
    5560
     
    6368    ASSERT(!isUpdating());
    6469    if (wasUpdating)
    65         m_provider.stopUpdating(this);
     70        m_provider->stopUpdating(*this);
    6671}
    6772
     
    109114    m_updateRequesters.add(&connection.client());
    110115    if (!wasUpdating) {
    111         m_provider.setEnableHighAccuracy(this, isHighAccuracyEnabled());
    112         m_provider.startUpdating(this);
     116        m_provider->setEnableHighAccuracy(*this, isHighAccuracyEnabled());
     117        m_provider->startUpdating(*this);
    113118    }
    114119}
     
    128133
    129134    if (wasUpdating && !isUpdating())
    130         m_provider.stopUpdating(this);
     135        m_provider->stopUpdating(*this);
    131136    else {
    132137        bool highAccuracyShouldBeEnabled = isHighAccuracyEnabled();
    133138        if (highAccuracyShouldBeEnabled != highAccuracyWasEnabled)
    134             m_provider.setEnableHighAccuracy(this, highAccuracyShouldBeEnabled);
     139            m_provider->setEnableHighAccuracy(*this, highAccuracyShouldBeEnabled);
    135140    }
    136141}
     
    147152    bool highAccuracyShouldBeEnabled = isHighAccuracyEnabled();
    148153    if (isUpdating() && highAccuracyWasEnabled != highAccuracyShouldBeEnabled)
    149         m_provider.setEnableHighAccuracy(this, highAccuracyShouldBeEnabled);
     154        m_provider->setEnableHighAccuracy(*this, highAccuracyShouldBeEnabled);
    150155}
    151156
  • trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h

    r216473 r218165  
    3030#include "MessageReceiver.h"
    3131#include "WebContextSupplement.h"
    32 #include "WebGeolocationProvider.h"
    3332#include <wtf/HashSet.h>
    3433#include <wtf/text/WTFString.h>
     34
     35namespace API {
     36class GeolocationProvider;
     37}
    3538
    3639namespace WebKit {
     
    4548    static Ref<WebGeolocationManagerProxy> create(WebProcessPool*);
    4649
    47     void initializeProvider(const WKGeolocationProviderBase*);
     50    void setProvider(std::unique_ptr<API::GeolocationProvider>);
    4851
    4952    void providerDidChangePosition(WebGeolocationPosition*);
     
    7982    HashSet<const IPC::Connection::Client*> m_highAccuracyRequesters;
    8083
    81     WebGeolocationProvider m_provider;
     84    std::unique_ptr<API::GeolocationProvider> m_provider;
    8285};
    8386
  • trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp

    r159988 r218165  
    3232namespace WebKit {
    3333
    34 void WebGeolocationProvider::startUpdating(WebGeolocationManagerProxy* geolocationManager)
     34WebGeolocationProvider::WebGeolocationProvider(const WKGeolocationProviderBase* provider)
     35{
     36    initialize(provider);
     37}
     38
     39void WebGeolocationProvider::startUpdating(WebGeolocationManagerProxy& geolocationManager)
    3540{
    3641    if (!m_client.startUpdating)
    3742        return;
    3843
    39     m_client.startUpdating(toAPI(geolocationManager), m_client.base.clientInfo);
     44    m_client.startUpdating(toAPI(&geolocationManager), m_client.base.clientInfo);
    4045}
    4146
    42 void WebGeolocationProvider::stopUpdating(WebGeolocationManagerProxy* geolocationManager)
     47void WebGeolocationProvider::stopUpdating(WebGeolocationManagerProxy& geolocationManager)
    4348{
    4449    if (!m_client.stopUpdating)
    4550        return;
    4651
    47     m_client.stopUpdating(toAPI(geolocationManager), m_client.base.clientInfo);
     52    m_client.stopUpdating(toAPI(&geolocationManager), m_client.base.clientInfo);
    4853}
    4954
    50 void WebGeolocationProvider::setEnableHighAccuracy(WebGeolocationManagerProxy* geolocationManager, bool enabled)
     55void WebGeolocationProvider::setEnableHighAccuracy(WebGeolocationManagerProxy& geolocationManager, bool enabled)
    5156{
    5257    if (!m_client.setEnableHighAccuracy)
    5358        return;
    5459
    55     m_client.setEnableHighAccuracy(toAPI(geolocationManager), enabled, m_client.base.clientInfo);
     60    m_client.setEnableHighAccuracy(toAPI(&geolocationManager), enabled, m_client.base.clientInfo);
    5661}
    5762
  • trunk/Source/WebKit2/UIProcess/WebGeolocationProvider.h

    r159994 r218165  
    2828
    2929#include "APIClient.h"
     30#include "APIGeolocationProvider.h"
    3031#include "WKGeolocationManager.h"
    3132#include <wtf/Forward.h>
     
    4142class WebGeolocationManagerProxy;
    4243
    43 class WebGeolocationProvider : public API::Client<WKGeolocationProviderBase> {
     44class WebGeolocationProvider : public API::GeolocationProvider, API::Client<WKGeolocationProviderBase> {
    4445public:
    45     void startUpdating(WebGeolocationManagerProxy*);
    46     void stopUpdating(WebGeolocationManagerProxy*);
    47     void setEnableHighAccuracy(WebGeolocationManagerProxy*, bool);
     46    explicit WebGeolocationProvider(const WKGeolocationProviderBase*);
     47
     48    void startUpdating(WebGeolocationManagerProxy&) override;
     49    void stopUpdating(WebGeolocationManagerProxy&) override;
     50    void setEnableHighAccuracy(WebGeolocationManagerProxy&, bool) override;
    4851};
    4952
  • trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm

    r216794 r218165  
    3434#import "GeolocationPermissionRequestProxy.h"
    3535#import "WKFrameInfoInternal.h"
     36#import "WKGeolocationManager.h"
    3637#import "WKProcessPoolInternal.h"
    3738#import "WKUIDelegatePrivate.h"
     
    162163        setEnableHighAccuracy
    163164    };
    164     _geolocationManager->initializeProvider(reinterpret_cast<WKGeolocationProviderBase*>(&providerCallback));
     165    WKGeolocationManagerSetProvider(toAPI(_geolocationManager.get()), &providerCallback.base);
    165166    _coreLocationProvider = wrapper(processPool)._coreLocationProvider ?: adoptNS(static_cast<id <_WKGeolocationCoreLocationProvider>>([[WKLegacyCoreLocationProvider alloc] init]));
    166167    [_coreLocationProvider setListener:self];
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r218164 r218165  
    12191219                7AAD175F1EA6AF99003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AAD175E1EA6AF37003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm */; };
    12201220                7AB6EA451EEAAE3800037B2B /* APIIconDatabaseClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB6EA441EEAAE2300037B2B /* APIIconDatabaseClient.h */; };
     1221                7AB6EA471EEAB6B800037B2B /* APIGeolocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */; };
    12211222                7AF236201E79A3E400438A05 /* WebErrors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF2361E1E79A3B400438A05 /* WebErrors.cpp */; };
    12221223                7AF236211E79A40800438A05 /* WebErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF2361F1E79A3D800438A05 /* WebErrors.h */; };
     
    35073508                7AAD175E1EA6AF37003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebResourceLoadStatisticsStoreCocoa.mm; sourceTree = "<group>"; };
    35083509                7AB6EA441EEAAE2300037B2B /* APIIconDatabaseClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIIconDatabaseClient.h; sourceTree = "<group>"; };
     3510                7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIGeolocationProvider.h; sourceTree = "<group>"; };
    35093511                7AF2361E1E79A3B400438A05 /* WebErrors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebErrors.cpp; sourceTree = "<group>"; };
    35103512                7AF2361F1E79A3D800438A05 /* WebErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebErrors.h; sourceTree = "<group>"; };
     
    68846886                                2DF9EEE41A781FB400B6CFBE /* APIFrameInfo.h */,
    68856887                                CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */,
     6888                                7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */,
    68866889                                2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */,
    68876890                                93A88B421BC8828C00ABA5C2 /* APIHitTestResult.cpp */,
     
    90529055                                5272D4C91E735F0900EB4290 /* WKProtectionSpaceNS.h in Headers */,
    90539056                                518ACAEA12AEE6BB00B04B83 /* WKProtectionSpaceTypes.h in Headers */,
     9057                                7AB6EA471EEAB6B800037B2B /* APIGeolocationProvider.h in Headers */,
    90549058                                1AD01BCD1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.h in Headers */,
    90559059                                1A9E329B1822E1CC00F5D04C /* WKRemoteObject.h in Headers */,
Note: See TracChangeset for help on using the changeset viewer.