Changeset 73163 in webkit


Ignore:
Timestamp:
Dec 2, 2010 10:59:07 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-12-02 John Knottenbelt <jknotten@chromium.org>

Reviewed by Steve Block.

Move requestGeolocationPermissionForFrame to GeolocationClient
https://bugs.webkit.org/show_bug.cgi?id=50061

This change facilitates client-based geolocation implementation by
bringing together permission control into the geolocation client
interface.

  • page/Chrome.h:
  • page/ChromeClient.h:
  • page/Geolocation.cpp: (WebCore::Geolocation::disconnectFrame): (WebCore::Geolocation::requestPermission):
  • page/GeolocationClient.h:
  • page/GeolocationController.cpp: (WebCore::GeolocationController::requestPermission): (WebCore::GeolocationController::cancelPermissionRequest):
  • page/GeolocationController.h:
  • platform/mock/GeolocationClientMock.cpp: (WebCore::GeolocationClientMock::GeolocationClientMock): (WebCore::GeolocationClientMock::setPermission): (WebCore::GeolocationClientMock::requestPermission): (WebCore::GeolocationClientMock::cancelPermissionRequest): (WebCore::GeolocationClientMock::asyncUpdatePermission): (WebCore::GeolocationClientMock::permissionTimerFired): (WebCore::GeolocationClientMock::reset): (WebCore::GeolocationClientMock::stopUpdating): (WebCore::GeolocationClientMock::asyncUpdateController): (WebCore::GeolocationClientMock::controllerTimerFired):
  • platform/mock/GeolocationClientMock.h:

2010-12-02 John Knottenbelt <jknotten@chromium.org>

Reviewed by Steve Block.

Move requestGeolocationPermissionForFrame to GeolocationClient
https://bugs.webkit.org/show_bug.cgi?id=50061

This change facilitates client-based geolocation implementation by
bringing together permission control into the geolocation client
interface.

Move method ChromeClient::requestGeolocationPermissionForFrame to
GeolocationClient::requestPermission, and supporting class
WebGeolocationPolicyListener. The moved code is unchanged except
that requestPermission now takes only one argument (Geolocation*)
and the Frame parameter is retrieved from the Geolocation object.

  • WebCoreSupport/WebChromeClient.h:
  • WebCoreSupport/WebChromeClient.mm:
  • WebCoreSupport/WebGeolocationClient.h: (WebGeolocationClient::cancelPermissionRequest):
  • WebCoreSupport/WebGeolocationClient.mm: (WebGeolocationClient::requestPermission): (-[WebGeolocationPolicyListener initWithGeolocation:]): (-[WebGeolocationPolicyListener allow]): (-[WebGeolocationPolicyListener deny]):

2010-12-02 John Knottenbelt <jknotten@chromium.org>

Reviewed by Steve Block.

Move requestGeolocationPermissionForFrame to GeolocationClient
https://bugs.webkit.org/show_bug.cgi?id=50061

This change facilitates client-based geolocation implementation by
bringing together permission control into the geolocation client
interface.

Move method ChromeClient::requestGeolocationPermissionForFrame to
GeolocationClient::requestPermission. The moved code is unchanged
except that requestPermission now takes only one argument (Geolocation*),
the Frame parameter is retrieved from the Geolocation object and we need to
call m_webView.get() as it is a COMPtr in GeolocationClient.

  • WebCoreSupport/WebChromeClient.cpp:
  • WebCoreSupport/WebChromeClient.h:
  • WebCoreSupport/WebGeolocationClient.cpp: (WebGeolocationClient::requestPermission):
  • WebCoreSupport/WebGeolocationClient.h: (WebGeolocationClient::cancelPermissionRequest):
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r73152 r73163  
     12010-12-02  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Move requestGeolocationPermissionForFrame to GeolocationClient
     6        https://bugs.webkit.org/show_bug.cgi?id=50061
     7
     8        This change facilitates client-based geolocation implementation by
     9        bringing together permission control into the geolocation client
     10        interface.
     11
     12        * page/Chrome.h:
     13        * page/ChromeClient.h:
     14        * page/Geolocation.cpp:
     15        (WebCore::Geolocation::disconnectFrame):
     16        (WebCore::Geolocation::requestPermission):
     17        * page/GeolocationClient.h:
     18        * page/GeolocationController.cpp:
     19        (WebCore::GeolocationController::requestPermission):
     20        (WebCore::GeolocationController::cancelPermissionRequest):
     21        * page/GeolocationController.h:
     22        * platform/mock/GeolocationClientMock.cpp:
     23        (WebCore::GeolocationClientMock::GeolocationClientMock):
     24        (WebCore::GeolocationClientMock::setPermission):
     25        (WebCore::GeolocationClientMock::requestPermission):
     26        (WebCore::GeolocationClientMock::cancelPermissionRequest):
     27        (WebCore::GeolocationClientMock::asyncUpdatePermission):
     28        (WebCore::GeolocationClientMock::permissionTimerFired):
     29        (WebCore::GeolocationClientMock::reset):
     30        (WebCore::GeolocationClientMock::stopUpdating):
     31        (WebCore::GeolocationClientMock::asyncUpdateController):
     32        (WebCore::GeolocationClientMock::controllerTimerFired):
     33        * platform/mock/GeolocationClientMock.h:
     34
    1352010-12-01  Ilya Tikhonovsky  <loislo@chromium.org>
    236
  • trunk/WebCore/page/Chrome.h

    r71541 r73163  
    140140        void print(Frame*);
    141141
     142        // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
     143        // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
    142144        void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
    143145        void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
  • trunk/WebCore/page/ChromeClient.h

    r72954 r73163  
    207207        virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&);
    208208
     209        // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
     210        // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
    209211        // This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission
    210212        // to use Geolocation.
    211213        virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
    212214        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
    213            
     215
    214216        virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
    215217        // Asynchronous request to load an icon for specified filenames.
  • trunk/WebCore/page/Geolocation.cpp

    r72396 r73163  
    234234void Geolocation::disconnectFrame()
    235235{
    236     if (m_frame && m_frame->page() && m_allowGeolocation == InProgress)
     236    if (m_frame && m_frame->page() && m_allowGeolocation == InProgress) {
     237#if ENABLE(CLIENT_BASED_GEOLOCATION)
     238        m_frame->page()->geolocationController()->cancelPermissionRequest(this);
     239#else
    237240        m_frame->page()->chrome()->cancelGeolocationPermissionRequestForFrame(m_frame, this);
     241#endif
     242    }
    238243    cancelAllRequests();
    239244    stopUpdating();
     
    597602    m_allowGeolocation = InProgress;
    598603
    599     // Ask the chrome: it maintains the geolocation challenge policy itself.
     604    // Ask the embedder: it maintains the geolocation challenge policy itself.
     605#if ENABLE(CLIENT_BASED_GEOLOCATION)
     606    page->geolocationController()->requestPermission(this);
     607#else
    600608    page->chrome()->requestGeolocationPermissionForFrame(m_frame, this);
     609#endif
    601610}
    602611
  • trunk/WebCore/page/GeolocationClient.h

    r71903 r73163  
    2929namespace WebCore {
    3030
     31class Geolocation;
    3132class GeolocationPosition;
    3233
     
    4445    virtual GeolocationPosition* lastPosition() = 0;
    4546
     47    virtual void requestPermission(Geolocation*) = 0;
     48    virtual void cancelPermissionRequest(Geolocation*) = 0;
     49
    4650protected:
    4751    virtual ~GeolocationClient() { }
  • trunk/WebCore/page/GeolocationController.cpp

    r71903 r73163  
    7979}
    8080
     81void GeolocationController::requestPermission(Geolocation* geolocation)
     82{
     83    if (m_client)
     84        m_client->requestPermission(geolocation);
     85}
     86
     87void GeolocationController::cancelPermissionRequest(Geolocation* geolocation)
     88{
     89    if (m_client)
     90        m_client->cancelPermissionRequest(geolocation);
     91}
     92
    8193void GeolocationController::positionChanged(GeolocationPosition* position)
    8294{
  • trunk/WebCore/page/GeolocationController.h

    r71903 r73163  
    4949    void removeObserver(Geolocation*);
    5050
     51    void requestPermission(Geolocation*);
     52    void cancelPermissionRequest(Geolocation*);
     53
    5154    void positionChanged(GeolocationPosition*);
    5255    void errorOccurred(GeolocationError*);
  • trunk/WebCore/platform/mock/GeolocationClientMock.cpp

    r72581 r73163  
    4242GeolocationClientMock::GeolocationClientMock()
    4343    : m_controller(0)
    44     , m_timer(this, &GeolocationClientMock::timerFired)
     44    , m_controllerTimer(this, &GeolocationClientMock::controllerTimerFired)
     45    , m_permissionTimer(this, &GeolocationClientMock::permissionTimerFired)
    4546    , m_isActive(false)
     47    , m_permissionState(PermissionStateUnset)
    4648{
    4749}
     
    7274}
    7375
     76void GeolocationClientMock::setPermission(bool allowed)
     77{
     78    m_permissionState = allowed ? PermissionStateAllowed : PermissionStateDenied;
     79    asyncUpdatePermission();
     80}
     81
     82void GeolocationClientMock::requestPermission(Geolocation* geolocation)
     83{
     84    m_pendingPermission.add(geolocation);
     85    if (m_permissionState != PermissionStateUnset)
     86        asyncUpdatePermission();
     87}
     88
     89void GeolocationClientMock::cancelPermissionRequest(Geolocation* geolocation)
     90{
     91    // Called from Geolocation::disconnectFrame() in response to Frame destruction.
     92    m_pendingPermission.remove(geolocation);
     93    if (m_pendingPermission.isEmpty() && m_permissionTimer.isActive())
     94        m_permissionTimer.stop();
     95}
     96
     97void GeolocationClientMock::asyncUpdatePermission()
     98{
     99    ASSERT(m_permissionState != PermissionStateUnset);
     100    if (!m_permissionTimer.isActive())
     101        m_permissionTimer.startOneShot(0);
     102}
     103
     104void GeolocationClientMock::permissionTimerFired(WebCore::Timer<GeolocationClientMock>* timer)
     105{
     106    ASSERT_UNUSED(timer, timer == &m_permissionTimer);
     107    ASSERT(m_permissionState != PermissionStateUnset);
     108    bool allowed = m_permissionState == PermissionStateAllowed;
     109    GeolocationSet::iterator end = m_pendingPermission.end();
     110
     111    // Once permission has been set (or denied) on a Geolocation object, there can be
     112    // no further requests for permission to the mock. Consequently the callbacks
     113    // which fire synchronously from Geolocation::setIsAllowed() cannot reentrantly modify
     114    // m_pendingPermission.
     115    for (GeolocationSet::iterator it = m_pendingPermission.begin(); it != end; ++it)
     116        (*it)->setIsAllowed(allowed);
     117    m_pendingPermission.clear();
     118}
     119
    74120void GeolocationClientMock::reset()
    75121{
    76122    m_lastPosition = 0;
    77123    m_lastError = 0;
     124    m_permissionState = PermissionStateUnset;
    78125}
    79126
     
    94141    ASSERT(m_isActive);
    95142    m_isActive = false;
    96     m_timer.stop();
     143    m_controllerTimer.stop();
    97144}
    98145
     
    111158{
    112159    ASSERT(m_controller);
    113     if (m_isActive && !m_timer.isActive())
    114         m_timer.startOneShot(0);
     160    if (m_isActive && !m_controllerTimer.isActive())
     161        m_controllerTimer.startOneShot(0);
    115162}
    116163
    117 void GeolocationClientMock::timerFired(Timer<GeolocationClientMock>* timer)
     164void GeolocationClientMock::controllerTimerFired(Timer<GeolocationClientMock>* timer)
    118165{
    119     ASSERT_UNUSED(timer, timer == &m_timer);
    120     updateController();
    121 }
    122 
    123 void GeolocationClientMock::updateController()
    124 {
     166    ASSERT_UNUSED(timer, timer == &m_controllerTimer);
    125167    ASSERT(m_controller);
    126168
  • trunk/WebCore/platform/mock/GeolocationClientMock.h

    r72581 r73163  
    3838#include "Timer.h"
    3939
     40#include <wtf/HashSet.h>
    4041#include <wtf/PassRefPtr.h>
    4142#include <wtf/RefPtr.h>
     
    5859    void setError(PassRefPtr<GeolocationError>);
    5960    void setPosition(PassRefPtr<GeolocationPosition>);
     61    void setPermission(bool allowed);
    6062
    6163    // GeolocationClient
     
    6567    virtual void setEnableHighAccuracy(bool);
    6668    virtual GeolocationPosition* lastPosition();
     69    virtual void requestPermission(Geolocation*);
     70    virtual void cancelPermissionRequest(Geolocation*);
    6771
    6872private:
    69     void timerFired(Timer<GeolocationClientMock>*);
    7073    void asyncUpdateController();
    71     void updateController();
     74    void controllerTimerFired(Timer<GeolocationClientMock>*);
     75
     76    void asyncUpdatePermission();
     77    void permissionTimerFired(Timer<GeolocationClientMock>*);
    7278
    7379    GeolocationController* m_controller;
    7480    RefPtr<GeolocationPosition> m_lastPosition;
    7581    RefPtr<GeolocationError> m_lastError;
    76     Timer<GeolocationClientMock> m_timer;
     82    Timer<GeolocationClientMock> m_controllerTimer;
     83    Timer<GeolocationClientMock> m_permissionTimer;
    7784    bool m_isActive;
     85
     86    enum PermissionState {
     87        PermissionStateUnset,
     88        PermissionStateAllowed,
     89        PermissionStateDenied,
     90    } m_permissionState;
     91    typedef WTF::HashSet<RefPtr<Geolocation> > GeolocationSet;
     92    GeolocationSet m_pendingPermission;
    7893};
    7994
  • trunk/WebKit/mac/ChangeLog

    r73149 r73163  
     12010-12-02  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Move requestGeolocationPermissionForFrame to GeolocationClient
     6        https://bugs.webkit.org/show_bug.cgi?id=50061
     7
     8        This change facilitates client-based geolocation implementation by
     9        bringing together permission control into the geolocation client
     10        interface.
     11
     12        Move method ChromeClient::requestGeolocationPermissionForFrame to
     13        GeolocationClient::requestPermission, and supporting class
     14        WebGeolocationPolicyListener. The moved code is unchanged except
     15        that requestPermission now takes only one argument (Geolocation*)
     16        and the Frame parameter is retrieved from the Geolocation object.
     17
     18        * WebCoreSupport/WebChromeClient.h:
     19        * WebCoreSupport/WebChromeClient.mm:
     20        * WebCoreSupport/WebGeolocationClient.h:
     21        (WebGeolocationClient::cancelPermissionRequest):
     22        * WebCoreSupport/WebGeolocationClient.mm:
     23        (WebGeolocationClient::requestPermission):
     24        (-[WebGeolocationPolicyListener initWithGeolocation:]):
     25        (-[WebGeolocationPolicyListener allow]):
     26        (-[WebGeolocationPolicyListener deny]):
     27
    1282010-12-02  Joseph Pecoraro  <joepeck@webkit.org>
    229
  • trunk/WebKit/mac/WebCoreSupport/WebChromeClient.h

    r71541 r73163  
    173173#endif
    174174
    175     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
     175    // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
     176    // For client-based geolocation, these two methods have moved to WebGeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
     177    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
    176178    virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
    177179
  • trunk/WebKit/mac/WebCoreSupport/WebChromeClient.mm

    r71541 r73163  
    5656#import <WebCore/Frame.h>
    5757#import <WebCore/FrameLoadRequest.h>
    58 #import <WebCore/Geolocation.h>
    5958#import <WebCore/HTMLNames.h>
    6059#import <WebCore/HitTestResult.h>
     
    101100}
    102101- (id)initWithChooser:(PassRefPtr<FileChooser>)chooser;
    103 @end
    104 
    105 @interface WebGeolocationPolicyListener : NSObject <WebGeolocationPolicyListener>
    106 {
    107     RefPtr<Geolocation> _geolocation;
    108 }
    109 - (id)initWithGeolocation:(Geolocation*)geolocation;
    110102@end
    111103
     
    850842#endif
    851843
    852 void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
    853 {
    854     BEGIN_BLOCK_OBJC_EXCEPTIONS;
    855 
    856     SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:);
    857     if (![[m_webView UIDelegate] respondsToSelector:selector]) {
    858         geolocation->setIsAllowed(false);
    859         return;
    860     }
    861 
    862     WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
    863     WebGeolocationPolicyListener* listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:geolocation];
    864 
    865     CallUIDelegate(m_webView, selector, webOrigin, kit(frame), listener);
    866 
    867     [webOrigin release];
    868     [listener release];
    869 
    870     END_BLOCK_OBJC_EXCEPTIONS;
    871 }
    872 
    873844@implementation WebOpenPanelResultListener
    874845
     
    933904@end
    934905
    935 @implementation WebGeolocationPolicyListener
    936 
    937 - (id)initWithGeolocation:(Geolocation*)geolocation
    938 {
    939     if (!(self = [super init]))
    940         return nil;
    941     _geolocation = geolocation;
    942     return self;
    943 }
    944 
    945 - (void)allow
    946 {
    947     _geolocation->setIsAllowed(true);
    948 }
    949 
    950 - (void)deny
    951 {
    952     _geolocation->setIsAllowed(false);
    953 }
    954 
    955 @end
    956 
    957906#if ENABLE(FULLSCREEN_API)
    958907
  • trunk/WebKit/mac/WebCoreSupport/WebGeolocationClient.h

    r71903 r73163  
    2727
    2828namespace WebCore {
    29     class GeolocationPosition;
     29class Geolocation;
     30class GeolocationPosition;
    3031}
    3132
     
    4445    WebCore::GeolocationPosition* lastPosition();
    4546
     47    void requestPermission(WebCore::Geolocation*);
     48    void cancelPermissionRequest(WebCore::Geolocation*) { };
     49
    4650private:
    4751    WebView *m_webView;
  • trunk/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm

    r71903 r73163  
    2626#import "WebGeolocationClient.h"
    2727
     28#import "WebDelegateImplementationCaching.h"
     29#import "WebFrameInternal.h"
    2830#import "WebGeolocationPositionInternal.h"
     31#import "WebSecurityOriginInternal.h"
     32#import "WebUIDelegatePrivate.h"
    2933#import "WebViewInternal.h"
     34#import <WebCore/BlockExceptions.h>
     35#import <WebCore/Frame.h>
     36#import <WebCore/Geolocation.h>
    3037
    3138using namespace WebCore;
     39
     40@interface WebGeolocationPolicyListener : NSObject <WebGeolocationPolicyListener>
     41{
     42    RefPtr<Geolocation> _geolocation;
     43}
     44- (id)initWithGeolocation:(Geolocation*)geolocation;
     45@end
    3246
    3347WebGeolocationClient::WebGeolocationClient(WebView *webView)
     
    5165}
    5266
     67void WebGeolocationClient::requestPermission(Geolocation* geolocation)
     68{
     69    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     70
     71    SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:);
     72    if (![[m_webView UIDelegate] respondsToSelector:selector]) {
     73        geolocation->setIsAllowed(false);
     74        return;
     75    }
     76
     77    Frame *frame = geolocation->frame();
     78    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
     79    WebGeolocationPolicyListener* listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:geolocation];
     80
     81    CallUIDelegate(m_webView, selector, webOrigin, kit(frame), listener);
     82
     83    [webOrigin release];
     84    [listener release];
     85
     86    END_BLOCK_OBJC_EXCEPTIONS;
     87}
     88
    5389GeolocationPosition* WebGeolocationClient::lastPosition()
    5490{
     
    5995#endif
    6096}
     97
     98@implementation WebGeolocationPolicyListener
     99
     100- (id)initWithGeolocation:(Geolocation*)geolocation
     101{
     102    if (!(self = [super init]))
     103        return nil;
     104    _geolocation = geolocation;
     105    return self;
     106}
     107
     108- (void)allow
     109{
     110    _geolocation->setIsAllowed(true);
     111}
     112
     113- (void)deny
     114{
     115    _geolocation->setIsAllowed(false);
     116}
     117
     118@end
     119
  • trunk/WebKit/win/ChangeLog

    r73088 r73163  
     12010-12-02  John Knottenbelt  <jknotten@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Move requestGeolocationPermissionForFrame to GeolocationClient
     6        https://bugs.webkit.org/show_bug.cgi?id=50061
     7
     8        This change facilitates client-based geolocation implementation by
     9        bringing together permission control into the geolocation client
     10        interface.
     11
     12        Move method ChromeClient::requestGeolocationPermissionForFrame to
     13        GeolocationClient::requestPermission. The moved code is unchanged
     14        except that requestPermission now takes only one argument (Geolocation*),
     15        the Frame parameter is retrieved from the Geolocation object and we need to
     16        call m_webView.get() as it is a COMPtr in GeolocationClient.
     17
     18        * WebCoreSupport/WebChromeClient.cpp:
     19        * WebCoreSupport/WebChromeClient.h:
     20        * WebCoreSupport/WebGeolocationClient.cpp:
     21        (WebGeolocationClient::requestPermission):
     22        * WebCoreSupport/WebGeolocationClient.h:
     23        (WebGeolocationClient::cancelPermissionRequest):
     24
    1252010-12-01  Jia Pu  <jpu@apple.com>
    226
  • trunk/WebKit/win/WebCoreSupport/WebChromeClient.cpp

    r71541 r73163  
    3333#include "WebElementPropertyBag.h"
    3434#include "WebFrame.h"
    35 #include "WebGeolocationPolicyListener.h"
    3635#include "WebHistory.h"
    3736#include "WebMutableURLRequest.h"
     
    4746#include <WebCore/FrameLoadRequest.h>
    4847#include <WebCore/FrameView.h>
    49 #include <WebCore/Geolocation.h>
    5048#include <WebCore/HTMLNames.h>
    5149#include <WebCore/Icon.h>
     
    818816}
    819817
    820 void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
    821 {
    822     COMPtr<IWebUIDelegate> uiDelegate;
    823     if (FAILED(m_webView->uiDelegate(&uiDelegate))) {
    824         geolocation->setIsAllowed(false);
    825         return;
    826     }
    827 
    828     COMPtr<IWebUIDelegatePrivate2> uiDelegatePrivate2(Query, uiDelegate);
    829     if (!uiDelegatePrivate2) {
    830         geolocation->setIsAllowed(false);
    831         return;
    832     }
    833 
    834     COMPtr<WebSecurityOrigin> origin(AdoptCOM, WebSecurityOrigin::createInstance(frame->document()->securityOrigin()));
    835     COMPtr<WebGeolocationPolicyListener> listener = WebGeolocationPolicyListener::createInstance(geolocation);
    836     HRESULT hr = uiDelegatePrivate2->decidePolicyForGeolocationRequest(m_webView, kit(frame), origin.get(), listener.get());
    837     if (hr != E_NOTIMPL)
    838         return;
    839 
    840     geolocation->setIsAllowed(false);
    841 }
    842 
    843818#if USE(ACCELERATED_COMPOSITING)
    844819void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
  • trunk/WebKit/win/WebCoreSupport/WebChromeClient.h

    r71548 r73163  
    160160    virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const {}
    161161
    162     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
     162    // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
     163    // For client-based geolocation, these two methods have been moved to WebGeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
     164    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
    163165    virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
    164166
  • trunk/WebKit/win/WebCoreSupport/WebGeolocationClient.cpp

    r71903 r73163  
    2828#include "WebGeolocationClient.h"
    2929
     30#include "WebFrame.h"
     31#include "WebGeolocationPolicyListener.h"
    3032#include "WebGeolocationPosition.h"
     33#include "WebSecurityOrigin.h"
    3134#include "WebView.h"
     35#include <WebCore/Frame.h>
     36#include <WebCore/Geolocation.h>
     37#include <WebCore/SecurityOrigin.h>
    3238
    3339using namespace WebCore;
     
    7379#endif
    7480}
     81
     82void WebGeolocationClient::requestPermission(Geolocation* geolocation)
     83{
     84    COMPtr<IWebUIDelegate> uiDelegate;
     85    if (FAILED(m_webView->uiDelegate(&uiDelegate))) {
     86        geolocation->setIsAllowed(false);
     87        return;
     88    }
     89
     90    COMPtr<IWebUIDelegatePrivate2> uiDelegatePrivate2(Query, uiDelegate);
     91    if (!uiDelegatePrivate2) {
     92        geolocation->setIsAllowed(false);
     93        return;
     94    }
     95
     96    Frame* frame = geolocation->frame();
     97    COMPtr<WebSecurityOrigin> origin(AdoptCOM, WebSecurityOrigin::createInstance(frame->document()->securityOrigin()));
     98    COMPtr<WebGeolocationPolicyListener> listener = WebGeolocationPolicyListener::createInstance(geolocation);
     99    HRESULT hr = uiDelegatePrivate2->decidePolicyForGeolocationRequest(m_webView.get(), kit(frame), origin.get(), listener.get());
     100    if (hr != E_NOTIMPL)
     101        return;
     102
     103    geolocation->setIsAllowed(false);
     104}
  • trunk/WebKit/win/WebCoreSupport/WebGeolocationClient.h

    r71903 r73163  
    3131
    3232namespace WebCore {
    33     class GeolocationPosition;
     33class Geolocation;
     34class GeolocationPosition;
    3435}
    3536
     
    4647    virtual WebCore::GeolocationPosition* lastPosition();
    4748
     49    virtual void requestPermission(WebCore::Geolocation*);
     50    virtual void cancelPermissionRequest(WebCore::Geolocation*) { }
     51
    4852private:
    4953    COMPtr<WebView> m_webView;
Note: See TracChangeset for help on using the changeset viewer.