Changeset 186664 in webkit
- Timestamp:
- Jul 9, 2015 10:18:53 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r186663 r186664 1 2015-07-09 Dan Bernstein <mitz@apple.com> 2 3 WebCore part of Track and expose policies for external URL schemes and App Links separately 4 https://bugs.webkit.org/show_bug.cgi?id=146822 5 6 Reviewed by Anders Carlsson. 7 8 * loader/FrameLoaderTypes.h: Added ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, 9 meaning external schemes are allowed but App Links are not. The opposite state doesn’t 10 exist. 11 12 * page/ContextMenuController.cpp: 13 (WebCore::ContextMenuController::contextMenuItemSelected): Opening a link in a new window 14 or in the current window should never open it as an App Link. 15 1 16 2015-07-09 Daniel Bates <dabates@apple.com> 2 17 -
trunk/Source/WebCore/loader/FrameLoaderTypes.h
r184941 r186664 74 74 enum class ShouldOpenExternalURLsPolicy { 75 75 ShouldNotAllow, 76 ShouldAllowExternalSchemes, 76 77 ShouldAllow, 77 78 }; -
trunk/Source/WebCore/page/ContextMenuController.cpp
r185231 r186664 239 239 switch (item->action()) { 240 240 case ContextMenuItemTagOpenLinkInNewWindow: 241 openNewWindow(m_context.hitTestResult().absoluteLinkURL(), frame, ShouldOpenExternalURLsPolicy::ShouldAllow );241 openNewWindow(m_context.hitTestResult().absoluteLinkURL(), frame, ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes); 242 242 break; 243 243 case ContextMenuItemTagDownloadLinkToDisk: … … 407 407 break; 408 408 case ContextMenuItemTagOpenLinkInThisWindow: 409 frame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_context.hitTestResult().absoluteLinkURL(), frame->loader().outgoingReferrer()), LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress, ShouldOpenExternalURLsPolicy::ShouldAllow ), nullptr, nullptr);409 frame->loader().loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_context.hitTestResult().absoluteLinkURL(), frame->loader().outgoingReferrer()), LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress, ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes), nullptr, nullptr); 410 410 break; 411 411 case ContextMenuItemTagBold: -
trunk/Source/WebKit2/ChangeLog
r186662 r186664 1 2015-07-09 Dan Bernstein <mitz@apple.com> 2 3 WebKit2 part of Track and expose policies for external URL schemes and App Links separately 4 https://bugs.webkit.org/show_bug.cgi?id=146822 5 6 Reviewed by Anders Carlsson. 7 8 * Shared/NavigationActionData.cpp: 9 (WebKit::NavigationActionData::encode): 10 (WebKit::NavigationActionData::decode): 11 * Shared/NavigationActionData.h: 12 Replaced the shouldOpenExternalURLsPolicy boolean member with a 13 shouldOpenExternalURLsPolicy member whose type is ShouldOpenExternalURLsPolicy, and 14 updated encoding and decoding: 15 16 * UIProcess/API/APINavigationAction.h: 17 Added shouldOpenAppLinks boolean to NavigationAction::create and the constructor. It 18 augments the policy in the NavigationActionData with a valude decided in the UI process. 19 Replaced shouldOpenExternalURLs() with shouldOpenExternalSchemes() and 20 shouldOpenAppLinks() which check the policy and the new m_shouldOpenAppLinks boolean. 21 22 * UIProcess/API/Cocoa/WKNavigationAction.mm: 23 (-[WKNavigationAction _shouldOpenExternalSchemes]): Getter for new property, calls through 24 to the NavigationAction. 25 (-[WKNavigationAction _shouldOpenAppLinks]): Ditto. 26 (-[WKNavigationAction _shouldOpenExternalURLs]): Now deprecated and returns the 27 _shouldOpenExternalSchemes value. 28 * UIProcess/API/Cocoa/WKNavigationActionPrivate.h: Declared new properties for the two 29 policies and deprecated old property. 30 31 * UIProcess/Cocoa/NavigationState.mm: 32 (WebKit::tryAppLink): Changed to use NavigationAction::shouldOpenAppLinks, which 33 encapsulates logic that used to be here. 34 35 * UIProcess/Cocoa/UIDelegate.mm: 36 (WebKit::UIDelegate::UIClient::createNewPage): Allow App Links (if already allowed by policy). 37 38 * UIProcess/WebPageProxy.cpp: 39 (WebKit::WebPageProxy::decidePolicyForNavigationAction): Moved logic from tryAppLink in 40 NavigationState.mm here and pass the result to NavigationAction::create. 41 (WebKit::WebPageProxy::decidePolicyForNewWindowAction): Allow App Links (if already allowed 42 by policy). 43 * UIProcess/WebPageProxy.h: 44 (WebKit::WebPageProxy::loadRequest): Changed the default policy to not allow App Links (but 45 still allow external schemes). 46 47 * WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp: 48 (WKBundleNavigationActionGetShouldTryAppLinks): Added this getter. 49 * WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h: 50 51 * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp: 52 (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction): 53 * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h: 54 Added m_shouldTryAppLinks boolean member, initialized from the policy. Updated the 55 initialization of m_shouldOpenExternalURLs to account for the new policy. 56 57 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 58 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): Pass the policy 59 in the navigation data. 60 1 61 2015-07-09 Tim Horton <timothy_horton@apple.com> 2 62 -
trunk/Source/WebKit2/Shared/NavigationActionData.cpp
r184941 r186664 41 41 encoder << isProcessingUserGesture; 42 42 encoder << canHandleRequest; 43 encoder << shouldOpenExternalURLs;43 encoder.encodeEnum(shouldOpenExternalURLsPolicy); 44 44 } 45 45 … … 56 56 if (!decoder.decode(result.canHandleRequest)) 57 57 return false; 58 if (!decoder.decode (result.shouldOpenExternalURLs))58 if (!decoder.decodeEnum(result.shouldOpenExternalURLsPolicy)) 59 59 return false; 60 60 -
trunk/Source/WebKit2/Shared/NavigationActionData.h
r184941 r186664 46 46 bool isProcessingUserGesture { false }; 47 47 bool canHandleRequest { false }; 48 bool shouldOpenExternalURLs { false};48 WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy { WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow }; 49 49 }; 50 50 -
trunk/Source/WebKit2/UIProcess/API/APINavigationAction.h
r184941 r186664 39 39 class NavigationAction final : public ObjectImpl<Object::Type::NavigationAction> { 40 40 public: 41 static Ref<NavigationAction> create(const WebKit::NavigationActionData& navigationActionData, API::FrameInfo* sourceFrame, API::FrameInfo* targetFrame, const WebCore::ResourceRequest& request, const WebCore::URL& originalURL )41 static Ref<NavigationAction> create(const WebKit::NavigationActionData& navigationActionData, API::FrameInfo* sourceFrame, API::FrameInfo* targetFrame, const WebCore::ResourceRequest& request, const WebCore::URL& originalURL, bool shouldOpenAppLinks) 42 42 { 43 return adoptRef(*new NavigationAction(navigationActionData, sourceFrame, targetFrame, request, originalURL ));43 return adoptRef(*new NavigationAction(navigationActionData, sourceFrame, targetFrame, request, originalURL, shouldOpenAppLinks)); 44 44 } 45 45 46 NavigationAction(const WebKit::NavigationActionData& navigationActionData, API::FrameInfo* sourceFrame, API::FrameInfo* targetFrame, const WebCore::ResourceRequest& request, const WebCore::URL& originalURL )46 NavigationAction(const WebKit::NavigationActionData& navigationActionData, API::FrameInfo* sourceFrame, API::FrameInfo* targetFrame, const WebCore::ResourceRequest& request, const WebCore::URL& originalURL, bool shouldOpenAppLinks) 47 47 : m_sourceFrame(sourceFrame) 48 48 , m_targetFrame(targetFrame) 49 49 , m_request(request) 50 50 , m_originalURL(originalURL) 51 , m_shouldOpenAppLinks(shouldOpenAppLinks) 51 52 , m_navigationActionData(navigationActionData) 52 53 { … … 64 65 bool isProcessingUserGesture() const { return m_navigationActionData.isProcessingUserGesture; } 65 66 bool canHandleRequest() const { return m_navigationActionData.canHandleRequest; } 66 bool shouldOpenExternalURLs() const { return m_navigationActionData.shouldOpenExternalURLs; } 67 bool shouldOpenExternalSchemes() const { return m_navigationActionData.shouldOpenExternalURLsPolicy == WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow || m_navigationActionData.shouldOpenExternalURLsPolicy == WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes; } 68 bool shouldOpenAppLinks() const { return m_shouldOpenAppLinks && m_navigationActionData.shouldOpenExternalURLsPolicy == WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow; } 67 69 68 70 private: … … 73 75 WebCore::URL m_originalURL; 74 76 77 bool m_shouldOpenAppLinks; 78 75 79 WebKit::NavigationActionData m_navigationActionData; 76 80 }; -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationAction.mm
r184941 r186664 173 173 } 174 174 175 - (BOOL)_shouldOpenExternalSchemes 176 { 177 return _navigationAction->shouldOpenExternalSchemes(); 178 } 179 180 - (BOOL)_shouldOpenAppLinks 181 { 182 return _navigationAction->shouldOpenAppLinks(); 183 } 184 175 185 - (BOOL)_shouldOpenExternalURLs 176 186 { 177 return _navigationAction->shouldOpenExternalURLs();187 return [self _shouldOpenExternalSchemes]; 178 188 } 179 189 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionPrivate.h
r184941 r186664 33 33 @property (nonatomic, readonly, getter=_isUserInitiated) BOOL _userInitiated; 34 34 @property (nonatomic, readonly) BOOL _canHandleRequest; 35 @property (nonatomic, readonly) BOOL _shouldOpenExternalURLs; 35 @property (nonatomic, readonly) BOOL _shouldOpenExternalSchemes WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA); 36 @property (nonatomic, readonly) BOOL _shouldOpenAppLinks WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA); 37 38 @property (nonatomic, readonly) BOOL _shouldOpenExternalURLs WK_DEPRECATED(WK_MAC_TBA, WK_MAC_TBA, WK_IOS_TBA, WK_IOS_TBA, "use _shouldOpenExternalSchemes and _shouldOpenAppLinks"); 36 39 37 40 @end -
trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm
r186586 r186664 249 249 { 250 250 #if HAVE(APP_LINKS) 251 bool mainFrameNavigation = !navigationAction->targetFrame() || navigationAction->targetFrame()->isMainFrame(); 252 bool shouldOpenExternalURLs = navigationAction->shouldOpenExternalURLs(); 253 if (!mainFrameNavigation || !shouldOpenExternalURLs) { 254 completionHandler(false); 255 return; 256 } 257 258 // If the new URL is within the same origin as the current URL, do not try to open it externally. 259 URL currentURL = URL(ParsedURLString, currentMainFrameURL); 260 if (protocolHostAndPortAreEqual(currentURL, navigationAction->request().url())) { 251 if (!navigationAction->shouldOpenAppLinks()) { 261 252 completionHandler(false); 262 253 return; -
trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
r185877 r186664 106 106 107 107 auto sourceFrameInfo = API::FrameInfo::create(*initiatingFrame, securityOriginData.securityOrigin()); 108 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.ptr(), nullptr, request, WebCore::URL() );108 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.ptr(), nullptr, request, WebCore::URL(), true); 109 109 110 110 RetainPtr<WKWebView> webView = [delegate.get() webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(navigationAction) windowFeatures:adoptNS([[WKWindowFeatures alloc] _initWithWindowFeatures:windowFeatures]).get()]; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r186538 r186664 3256 3256 sourceFrameInfo = API::FrameInfo::create(*originatingFrame, originatingFrameSecurityOrigin.securityOrigin()); 3257 3257 3258 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.get(), destinationFrameInfo.get(), request, originalRequest.url()); 3258 bool shouldOpenAppLinks = (!destinationFrameInfo || destinationFrameInfo->isMainFrame()) && !protocolHostAndPortAreEqual(URL(ParsedURLString, m_mainFrame->url()), request.url()); 3259 3260 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.get(), destinationFrameInfo.get(), request, originalRequest.url(), shouldOpenAppLinks); 3259 3261 3260 3262 m_navigationClient->decidePolicyForNavigationAction(*this, navigationAction.get(), WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get()); … … 3285 3287 sourceFrameInfo = API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin()); 3286 3288 3287 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.get(), nullptr, request, request.url() );3289 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.get(), nullptr, request, request.url(), true); 3288 3290 3289 3291 m_navigationClient->decidePolicyForNavigationAction(*this, navigationAction.get(), WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get()); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r186538 r186664 364 364 bool isClosed() const { return m_isClosed; } 365 365 366 RefPtr<API::Navigation> loadRequest(const WebCore::ResourceRequest&, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow , API::Object* userData = nullptr);366 RefPtr<API::Navigation> loadRequest(const WebCore::ResourceRequest&, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes, API::Object* userData = nullptr); 367 367 RefPtr<API::Navigation> loadFile(const String& fileURL, const String& resourceDirectoryURL, API::Object* userData = nullptr); 368 368 RefPtr<API::Navigation> loadData(API::Data*, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData = nullptr); -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp
r185072 r186664 72 72 return toImpl(navigationActionRef)->shouldOpenExternalURLs(); 73 73 } 74 75 bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef navigationActionRef) 76 { 77 return toImpl(navigationActionRef)->shouldTryAppLinks(); 78 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h
r185072 r186664 34 34 35 35 WK_EXPORT bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef); 36 WK_EXPORT bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef); 36 37 37 38 #ifdef __cplusplus -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp
r186566 r186664 91 91 , m_modifiers(modifiersForNavigationAction(navigationAction)) 92 92 , m_mouseButton(WebMouseEvent::NoButton) 93 , m_shouldOpenExternalURLs(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow) 93 , m_shouldOpenExternalURLs(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow || navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes) 94 , m_shouldTryAppLinks(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow) 94 95 { 95 96 if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) { -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h
r186566 r186664 58 58 59 59 bool shouldOpenExternalURLs() const { return m_shouldOpenExternalURLs; } 60 bool shouldTryAppLinks() const { return m_shouldTryAppLinks; } 60 61 61 62 private: … … 68 69 RefPtr<InjectedBundleNodeHandle> m_formElement; 69 70 bool m_shouldOpenExternalURLs; 71 bool m_shouldTryAppLinks; 70 72 }; 71 73 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r185877 r186664 802 802 navigationActionData.isProcessingUserGesture = navigationAction.processingUserGesture(); 803 803 navigationActionData.canHandleRequest = webPage->canHandleRequest(request); 804 navigationActionData.shouldOpenExternalURLs = navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow;804 navigationActionData.shouldOpenExternalURLsPolicy = navigationAction.shouldOpenExternalURLsPolicy(); 805 805 806 806 WebCore::Frame* coreFrame = m_frame->coreFrame();
Note: See TracChangeset
for help on using the changeset viewer.