[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 17:55:14 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f0d6e2b331fdb67f67ecc663ad388edf198fd9ab
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 2 18:59:07 2010 +0000

    2010-12-02  John Knottenbelt  <jknotten at 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 at 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 at 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):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73163 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 95c0852..3adf279 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2010-12-02  John Knottenbelt  <jknotten at 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-01  Ilya Tikhonovsky  <loislo at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/page/Chrome.h b/WebCore/page/Chrome.h
index f2c5db4..c9862ad 100644
--- a/WebCore/page/Chrome.h
+++ b/WebCore/page/Chrome.h
@@ -139,6 +139,8 @@ namespace WebCore {
 
         void print(Frame*);
 
+        // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
+        // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
         void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
         void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
 
diff --git a/WebCore/page/ChromeClient.h b/WebCore/page/ChromeClient.h
index 8a06a8d..d013d1c 100644
--- a/WebCore/page/ChromeClient.h
+++ b/WebCore/page/ChromeClient.h
@@ -206,11 +206,13 @@ namespace WebCore {
                                           float value, float proportion, ScrollbarControlPartMask);
         virtual bool paintCustomScrollCorner(GraphicsContext*, const FloatRect&);
 
+        // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
+        // For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
         // This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission
         // to use Geolocation.
         virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
         virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
-            
+
         virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
         // Asynchronous request to load an icon for specified filenames.
         virtual void chooseIconForFiles(const Vector<String>&, FileChooser*) = 0;
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
index 9135049..9c6f6d1 100644
--- a/WebCore/page/Geolocation.cpp
+++ b/WebCore/page/Geolocation.cpp
@@ -233,8 +233,13 @@ Geolocation::~Geolocation()
 
 void Geolocation::disconnectFrame()
 {
-    if (m_frame && m_frame->page() && m_allowGeolocation == InProgress)
+    if (m_frame && m_frame->page() && m_allowGeolocation == InProgress) {
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+        m_frame->page()->geolocationController()->cancelPermissionRequest(this);
+#else
         m_frame->page()->chrome()->cancelGeolocationPermissionRequestForFrame(m_frame, this);
+#endif
+    }
     cancelAllRequests();
     stopUpdating();
     if (m_frame && m_frame->document())
@@ -596,8 +601,12 @@ void Geolocation::requestPermission()
 
     m_allowGeolocation = InProgress;
 
-    // Ask the chrome: it maintains the geolocation challenge policy itself.
+    // Ask the embedder: it maintains the geolocation challenge policy itself.
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+    page->geolocationController()->requestPermission(this);
+#else
     page->chrome()->requestGeolocationPermissionForFrame(m_frame, this);
+#endif
 }
 
 void Geolocation::positionChangedInternal()
diff --git a/WebCore/page/GeolocationClient.h b/WebCore/page/GeolocationClient.h
index c646f91..44cb909 100644
--- a/WebCore/page/GeolocationClient.h
+++ b/WebCore/page/GeolocationClient.h
@@ -28,6 +28,7 @@
 
 namespace WebCore {
 
+class Geolocation;
 class GeolocationPosition;
 
 class GeolocationClient {
@@ -43,6 +44,9 @@ public:
     virtual void setEnableHighAccuracy(bool) = 0;
     virtual GeolocationPosition* lastPosition() = 0;
 
+    virtual void requestPermission(Geolocation*) = 0;
+    virtual void cancelPermissionRequest(Geolocation*) = 0;
+
 protected:
     virtual ~GeolocationClient() { }
 };
diff --git a/WebCore/page/GeolocationController.cpp b/WebCore/page/GeolocationController.cpp
index db4cc23..28d522d 100644
--- a/WebCore/page/GeolocationController.cpp
+++ b/WebCore/page/GeolocationController.cpp
@@ -78,6 +78,18 @@ void GeolocationController::removeObserver(Geolocation* observer)
     }
 }
 
+void GeolocationController::requestPermission(Geolocation* geolocation)
+{
+    if (m_client)
+        m_client->requestPermission(geolocation);
+}
+
+void GeolocationController::cancelPermissionRequest(Geolocation* geolocation)
+{
+    if (m_client)
+        m_client->cancelPermissionRequest(geolocation);
+}
+
 void GeolocationController::positionChanged(GeolocationPosition* position)
 {
     m_lastPosition = position;
diff --git a/WebCore/page/GeolocationController.h b/WebCore/page/GeolocationController.h
index 2d8106d..7db1951 100644
--- a/WebCore/page/GeolocationController.h
+++ b/WebCore/page/GeolocationController.h
@@ -48,6 +48,9 @@ public:
     void addObserver(Geolocation*, bool enableHighAccuracy);
     void removeObserver(Geolocation*);
 
+    void requestPermission(Geolocation*);
+    void cancelPermissionRequest(Geolocation*);
+
     void positionChanged(GeolocationPosition*);
     void errorOccurred(GeolocationError*);
 
diff --git a/WebCore/platform/mock/GeolocationClientMock.cpp b/WebCore/platform/mock/GeolocationClientMock.cpp
index 3c4697f..5255b34 100644
--- a/WebCore/platform/mock/GeolocationClientMock.cpp
+++ b/WebCore/platform/mock/GeolocationClientMock.cpp
@@ -41,8 +41,10 @@ namespace WebCore {
 
 GeolocationClientMock::GeolocationClientMock()
     : m_controller(0)
-    , m_timer(this, &GeolocationClientMock::timerFired)
+    , m_controllerTimer(this, &GeolocationClientMock::controllerTimerFired)
+    , m_permissionTimer(this, &GeolocationClientMock::permissionTimerFired)
     , m_isActive(false)
+    , m_permissionState(PermissionStateUnset)
 {
 }
 
@@ -71,10 +73,55 @@ void GeolocationClientMock::setError(PassRefPtr<GeolocationError> error)
     asyncUpdateController();
 }
 
+void GeolocationClientMock::setPermission(bool allowed)
+{
+    m_permissionState = allowed ? PermissionStateAllowed : PermissionStateDenied;
+    asyncUpdatePermission();
+}
+
+void GeolocationClientMock::requestPermission(Geolocation* geolocation)
+{
+    m_pendingPermission.add(geolocation);
+    if (m_permissionState != PermissionStateUnset)
+        asyncUpdatePermission();
+}
+
+void GeolocationClientMock::cancelPermissionRequest(Geolocation* geolocation)
+{
+    // Called from Geolocation::disconnectFrame() in response to Frame destruction.
+    m_pendingPermission.remove(geolocation);
+    if (m_pendingPermission.isEmpty() && m_permissionTimer.isActive())
+        m_permissionTimer.stop();
+}
+
+void GeolocationClientMock::asyncUpdatePermission()
+{
+    ASSERT(m_permissionState != PermissionStateUnset);
+    if (!m_permissionTimer.isActive())
+        m_permissionTimer.startOneShot(0);
+}
+
+void GeolocationClientMock::permissionTimerFired(WebCore::Timer<GeolocationClientMock>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_permissionTimer);
+    ASSERT(m_permissionState != PermissionStateUnset);
+    bool allowed = m_permissionState == PermissionStateAllowed;
+    GeolocationSet::iterator end = m_pendingPermission.end();
+
+    // Once permission has been set (or denied) on a Geolocation object, there can be
+    // no further requests for permission to the mock. Consequently the callbacks
+    // which fire synchronously from Geolocation::setIsAllowed() cannot reentrantly modify
+    // m_pendingPermission.
+    for (GeolocationSet::iterator it = m_pendingPermission.begin(); it != end; ++it)
+        (*it)->setIsAllowed(allowed);
+    m_pendingPermission.clear();
+}
+
 void GeolocationClientMock::reset()
 {
     m_lastPosition = 0;
     m_lastError = 0;
+    m_permissionState = PermissionStateUnset;
 }
 
 void GeolocationClientMock::geolocationDestroyed()
@@ -93,7 +140,7 @@ void GeolocationClientMock::stopUpdating()
 {
     ASSERT(m_isActive);
     m_isActive = false;
-    m_timer.stop();
+    m_controllerTimer.stop();
 }
 
 void GeolocationClientMock::setEnableHighAccuracy(bool)
@@ -110,18 +157,13 @@ GeolocationPosition* GeolocationClientMock::lastPosition()
 void GeolocationClientMock::asyncUpdateController()
 {
     ASSERT(m_controller);
-    if (m_isActive && !m_timer.isActive())
-        m_timer.startOneShot(0);
-}
-
-void GeolocationClientMock::timerFired(Timer<GeolocationClientMock>* timer)
-{
-    ASSERT_UNUSED(timer, timer == &m_timer);
-    updateController();
+    if (m_isActive && !m_controllerTimer.isActive())
+        m_controllerTimer.startOneShot(0);
 }
 
-void GeolocationClientMock::updateController()
+void GeolocationClientMock::controllerTimerFired(Timer<GeolocationClientMock>* timer)
 {
+    ASSERT_UNUSED(timer, timer == &m_controllerTimer);
     ASSERT(m_controller);
 
     if (m_lastPosition.get())
diff --git a/WebCore/platform/mock/GeolocationClientMock.h b/WebCore/platform/mock/GeolocationClientMock.h
index f57afa9..df35316 100644
--- a/WebCore/platform/mock/GeolocationClientMock.h
+++ b/WebCore/platform/mock/GeolocationClientMock.h
@@ -37,6 +37,7 @@
 #include "PlatformString.h"
 #include "Timer.h"
 
+#include <wtf/HashSet.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
@@ -57,6 +58,7 @@ public:
 
     void setError(PassRefPtr<GeolocationError>);
     void setPosition(PassRefPtr<GeolocationPosition>);
+    void setPermission(bool allowed);
 
     // GeolocationClient
     virtual void geolocationDestroyed();
@@ -64,17 +66,30 @@ public:
     virtual void stopUpdating();
     virtual void setEnableHighAccuracy(bool);
     virtual GeolocationPosition* lastPosition();
+    virtual void requestPermission(Geolocation*);
+    virtual void cancelPermissionRequest(Geolocation*);
 
 private:
-    void timerFired(Timer<GeolocationClientMock>*);
     void asyncUpdateController();
-    void updateController();
+    void controllerTimerFired(Timer<GeolocationClientMock>*);
+
+    void asyncUpdatePermission();
+    void permissionTimerFired(Timer<GeolocationClientMock>*);
 
     GeolocationController* m_controller;
     RefPtr<GeolocationPosition> m_lastPosition;
     RefPtr<GeolocationError> m_lastError;
-    Timer<GeolocationClientMock> m_timer;
+    Timer<GeolocationClientMock> m_controllerTimer;
+    Timer<GeolocationClientMock> m_permissionTimer;
     bool m_isActive;
+
+    enum PermissionState {
+        PermissionStateUnset,
+        PermissionStateAllowed,
+        PermissionStateDenied,
+    } m_permissionState;
+    typedef WTF::HashSet<RefPtr<Geolocation> > GeolocationSet;
+    GeolocationSet m_pendingPermission;
 };
 
 }
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 9de2e2d..edc0e61 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,30 @@
+2010-12-02  John Knottenbelt  <jknotten at 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  Joseph Pecoraro  <joepeck at webkit.org>
 
         Reviewed by Eric Carlson.
diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.h b/WebKit/mac/WebCoreSupport/WebChromeClient.h
index a5f49e3..8649662 100644
--- a/WebKit/mac/WebCoreSupport/WebChromeClient.h
+++ b/WebKit/mac/WebCoreSupport/WebChromeClient.h
@@ -172,7 +172,9 @@ public:
     virtual void exitFullScreenForElement(WebCore::Element*);
 #endif
 
-    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
+    // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
+    // For client-based geolocation, these two methods have moved to WebGeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
+    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
 
     virtual bool selectItemWritingDirectionIsNatural();
diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.mm b/WebKit/mac/WebCoreSupport/WebChromeClient.mm
index fe95989..48ccdab 100644
--- a/WebKit/mac/WebCoreSupport/WebChromeClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebChromeClient.mm
@@ -55,7 +55,6 @@
 #import <WebCore/FloatRect.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameLoadRequest.h>
-#import <WebCore/Geolocation.h>
 #import <WebCore/HTMLNames.h>
 #import <WebCore/HitTestResult.h>
 #import <WebCore/Icon.h>
@@ -102,13 +101,6 @@ using namespace WebCore;
 - (id)initWithChooser:(PassRefPtr<FileChooser>)chooser;
 @end
 
- at interface WebGeolocationPolicyListener : NSObject <WebGeolocationPolicyListener>
-{
-    RefPtr<Geolocation> _geolocation;
-}
-- (id)initWithGeolocation:(Geolocation*)geolocation;
- at end
-
 #if ENABLE(FULLSCREEN_API)
 
 @interface WebKitFullScreenListener : NSObject <WebKitFullScreenListener>
@@ -849,27 +841,6 @@ void WebChromeClient::exitFullScreenForElement(Element* element)
 
 #endif
 
-void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-    SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:);
-    if (![[m_webView UIDelegate] respondsToSelector:selector]) {
-        geolocation->setIsAllowed(false);
-        return;
-    }
-
-    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
-    WebGeolocationPolicyListener* listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:geolocation];
-
-    CallUIDelegate(m_webView, selector, webOrigin, kit(frame), listener);
-
-    [webOrigin release];
-    [listener release];
-
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
 @implementation WebOpenPanelResultListener
 
 - (id)initWithChooser:(PassRefPtr<FileChooser>)chooser
@@ -932,28 +903,6 @@ void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geoloca
 
 @end
 
- at implementation WebGeolocationPolicyListener
-
-- (id)initWithGeolocation:(Geolocation*)geolocation
-{
-    if (!(self = [super init]))
-        return nil;
-    _geolocation = geolocation;
-    return self;
-}
-
-- (void)allow
-{
-    _geolocation->setIsAllowed(true);
-}
-
-- (void)deny
-{
-    _geolocation->setIsAllowed(false);
-}
-
- at end
-
 #if ENABLE(FULLSCREEN_API)
 
 @implementation WebKitFullScreenListener
diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationClient.h b/WebKit/mac/WebCoreSupport/WebGeolocationClient.h
index 5ea3369..b8e7b87 100644
--- a/WebKit/mac/WebCoreSupport/WebGeolocationClient.h
+++ b/WebKit/mac/WebCoreSupport/WebGeolocationClient.h
@@ -26,7 +26,8 @@
 #import <WebCore/GeolocationClient.h>
 
 namespace WebCore {
-    class GeolocationPosition;
+class Geolocation;
+class GeolocationPosition;
 }
 
 @class WebView;
@@ -43,6 +44,9 @@ public:
 
     WebCore::GeolocationPosition* lastPosition();
 
+    void requestPermission(WebCore::Geolocation*);
+    void cancelPermissionRequest(WebCore::Geolocation*) { };
+
 private:
     WebView *m_webView;
 };
diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm b/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm
index a635b44..b52b7bc 100644
--- a/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm
@@ -25,11 +25,25 @@
 
 #import "WebGeolocationClient.h"
 
+#import "WebDelegateImplementationCaching.h"
+#import "WebFrameInternal.h"
 #import "WebGeolocationPositionInternal.h"
+#import "WebSecurityOriginInternal.h"
+#import "WebUIDelegatePrivate.h"
 #import "WebViewInternal.h"
+#import <WebCore/BlockExceptions.h>
+#import <WebCore/Frame.h>
+#import <WebCore/Geolocation.h>
 
 using namespace WebCore;
 
+ at interface WebGeolocationPolicyListener : NSObject <WebGeolocationPolicyListener>
+{
+    RefPtr<Geolocation> _geolocation;
+}
+- (id)initWithGeolocation:(Geolocation*)geolocation;
+ at end
+
 WebGeolocationClient::WebGeolocationClient(WebView *webView)
     : m_webView(webView)
 {
@@ -50,6 +64,28 @@ void WebGeolocationClient::stopUpdating()
     [[m_webView _geolocationProvider] unregisterWebView:m_webView];
 }
 
+void WebGeolocationClient::requestPermission(Geolocation* geolocation)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+    SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:);
+    if (![[m_webView UIDelegate] respondsToSelector:selector]) {
+        geolocation->setIsAllowed(false);
+        return;
+    }
+
+    Frame *frame = geolocation->frame();
+    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
+    WebGeolocationPolicyListener* listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:geolocation];
+
+    CallUIDelegate(m_webView, selector, webOrigin, kit(frame), listener);
+
+    [webOrigin release];
+    [listener release];
+
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
 GeolocationPosition* WebGeolocationClient::lastPosition()
 {
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
@@ -58,3 +94,26 @@ GeolocationPosition* WebGeolocationClient::lastPosition()
     return 0;
 #endif
 }
+
+ at implementation WebGeolocationPolicyListener
+
+- (id)initWithGeolocation:(Geolocation*)geolocation
+{
+    if (!(self = [super init]))
+        return nil;
+    _geolocation = geolocation;
+    return self;
+}
+
+- (void)allow
+{
+    _geolocation->setIsAllowed(true);
+}
+
+- (void)deny
+{
+    _geolocation->setIsAllowed(false);
+}
+
+ at end
+
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index ed946c8..69f6af1 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,27 @@
+2010-12-02  John Knottenbelt  <jknotten at 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):
+
 2010-12-01  Jia Pu  <jpu at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
index d046c21..884d4dc 100644
--- a/WebKit/win/WebCoreSupport/WebChromeClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebChromeClient.cpp
@@ -32,7 +32,6 @@
 #include "DOMCoreClasses.h"
 #include "WebElementPropertyBag.h"
 #include "WebFrame.h"
-#include "WebGeolocationPolicyListener.h"
 #include "WebHistory.h"
 #include "WebMutableURLRequest.h"
 #include "WebDesktopNotificationsDelegate.h"
@@ -46,7 +45,6 @@
 #include <WebCore/FloatRect.h>
 #include <WebCore/FrameLoadRequest.h>
 #include <WebCore/FrameView.h>
-#include <WebCore/Geolocation.h>
 #include <WebCore/HTMLNames.h>
 #include <WebCore/Icon.h>
 #include <WebCore/LocalWindowsContext.h>
@@ -817,29 +815,6 @@ void WebChromeClient::setLastSetCursorToCurrentCursor()
     m_webView->setLastCursor(::GetCursor());
 }
 
-void WebChromeClient::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
-{
-    COMPtr<IWebUIDelegate> uiDelegate;
-    if (FAILED(m_webView->uiDelegate(&uiDelegate))) {
-        geolocation->setIsAllowed(false);
-        return;
-    }
-
-    COMPtr<IWebUIDelegatePrivate2> uiDelegatePrivate2(Query, uiDelegate);
-    if (!uiDelegatePrivate2) {
-        geolocation->setIsAllowed(false);
-        return;
-    }
-
-    COMPtr<WebSecurityOrigin> origin(AdoptCOM, WebSecurityOrigin::createInstance(frame->document()->securityOrigin()));
-    COMPtr<WebGeolocationPolicyListener> listener = WebGeolocationPolicyListener::createInstance(geolocation);
-    HRESULT hr = uiDelegatePrivate2->decidePolicyForGeolocationRequest(m_webView, kit(frame), origin.get(), listener.get());
-    if (hr != E_NOTIMPL)
-        return;
-
-    geolocation->setIsAllowed(false);
-}
-
 #if USE(ACCELERATED_COMPOSITING)
 void WebChromeClient::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
 {
diff --git a/WebKit/win/WebCoreSupport/WebChromeClient.h b/WebKit/win/WebCoreSupport/WebChromeClient.h
index 55167b6..b6c2525 100644
--- a/WebKit/win/WebCoreSupport/WebChromeClient.h
+++ b/WebKit/win/WebCoreSupport/WebChromeClient.h
@@ -159,7 +159,9 @@ public:
 
     virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const {}
 
-    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
+    // FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
+    // For client-based geolocation, these two methods have been moved to WebGeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
+    virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
 
 #if ENABLE(VIDEO)
diff --git a/WebKit/win/WebCoreSupport/WebGeolocationClient.cpp b/WebKit/win/WebCoreSupport/WebGeolocationClient.cpp
index 8a526c4..b1d83fb 100644
--- a/WebKit/win/WebCoreSupport/WebGeolocationClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebGeolocationClient.cpp
@@ -27,8 +27,14 @@
 #include "WebKitDLL.h"
 #include "WebGeolocationClient.h"
 
+#include "WebFrame.h"
+#include "WebGeolocationPolicyListener.h"
 #include "WebGeolocationPosition.h"
+#include "WebSecurityOrigin.h"
 #include "WebView.h"
+#include <WebCore/Frame.h>
+#include <WebCore/Geolocation.h>
+#include <WebCore/SecurityOrigin.h>
 
 using namespace WebCore;
 
@@ -72,3 +78,27 @@ GeolocationPosition* WebGeolocationClient::lastPosition()
     return 0;
 #endif
 }
+
+void WebGeolocationClient::requestPermission(Geolocation* geolocation)
+{
+    COMPtr<IWebUIDelegate> uiDelegate;
+    if (FAILED(m_webView->uiDelegate(&uiDelegate))) {
+        geolocation->setIsAllowed(false);
+        return;
+    }
+
+    COMPtr<IWebUIDelegatePrivate2> uiDelegatePrivate2(Query, uiDelegate);
+    if (!uiDelegatePrivate2) {
+        geolocation->setIsAllowed(false);
+        return;
+    }
+
+    Frame* frame = geolocation->frame();
+    COMPtr<WebSecurityOrigin> origin(AdoptCOM, WebSecurityOrigin::createInstance(frame->document()->securityOrigin()));
+    COMPtr<WebGeolocationPolicyListener> listener = WebGeolocationPolicyListener::createInstance(geolocation);
+    HRESULT hr = uiDelegatePrivate2->decidePolicyForGeolocationRequest(m_webView.get(), kit(frame), origin.get(), listener.get());
+    if (hr != E_NOTIMPL)
+        return;
+
+    geolocation->setIsAllowed(false);
+}
diff --git a/WebKit/win/WebCoreSupport/WebGeolocationClient.h b/WebKit/win/WebCoreSupport/WebGeolocationClient.h
index 2422ae5..c5db134 100644
--- a/WebKit/win/WebCoreSupport/WebGeolocationClient.h
+++ b/WebKit/win/WebCoreSupport/WebGeolocationClient.h
@@ -30,7 +30,8 @@
 #include <WebCore/GeolocationClient.h>
 
 namespace WebCore {
-    class GeolocationPosition;
+class Geolocation;
+class GeolocationPosition;
 }
 
 class WebView;
@@ -45,6 +46,9 @@ public:
     virtual void setEnableHighAccuracy(bool) { }
     virtual WebCore::GeolocationPosition* lastPosition();
 
+    virtual void requestPermission(WebCore::Geolocation*);
+    virtual void cancelPermissionRequest(WebCore::Geolocation*) { }
+
 private:
     COMPtr<WebView> m_webView;
 };

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list