Add a WKNavigationAction property indicating whether it resulted from processing...
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Apr 2014 23:19:32 +0000 (23:19 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Apr 2014 23:19:32 +0000 (23:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131405
<rdar://problem/16535453>

Reviewed by Tim Horton.

* Shared/NavigationActionData.cpp:
(WebKit::NavigationActionData::NavigationActionData):
(WebKit::NavigationActionData::encode):
(WebKit::NavigationActionData::decode):
* Shared/NavigationActionData.h:
* UIProcess/API/Cocoa/WKNavigationActionInternal.h:
* UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::createNewPage):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createWindow):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/NavigationActionData.cpp
Source/WebKit2/Shared/NavigationActionData.h
Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h
Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionPrivate.h
Source/WebKit2/UIProcess/Cocoa/NavigationState.mm
Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

index 689b90f..31d98ae 100644 (file)
@@ -1,3 +1,28 @@
+2014-04-08  Anders Carlsson  <andersca@apple.com>
+
+        Add a WKNavigationAction property indicating whether it resulted from processing a user gesture
+        https://bugs.webkit.org/show_bug.cgi?id=131405
+        <rdar://problem/16535453>
+
+        Reviewed by Tim Horton.
+
+        * Shared/NavigationActionData.cpp:
+        (WebKit::NavigationActionData::NavigationActionData):
+        (WebKit::NavigationActionData::encode):
+        (WebKit::NavigationActionData::decode):
+        * Shared/NavigationActionData.h:
+        * UIProcess/API/Cocoa/WKNavigationActionInternal.h:
+        * UIProcess/API/Cocoa/WKNavigationActionPrivate.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::UIClient::createNewPage):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::createWindow):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+
 2014-04-08  Tim Horton  <timothy_horton@apple.com>
 
         Unify and factor out page overlay implementations
index 2c37e63..dab5c61 100644 (file)
@@ -35,6 +35,9 @@ namespace WebKit {
 
 NavigationActionData::NavigationActionData()
     : navigationType(NavigationTypeOther)
+    , modifiers()
+    , mouseButton(WebMouseEvent::NoButton)
+    , isProcessingUserGesture(false)
 {
 }
 
@@ -43,6 +46,7 @@ void NavigationActionData::encode(IPC::ArgumentEncoder& encoder) const
     encoder.encodeEnum(navigationType);
     encoder.encodeEnum(modifiers);
     encoder.encodeEnum(mouseButton);
+    encoder << isProcessingUserGesture;
 }
 
 bool NavigationActionData::decode(IPC::ArgumentDecoder& decoder, NavigationActionData& result)
@@ -53,6 +57,8 @@ bool NavigationActionData::decode(IPC::ArgumentDecoder& decoder, NavigationActio
         return false;
     if (!decoder.decodeEnum(result.mouseButton))
         return false;
+    if (!decoder.decode(result.isProcessingUserGesture))
+        return false;
 
     return true;
 }
index 61cb5c2..3d6f628 100644 (file)
@@ -45,6 +45,7 @@ struct NavigationActionData {
     WebCore::NavigationType navigationType;
     WebEvent::Modifiers modifiers;
     WebMouseEvent::Button mouseButton;
+    bool isProcessingUserGesture;
 };
 
 }
index bb88c3b..676c4ae 100644 (file)
@@ -38,6 +38,7 @@
 @property (nonatomic, readwrite, copy) NSURLRequest *request;
 
 @property (nonatomic, readwrite, copy, setter=_setOriginalURL:) NSURL *_originalURL;
+@property (nonatomic, readwrite, setter=_setUserInitiated:) BOOL _userInitiated;
 
 @end
 
index c57f2dc..78307e3 100644 (file)
@@ -30,6 +30,7 @@
 @interface WKNavigationAction (WKPrivate)
 
 @property (nonatomic, readonly) NSURL *_originalURL;
+@property (nonatomic, readonly, getter=_isUserInitiated) BOOL _userInitiated;
 
 @end
 
index 531d03f..a2c1d07 100644 (file)
@@ -237,6 +237,7 @@ void NavigationState::PolicyClient::decidePolicyForNavigationAction(WebPageProxy
     [navigationAction setNavigationType:toWKNavigationType(navigationActionData.navigationType)];
     [navigationAction setRequest:request.nsURLRequest(WebCore::DoNotUpdateHTTPBody)];
     [navigationAction _setOriginalURL:originalRequest.url()];
+    [navigationAction _setUserInitiated:navigationActionData.isProcessingUserGesture];
 
     [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:navigationAction.get() decisionHandler:[listener](WKNavigationPolicyDecision policyDecision) {
         switch (policyDecision) {
index 32d800b..bba3e8e 100644 (file)
@@ -93,10 +93,10 @@ PassRefPtr<WebKit::WebPageProxy> UIDelegate::UIClient::createNewPage(WebKit::Web
 
     auto navigationAction = adoptNS([[WKNavigationAction alloc] init]);
 
-    // FIXME: Set a real navigation type.
     [navigationAction setSourceFrame:adoptNS([[WKFrameInfo alloc] initWithWebFrameProxy:*initiatingFrame]).get()];
     [navigationAction setNavigationType:toWKNavigationType(navigationActionData.navigationType)];
     [navigationAction setRequest:request.nsURLRequest(WebCore::DoNotUpdateHTTPBody)];
+    [navigationAction _setUserInitiated:navigationActionData.isProcessingUserGesture];
 
     RetainPtr<WKWebView> webView = [delegate.get() webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:navigationAction.get() windowFeatures:adoptNS([[WKWindowFeatures alloc] _initWithWindowFeatures:windowFeatures]).get()];
 
index 80e69e1..f8c2d95 100644 (file)
@@ -67,6 +67,7 @@
 #include <WebCore/MainFrame.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
+#include <WebCore/ScriptController.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/Settings.h>
 
@@ -209,6 +210,7 @@ Page* WebChromeClient::createWindow(Frame* frame, const FrameLoadRequest& reques
     navigationActionData.navigationType = navigationAction.type();
     navigationActionData.modifiers = InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction);
     navigationActionData.mouseButton = InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction);
+    navigationActionData.isProcessingUserGesture = ScriptController::processingUserGesture();
 
     uint64_t newPageID = 0;
     WebPageCreationParameters parameters;
index 267f642..bccfae9 100644 (file)
@@ -75,6 +75,7 @@
 #include <WebCore/ProgressTracker.h>
 #include <WebCore/ResourceBuffer.h>
 #include <WebCore/ResourceError.h>
+#include <WebCore/ScriptController.h>
 #include <WebCore/Settings.h>
 #include <WebCore/SubframeLoader.h>
 #include <WebCore/UIEventWithKeyState.h>
@@ -688,6 +689,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const Navigati
     navigationActionData.navigationType = action->navigationType();
     navigationActionData.modifiers = action->modifiers();
     navigationActionData.mouseButton = action->mouseButton();
+    navigationActionData.isProcessingUserGesture = ScriptController::processingUserGesture();
 
     webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), navigationActionData, request, frameName, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
 }
@@ -741,6 +743,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     navigationActionData.navigationType = action->navigationType();
     navigationActionData.modifiers = action->modifiers();
     navigationActionData.mouseButton = action->mouseButton();
+    navigationActionData.isProcessingUserGesture = ScriptController::processingUserGesture();
 
     // Notify the UIProcess.
     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), navigationActionData, originatingFrame ? originatingFrame->frameID() : 0, navigationAction.resourceRequest(), request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, policyAction, downloadID)))