Give the PageClient a chance to handle geolocation permission requests if the UIClien...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Nov 2013 04:34:08 +0000 (04:34 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Nov 2013 04:34:08 +0000 (04:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124955

Reviewed by Dan Bernstein.

Use the new PageClient function to remove the need for WKContentView to take over the WKPageUIClient.

* UIProcess/API/ios/PageClientImplIOS.h:
* UIProcess/API/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::decidePolicyForGeolocationPermissionRequest):
* UIProcess/API/ios/WKContentView.mm:
(-[WKContentView _decidePolicyForGeolocationRequestFromOrigin:frame:request:]):
(-[WKContentView _commonInitWithProcessGroup:browsingContextGroup:]):
* UIProcess/API/ios/WKContentViewInternal.h:
* UIProcess/PageClient.h:
(WebKit::PageClient::decidePolicyForGeolocationPermissionRequest):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestGeolocationPermissionForFrame):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159833 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/API/ios/WKContentView.mm
Source/WebKit2/UIProcess/API/ios/WKContentViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp

index ff4a79d..c42a2aa 100644 (file)
@@ -1,5 +1,26 @@
 2013-11-27  Sam Weinig  <sam@webkit.org>
 
 2013-11-27  Sam Weinig  <sam@webkit.org>
 
+        Give the PageClient a chance to handle geolocation permission requests if the UIClient doesn't handle it
+        https://bugs.webkit.org/show_bug.cgi?id=124955
+
+        Reviewed by Dan Bernstein.
+
+        Use the new PageClient function to remove the need for WKContentView to take over the WKPageUIClient.
+
+        * UIProcess/API/ios/PageClientImplIOS.h:
+        * UIProcess/API/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::decidePolicyForGeolocationPermissionRequest):
+        * UIProcess/API/ios/WKContentView.mm:
+        (-[WKContentView _decidePolicyForGeolocationRequestFromOrigin:frame:request:]):
+        (-[WKContentView _commonInitWithProcessGroup:browsingContextGroup:]):
+        * UIProcess/API/ios/WKContentViewInternal.h:
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::decidePolicyForGeolocationPermissionRequest):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestGeolocationPermissionForFrame):
+
+2013-11-27  Sam Weinig  <sam@webkit.org>
+
         Fix the iOS build.
 
         * UIProcess/API/ios/WKGeolocationProviderIOS.mm:
         Fix the iOS build.
 
         * UIProcess/API/ios/WKGeolocationProviderIOS.mm:
index 896bcd9..8109128 100644 (file)
@@ -57,6 +57,7 @@ private:
     virtual void pageClosed() OVERRIDE;
     virtual void preferencesDidChange() OVERRIDE;
     virtual void toolTipChanged(const String&, const String&) OVERRIDE;
     virtual void pageClosed() OVERRIDE;
     virtual void preferencesDidChange() OVERRIDE;
     virtual void toolTipChanged(const String&, const String&) OVERRIDE;
+    virtual bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&, WebSecurityOrigin&, GeolocationPermissionRequestProxy&) OVERRIDE;
     virtual void didChangeContentSize(const WebCore::IntSize&) OVERRIDE;
     virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
     virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
     virtual void didChangeContentSize(const WebCore::IntSize&) OVERRIDE;
     virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
     virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
index b07ebbe..471ad2d 100644 (file)
@@ -144,6 +144,12 @@ void PageClientImpl::toolTipChanged(const String&, const String&)
     notImplemented();
 }
 
     notImplemented();
 }
 
+bool PageClientImpl::decidePolicyForGeolocationPermissionRequest(WebFrameProxy& frame, WebSecurityOrigin& origin, GeolocationPermissionRequestProxy& request)
+{
+    [m_view _decidePolicyForGeolocationRequestFromOrigin:origin frame:frame request:request];
+    return true;
+}
+
 void PageClientImpl::didChangeContentSize(const IntSize& contentsSize)
 {
     [m_view _didChangeContentSize:contentsSize];
 void PageClientImpl::didChangeContentSize(const IntSize& contentsSize)
 {
     [m_view _didChangeContentSize:contentsSize];
index 8d5f167..f070cfe 100644 (file)
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextGroupPrivate.h"
 #import "WKGeolocationProviderIOS.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextGroupPrivate.h"
 #import "WKGeolocationProviderIOS.h"
-#import "WKProcessGroupPrivate.h"
 #import "WKInteractionView.h"
 #import "WKInteractionView.h"
+#import "WKProcessGroupPrivate.h"
 #import "WebContext.h"
 #import "WebContext.h"
+#import "WebFrameProxy.h"
 #import "WebPageGroup.h"
 #import "WebSystemInterface.h"
 #import <QuartzCore/CALayerHost.h>
 #import "WebPageGroup.h"
 #import "WebSystemInterface.h"
 #import <QuartzCore/CALayerHost.h>
@@ -147,12 +148,9 @@ using namespace WebKit;
     _page->didFinishZooming(scale);
 }
 
     _page->didFinishZooming(scale);
 }
 
-static void decidePolicyForGeolocationPermissionRequest(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo)
+- (void)_decidePolicyForGeolocationRequestFromOrigin:(WebSecurityOrigin&)origin frame:(WebFrameProxy&)frame request:(GeolocationPermissionRequestProxy&)permissionRequest
 {
 {
-    WKContentView *view = reinterpret_cast<WKContentView *>(const_cast<void*>(clientInfo));
-    ASSERT([view isKindOfClass:[WKContentView class]]);
-
-    [[view->_processGroup _geolocationProvider] decidePolicyForGeolocationRequestFromOrigin:origin frame:frame request:permissionRequest window:[view window]];
+    [[_processGroup _geolocationProvider] decidePolicyForGeolocationRequestFromOrigin:toAPI(&origin) frame:toAPI(&frame) request:toAPI(&permissionRequest) window:[self window]];
 }
 
 - (void)_commonInitWithProcessGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup
 }
 
 - (void)_commonInitWithProcessGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup
@@ -174,58 +172,6 @@ static void decidePolicyForGeolocationPermissionRequest(WKPageRef page, WKFrameR
     _page->setIntrinsicDeviceScaleFactor([UIScreen mainScreen].scale);
     _page->setUseFixedLayout(true);
 
     _page->setIntrinsicDeviceScaleFactor([UIScreen mainScreen].scale);
     _page->setUseFixedLayout(true);
 
-    WKPageUIClient pageUIClient = {
-        kWKPageUIClientCurrentVersion,
-        self,
-        0, // createNewPage_deprecatedForUseWithV0
-        0, // showPage
-        0, // closeOtherPage
-        0, // takeFocus
-        0, // focus
-        0, // unfocus
-        0, // runJavaScriptAlert
-        0, // runJavaScriptConfirm
-        0, // runJavaScriptPrompt
-        0, // setStatusText
-        0, // mouseDidMoveOverElement_deprecatedForUseWithV0
-        0, // missingPluginButtonClicked
-        0, // didNotHandleKeyEvent
-        0, // didNotHandleWheelEvent
-        0, // toolbarsAreVisible
-        0, // setToolbarsAreVisible
-        0, // menuBarIsVisible
-        0, // setMenuBarIsVisible
-        0, // statusBarIsVisible
-        0, // setStatusBarIsVisible
-        0, // isResizable
-        0, // setIsResizable
-        0, // getWindowFrameOtherPage
-        0, // setWindowFrameOtherPage
-        0, // runBeforeUnloadConfirmPanel
-        0, // didDraw
-        0, // pageDidScroll
-        0, // exceededDatabaseQuota
-        0, // runOpenPanel
-        decidePolicyForGeolocationPermissionRequest,
-        0, // headerHeight
-        0, // footerHeight
-        0, // drawHeader
-        0, // drawFooter
-        0, // printFrame
-        0, // runModal
-        0, // didCompleteRubberBandForMainFrame
-        0, // saveDataToFileInDownloadsFolder
-        0, // shouldInterruptJavaScript
-        0, // createOtherPage
-        0, // mouseDidMoveOverElement
-        0, // decidePolicyForNotificationPermissionRequest
-        0, // unavailablePluginButtonClicked
-        0, // showColorPicker
-        0, // hideColorPicker
-        0, // unavailablePluginButtonClicked
-    };
-    WKPageSetPageUIClient(toAPI(_page.get()), &pageUIClient);
-
     _browsingContextController = adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:toAPI(_page.get())]);
     [_browsingContextController setLoadDelegateInternal:self];
 
     _browsingContextController = adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:toAPI(_page.get())]);
     [_browsingContextController setLoadDelegateInternal:self];
 
index 5709b65..b63bf0b 100644 (file)
@@ -37,7 +37,10 @@ struct ViewportArguments;
 
 namespace WebKit {
 class DrawingAreaProxy;
 
 namespace WebKit {
 class DrawingAreaProxy;
+class GeolocationPermissionRequestProxy;
 class LayerTreeContext;
 class LayerTreeContext;
+class WebFrameProxy;
+class WebSecurityOrigin;
 }
 
 @class WebIOSEvent;
 }
 
 @class WebIOSEvent;
@@ -60,4 +63,6 @@ class LayerTreeContext;
 - (BOOL)_interpretKeyEvent:(WebIOSEvent *)theEvent isCharEvent:(BOOL)isCharEvent;
 - (void)_didChangeViewportArguments:(const WebCore::ViewportArguments&)viewportArguments;
 
 - (BOOL)_interpretKeyEvent:(WebIOSEvent *)theEvent isCharEvent:(BOOL)isCharEvent;
 - (void)_didChangeViewportArguments:(const WebCore::ViewportArguments&)viewportArguments;
 
+- (void)_decidePolicyForGeolocationRequestFromOrigin:(WebKit::WebSecurityOrigin&)origin frame:(WebKit::WebFrameProxy&)frame request:(WebKit::GeolocationPermissionRequestProxy&)permissionRequest;
+
 @end
 @end
index 0a49444..d2c6725 100644 (file)
@@ -120,6 +120,11 @@ public:
 
     virtual void toolTipChanged(const String&, const String&) = 0;
 
 
     virtual void toolTipChanged(const String&, const String&) = 0;
 
+    virtual bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&, WebSecurityOrigin&, GeolocationPermissionRequestProxy&)
+    {
+        return false;
+    }
+
 #if USE(TILED_BACKING_STORE)
     virtual void pageDidRequestScroll(const WebCore::IntPoint&) = 0;
     virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) = 0;
 #if USE(TILED_BACKING_STORE)
     virtual void pageDidRequestScroll(const WebCore::IntPoint&) = 0;
     virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) = 0;
index b4145a7..9c198e6 100644 (file)
@@ -3931,8 +3931,13 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID,
     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
     RefPtr<GeolocationPermissionRequestProxy> request = m_geolocationPermissionRequestManager.createRequest(geolocationID);
 
     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
     RefPtr<GeolocationPermissionRequestProxy> request = m_geolocationPermissionRequestManager.createRequest(geolocationID);
 
-    if (!m_uiClient.decidePolicyForGeolocationPermissionRequest(this, frame, origin.get(), request.get()))
-        request->deny();
+    if (m_uiClient.decidePolicyForGeolocationPermissionRequest(this, frame, origin.get(), request.get()))
+        return;
+
+    if (m_pageClient->decidePolicyForGeolocationPermissionRequest(*frame, *origin, *request))
+        return;
+
+    request->deny();
 }
 
 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
 }
 
 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)