Changeset 221216 in webkit
- Timestamp:
- Aug 25, 2017, 5:13:47 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221215 r221216 1 2017-08-25 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's saveDataToFileInDownloadsFolder 4 https://bugs.webkit.org/show_bug.cgi?id=176000 5 <rdar://problem/29270035> 6 7 Reviewed by Andy Estes. 8 9 Covered by a new API test. 10 11 * Shared/Cocoa/WKNSData.h: 12 (wrapper): Deleted. 13 * UIProcess/API/APIUIClient.h: 14 (API::UIClient::saveDataToFileInDownloadsFolder): 15 * UIProcess/API/C/WKPage.cpp: 16 (WKPageSetPageUIClient): 17 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 18 * UIProcess/Cocoa/UIDelegate.h: 19 * UIProcess/Cocoa/UIDelegate.mm: 20 (WebKit::UIDelegate::setDelegate): 21 (WebKit::UIDelegate::UIClient::saveDataToFileInDownloadsFolder): 22 * UIProcess/WebPageProxy.cpp: 23 (WebKit::WebPageProxy::saveDataToFileInDownloadsFolder): 24 (WebKit::WebPageProxy::savePDFToFileInDownloadsFolder): 25 * UIProcess/WebPageProxy.h: 26 * UIProcess/WebPageProxy.messages.in: 27 * WebProcess/WebPage/WebFrame.cpp: 28 (WebKit::WebFrame::url const): 29 * WebProcess/WebPage/WebFrame.h: 30 * WebProcess/WebPage/WebPage.cpp: 31 (WebKit::WebPage::savePDFToFileInDownloadsFolder): 32 * WebProcess/WebPage/WebPage.h: 33 1 34 2017-08-25 David Kilzer <ddkilzer@apple.com> 2 35 -
trunk/Source/WebKit/Shared/Cocoa/WKNSData.h
r160653 r221216 31 31 #import "WKObject.h" 32 32 33 namespace API { 34 33 35 inline NSData *wrapper(API::Data& data) 34 36 { … … 37 39 } 38 40 41 } 42 39 43 @interface WKNSData : NSData <WKObject> 40 44 @end -
trunk/Source/WebKit/UIProcess/API/APIUIClient.h
r221102 r221216 143 143 virtual void runModal(WebKit::WebPageProxy*) { } 144 144 145 virtual void saveDataToFileInDownloadsFolder(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, const W TF::String&, Data*) { }145 virtual void saveDataToFileInDownloadsFolder(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, const WebCore::URL&, Data&) { } 146 146 147 147 virtual void pinnedStateDidChange(WebKit::WebPageProxy&) { } -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r221102 r221216 2044 2044 } 2045 2045 2046 void saveDataToFileInDownloadsFolder(WebPageProxy* page, const String& suggestedFilename, const String& mimeType, const String& originatingURLString, API::Data*data) final2046 void saveDataToFileInDownloadsFolder(WebPageProxy* page, const String& suggestedFilename, const String& mimeType, const WebCore::URL& originatingURL, API::Data& data) final 2047 2047 { 2048 2048 if (!m_client.saveDataToFileInDownloadsFolder) 2049 2049 return; 2050 2050 2051 m_client.saveDataToFileInDownloadsFolder(toAPI(page), toAPI(suggestedFilename.impl()), toAPI(mimeType.impl()), toURLRef(originatingURL String.impl()), toAPI(data), m_client.base.clientInfo);2051 m_client.saveDataToFileInDownloadsFolder(toAPI(page), toAPI(suggestedFilename.impl()), toAPI(mimeType.impl()), toURLRef(originatingURL.string().impl()), toAPI(&data), m_client.base.clientInfo); 2052 2052 } 2053 2053 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r221172 r221216 33 33 #import <WebKit/_WKActivatedElementInfo.h> 34 34 35 @class NSData; 35 36 @class UIScrollView; 36 37 @class UIViewController; … … 144 145 - (void)_webView:(WKWebView *)webView didNotHandleWheelEvent:(NSEvent *)event WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 145 146 - (void)_webView:(WKWebView *)webView handleAutoplayEvent:(_WKAutoplayEvent)event withFlags:(_WKAutoplayEventFlags)flags WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 147 - (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 146 148 - (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element WK_API_AVAILABLE(macosx(10.12)); 147 149 - (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element userInfo:(id <NSSecureCoding>)userInfo WK_API_AVAILABLE(macosx(10.12)); -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r221172 r221216 101 101 void focus(WebPageProxy*) final; 102 102 void unfocus(WebPageProxy*) final; 103 void didNotHandleWheelEvent(Web Kit::WebPageProxy*, const WebKit::NativeWebWheelEvent&) final;104 void handleAutoplayEvent(Web Kit::WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;103 void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final; 104 void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final; 105 105 bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final; 106 void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const WebCore::URL&, API::Data&) final; 106 107 #endif 107 108 bool decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, API::SecurityOrigin&, UserMediaPermissionRequestProxy&) final; … … 149 150 bool webViewDidNotHandleWheelEvent : 1; 150 151 bool webViewHandleAutoplayEventWithFlags : 1; 152 bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1; 151 153 bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1; 152 154 #endif -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r221172 r221216 36 36 #import "UserMediaPermissionRequestProxy.h" 37 37 #import "WKFrameInfoInternal.h" 38 #import "WKNSData.h" 38 39 #import "WKNavigationActionInternal.h" 39 40 #import "WKOpenPanelParametersInternal.h" … … 108 109 m_delegateMethods.webViewDidNotHandleWheelEvent = [delegate respondsToSelector:@selector(_webView:didNotHandleWheelEvent:)]; 109 110 m_delegateMethods.webViewHandleAutoplayEventWithFlags = [delegate respondsToSelector:@selector(_webView:handleAutoplayEvent:withFlags:)]; 111 m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL = [delegate respondsToSelector:@selector(_webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:)]; 110 112 m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)]; 111 113 #endif 112 113 114 m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)]; 114 115 m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)]; … … 487 488 [(id <WKUIDelegatePrivate>)delegate _showWebView:m_uiDelegate.m_webView]; 488 489 } 489 490 491 void UIDelegate::UIClient::saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String& suggestedFilename, const WTF::String& mimeType, const WebCore::URL& originatingURL, API::Data& data) 492 { 493 if (!m_uiDelegate.m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL) 494 return; 495 496 auto delegate = m_uiDelegate.m_delegate.get(); 497 if (!delegate) 498 return; 499 500 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView saveDataToFile:wrapper(data) suggestedFilename:suggestedFilename mimeType:mimeType originatingURL:originatingURL]; 501 } 502 490 503 bool UIDelegate::UIClient::runOpenPanel(WebPageProxy*, WebFrameProxy* webFrameProxy, const WebCore::SecurityOriginData& securityOriginData, API::OpenPanelParameters* openPanelParameters, WebOpenPanelResultListenerProxy* listener) 491 504 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r221102 r221216 6114 6114 } 6115 6115 6116 void WebPageProxy::saveDataToFileInDownloadsFolder( const String& suggestedFilename, const String& mimeType, const String& originatingURLString, API::Data*data)6116 void WebPageProxy::saveDataToFileInDownloadsFolder(String&& suggestedFilename, String&& mimeType, URL&& originatingURLString, API::Data& data) 6117 6117 { 6118 6118 m_uiClient->saveDataToFileInDownloadsFolder(this, suggestedFilename, mimeType, originatingURLString, data); 6119 6119 } 6120 6120 6121 void WebPageProxy::savePDFToFileInDownloadsFolder( const String& suggestedFilename, const String& originatingURLString, const IPC::DataReference& dataReference)6121 void WebPageProxy::savePDFToFileInDownloadsFolder(String&& suggestedFilename, URL&& originatingURL, const IPC::DataReference& dataReference) 6122 6122 { 6123 6123 if (!suggestedFilename.endsWith(".pdf", false)) 6124 6124 return; 6125 6125 6126 saveDataToFileInDownloadsFolder( suggestedFilename, "application/pdf", originatingURLString,6127 API::Data::create(dataReference.data(), dataReference.size()). ptr());6126 saveDataToFileInDownloadsFolder(WTFMove(suggestedFilename), ASCIILiteral("application/pdf"), WTFMove(originatingURL), 6127 API::Data::create(dataReference.data(), dataReference.size()).get()); 6128 6128 } 6129 6129 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r221065 r221216 951 951 #endif 952 952 953 void saveDataToFileInDownloadsFolder( const String& suggestedFilename, const String& mimeType, const String& originatingURLString, API::Data*);954 void savePDFToFileInDownloadsFolder( const String& suggestedFilename, const String& originatingURLString, const IPC::DataReference&);953 void saveDataToFileInDownloadsFolder(String&& suggestedFilename, String&& mimeType, WebCore::URL&& originatingURL, API::Data&); 954 void savePDFToFileInDownloadsFolder(String&& suggestedFilename, WebCore::URL&& originatingURL, const IPC::DataReference&); 955 955 #if PLATFORM(COCOA) 956 956 void savePDFToTemporaryFolderAndOpenWithNativeApplicationRaw(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID); -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r219709 r221216 405 405 LoadRecentSearches(String name) -> (Vector<WebCore::RecentSearch> result) 406 406 407 SavePDFToFileInDownloadsFolder(String suggestedFilename, String originatingURLString, IPC::DataReference data)407 SavePDFToFileInDownloadsFolder(String suggestedFilename, WebCore::URL originatingURL, IPC::DataReference data) 408 408 409 409 #if PLATFORM(COCOA) -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp
r218487 r221216 86 86 87 87 if (frame->priv->uri.isNull()) 88 frame->priv->uri = frame->priv->webFrame->url(). utf8();88 frame->priv->uri = frame->priv->webFrame->url().string().utf8(); 89 89 90 90 return frame->priv->uri.data(); -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
r221068 r221216 393 393 } 394 394 395 StringWebFrame::url() const396 { 397 if (!m_coreFrame) 398 return String();399 400 DocumentLoader* documentLoader = m_coreFrame->loader().documentLoader();395 URL WebFrame::url() const 396 { 397 if (!m_coreFrame) 398 return { }; 399 400 auto* documentLoader = m_coreFrame->loader().documentLoader(); 401 401 if (!documentLoader) 402 return String();403 404 return documentLoader->url() .string();402 return { }; 403 404 return documentLoader->url(); 405 405 } 406 406 -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h
r220857 r221216 99 99 bool isMainFrame() const; 100 100 String name() const; 101 Stringurl() const;101 WebCore::URL url() const; 102 102 WebCore::CertificateInfo certificateInfo() const; 103 103 String innerText() const; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r221177 r221216 4563 4563 #endif 4564 4564 4565 void WebPage::savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size)4566 { 4567 send(Messages::WebPageProxy::SavePDFToFileInDownloadsFolder(suggestedFilename, originatingURL String, IPC::DataReference(data, size)));4565 void WebPage::savePDFToFileInDownloadsFolder(const String& suggestedFilename, const URL& originatingURL, const uint8_t* data, unsigned long size) 4566 { 4567 send(Messages::WebPageProxy::SavePDFToFileInDownloadsFolder(suggestedFilename, originatingURL, IPC::DataReference(data, size))); 4568 4568 } 4569 4569 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r221065 r221216 872 872 #endif 873 873 874 void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);874 void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const WebCore::URL& originatingURL, const uint8_t* data, unsigned long size); 875 875 #if PLATFORM(COCOA) 876 876 void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID); -
trunk/Tools/ChangeLog
r221214 r221216 1 2017-08-25 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's saveDataToFileInDownloadsFolder 4 https://bugs.webkit.org/show_bug.cgi?id=176000 5 <rdar://problem/29270035> 6 7 Reviewed by Andy Estes. 8 9 * TestWebKitAPI/Tests/WebKit2Cocoa/UIDelegate.mm: 10 (-[FocusDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 11 (TEST): 12 (-[SaveDataToFileDelegate _webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:]): 13 (-[SaveDataToFileDelegate webView:didFinishNavigation:]): 14 1 15 2017-08-25 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/UIDelegate.mm
r221172 r221216 101 101 } 102 102 103 static RetainPtr<NSWindow> window;104 103 static _WKFocusDirection takenDirection; 105 104 … … 118 117 { 119 118 completionHandler(); 120 synthesizeTab( window.get(), webView, true);119 synthesizeTab([webView window], webView, true); 121 120 } 122 121 … … 125 124 TEST(WebKit2, Focus) 126 125 { 127 window = adoptNS([[NSWindow alloc] initWithContentRect:CGRectMake(0, 0, 800, 600) styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES]);128 126 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]); 129 [[window contentView] addSubview:webView.get()];130 127 auto delegate = adoptNS([[FocusDelegate alloc] init]); 131 128 [webView setUIDelegate:delegate.get()]; … … 135 132 TestWebKitAPI::Util::run(&done); 136 133 ASSERT_EQ(takenDirection, _WKFocusDirectionBackward); 134 } 135 136 @interface SaveDataToFileDelegate : NSObject <WKUIDelegatePrivate, WKNavigationDelegate> 137 @end 138 139 @implementation SaveDataToFileDelegate 140 141 - (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url 142 { 143 NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]; 144 EXPECT_TRUE([data isEqualToData:[NSData dataWithContentsOfURL:pdfURL]]); 145 EXPECT_STREQ([suggestedFilename UTF8String], "test.pdf"); 146 EXPECT_STREQ([mimeType UTF8String], "application/pdf"); 147 EXPECT_STREQ([[url absoluteString] UTF8String], [[pdfURL absoluteString] UTF8String]); 148 done = true; 149 } 150 151 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 152 { 153 NSPoint location = NSMakePoint(490, 70); // Location of button to download the pdf. 154 [(TestWKWebView *)webView mouseDownAtPoint:location simulatePressure:NO]; 155 [(TestWKWebView *)webView mouseUpAtPoint:location]; 156 } 157 158 @end 159 160 TEST(WebKit2, SaveDataToFile) 161 { 162 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]); 163 auto delegate = adoptNS([[SaveDataToFileDelegate alloc] init]); 164 [webView setUIDelegate:delegate.get()]; 165 [webView setNavigationDelegate:delegate.get()]; 166 NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]; 167 [webView loadRequest:[NSURLRequest requestWithURL:pdfURL]]; 168 TestWebKitAPI::Util::run(&done); 137 169 } 138 170
Note:
See TracChangeset
for help on using the changeset viewer.