Changeset 159876 in webkit
- Timestamp:
- Nov 29, 2013, 3:21:08 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebKit2/ChangeLog ¶
r159875 r159876 1 2013-11-29 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Add a way to recover from load errors 4 https://bugs.webkit.org/show_bug.cgi?id=125020 5 6 Reviewed by Sam Weinig. 7 8 * UIProcess/API/Cocoa/WKBrowsingContextController.mm: 9 (createErrorWithRecoveryAttempter): Added this helper function. It creates an NSError from 10 the given error, adding two keys to the user info dictionary: the context controller under 11 the recovery attempter key, and the frame under a private key. 12 (didFailProvisionalLoadWithErrorForFrame): Changed to use createErrorWithRecoveryAttempter. 13 (didFailLoadWithErrorForFrame): Ditto. 14 (-[WKBrowsingContextController attemptRecoveryFromError:]): Implemented this 15 WKErrorRecoveryAttempting protocol method by loading the failing URL from the error into the 16 frame from the error. 17 18 * UIProcess/API/Cocoa/WKErrorRecoveryAttempting.h: Added. Defines a protocol for attempting 19 recovery from errors and declares the error user info dictionary key under which an object 20 conforming to this protocol may be stored. 21 * UIProcess/API/Cocoa/WKErrorRecoveryAttempting.m: Added. Defines 22 WKRecoveryAttempterErrorKey. 23 24 * UIProcess/WebFrameProxy.cpp: 25 (WebKit::WebFrameProxy::loadURL): Added. Sends the LoadURLInFrame message to the page. 26 * UIProcess/WebFrameProxy.h: 27 28 * WebKit2.xcodeproj/project.pbxproj: Added references to new files. 29 30 * WebProcess/WebPage/WebPage.cpp: 31 (WebKit::WebPage::loadURLInFrame): Added. Loads the URL in the given frame. 32 * WebProcess/WebPage/WebPage.h: 33 * WebProcess/WebPage/WebPage.messages.in: Added LoadURLInFrame. 34 1 35 2013-11-29 Dan Bernstein <mitz@apple.com> 2 36 -
TabularUnified trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm ¶
r159875 r159876 33 33 #import "WKBackForwardListItemInternal.h" 34 34 #import "WKErrorCF.h" 35 #import "WKErrorRecoveryAttempting.h" 35 36 #import "WKFrame.h" 36 37 #import "WKFramePolicyListener.h" 37 38 #import "WKNSArray.h" 39 #import "WKNSError.h" 38 40 #import "WKNSURLExtras.h" 39 41 #import "WKPagePrivate.h" … … 102 104 NSString * const WKActionCanShowMIMETypeKey = @"WKActionCanShowMIMETypeKey"; 103 105 106 static NSString * const frameErrorKey = @"WKBrowsingContextFrameErrorKey"; 107 108 @interface WKBrowsingContextController () <WKErrorRecoveryAttempting> 109 @end 110 104 111 @implementation WKBrowsingContextController { 105 112 // Underlying WKPageRef. … … 374 381 } 375 382 383 static NSError *createErrorWithRecoveryAttempter(WKErrorRef wkError, WKFrameRef frame, WKBrowsingContextController *browsingContext) 384 { 385 NSError *error = wrapper(*toImpl(wkError)); 386 NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: 387 browsingContext, WKRecoveryAttempterErrorKey, 388 toImpl(frame)->wrapper(), frameErrorKey, 389 nil]; 390 391 if (NSDictionary *originalUserInfo = error.userInfo) 392 [userInfo addEntriesFromDictionary:originalUserInfo]; 393 394 return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:userInfo]; 395 } 396 376 397 static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) 377 398 { … … 401 422 WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo; 402 423 if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailProvisionalLoad:withError:)]) { 403 RetainPtr< CFErrorRef> cfError = adoptCF(WKErrorCopyCFError(kCFAllocatorDefault, error));404 [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError: (NSError *)cfError.get()];424 RetainPtr<NSError> nsError = adoptNS(createErrorWithRecoveryAttempter(error, frame, browsingContext)); 425 [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError:nsError.get()]; 405 426 } 406 427 } … … 433 454 WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo; 434 455 if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailLoad:withError:)]) { 435 RetainPtr< CFErrorRef> cfError = adoptCF(WKErrorCopyCFError(kCFAllocatorDefault, error));436 [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError: (NSError *)cfError.get()];456 RetainPtr<NSError> nsError = adoptNS(createErrorWithRecoveryAttempter(error, frame, browsingContext)); 457 [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError:nsError.get()]; 437 458 } 438 459 } … … 611 632 return customSchemes; 612 633 } 613 634 635 #pragma mark WKErrorRecoveryAttempting 636 637 - (BOOL)attemptRecoveryFromError:(NSError *)error 638 { 639 NSDictionary *userInfo = error.userInfo; 640 641 NSString *failingURLString = userInfo[NSURLErrorFailingURLStringErrorKey]; 642 if (!failingURLString) 643 return NO; 644 645 NSObject <WKObject> *frame = userInfo[frameErrorKey]; 646 if (![frame conformsToProtocol:@protocol(WKObject)]) 647 return NO; 648 649 if (frame._apiObject.type() != API::Object::Type::Frame) 650 return NO; 651 652 WebFrameProxy& webFrame = *static_cast<WebFrameProxy*>(&frame._apiObject); 653 webFrame.loadURL(failingURLString); 654 655 return YES; 656 } 657 614 658 @end 615 659 -
TabularUnified trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp ¶
r159647 r159876 74 74 } 75 75 76 void WebFrameProxy::loadURL(const String& url) 77 { 78 if (!m_page) 79 return; 80 81 m_page->process()->send(Messages::WebPage::LoadURLInFrame(url, m_frameID), m_page->pageID()); 82 } 83 76 84 void WebFrameProxy::stopLoading() const 77 85 { -
TabularUnified trunk/Source/WebKit2/UIProcess/WebFrameProxy.h ¶
r159647 r159876 72 72 FrameLoadState& frameLoadState() { return m_frameLoadState; } 73 73 74 void loadURL(const String&); 74 75 void stopLoading() const; 75 76 -
TabularUnified trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj ¶
r159874 r159876 454 454 37C4C0951814B9E6003688B9 /* WKBackForwardListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08E1814AF3A003688B9 /* WKBackForwardListInternal.h */; }; 455 455 37C4E9F6131C6E7E0029BD5A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = B396EA5512E0ED2D00F4FEB7 /* config.h */; }; 456 37D0B5C61845218400F6CE7D /* WKErrorRecoveryAttempting.h in Headers */ = {isa = PBXBuildFile; fileRef = 37D0B5C51845218400F6CE7D /* WKErrorRecoveryAttempting.h */; settings = {ATTRIBUTES = (Public, ); }; }; 457 37D0B5C81845232700F6CE7D /* WKErrorRecoveryAttempting.m in Sources */ = {isa = PBXBuildFile; fileRef = 37D0B5C71845232700F6CE7D /* WKErrorRecoveryAttempting.m */; }; 456 458 37DFA7001810BB92001F4A9F /* WKFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 37DFA6FF1810BB92001F4A9F /* WKFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 457 459 37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F623B712A57B6200E3FDF6 /* WKFindOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1978 1980 37C4C0911814B3AF003688B9 /* WKNSArray.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSArray.mm; sourceTree = "<group>"; }; 1979 1981 37C4C0921814B3AF003688B9 /* WKNSArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSArray.h; sourceTree = "<group>"; }; 1982 37D0B5C51845218400F6CE7D /* WKErrorRecoveryAttempting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKErrorRecoveryAttempting.h; sourceTree = "<group>"; }; 1983 37D0B5C71845232700F6CE7D /* WKErrorRecoveryAttempting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKErrorRecoveryAttempting.m; sourceTree = "<group>"; }; 1980 1984 37DFA6FF1810BB92001F4A9F /* WKFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFoundation.h; sourceTree = "<group>"; }; 1981 1985 37F623B712A57B6200E3FDF6 /* WKFindOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindOptions.h; sourceTree = "<group>"; }; … … 3759 3763 BCA284D41492F2C7001F9042 /* WKConnection.mm */, 3760 3764 BC5C75C614954DA600BC4775 /* WKConnectionInternal.h */, 3765 37D0B5C51845218400F6CE7D /* WKErrorRecoveryAttempting.h */, 3766 37D0B5C71845232700F6CE7D /* WKErrorRecoveryAttempting.m */, 3761 3767 370F34A11829BE1E009027C8 /* WKNavigationData.h */, 3762 3768 370F34A01829BE1E009027C8 /* WKNavigationData.mm */, … … 5928 5934 D3B9484911FF4B6500032B39 /* WebSearchPopupMenu.h in Headers */, 5929 5935 F634445612A885C8000612D8 /* WebSecurityOrigin.h in Headers */, 5936 37D0B5C61845218400F6CE7D /* WKErrorRecoveryAttempting.h in Headers */, 5930 5937 BCC5715B115ADAEF001CCAF9 /* WebSystemInterface.h in Headers */, 5931 5938 1A594ABB112A1FB6009DE7C7 /* WebUIClient.h in Headers */, … … 6926 6933 E1EE53E711F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp in Sources */, 6927 6934 BC14E109120B905E00826C0C /* InjectedBundlePageFormClient.cpp in Sources */, 6935 37D0B5C81845232700F6CE7D /* WKErrorRecoveryAttempting.m in Sources */, 6928 6936 CD5C66A0134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.cpp in Sources */, 6929 6937 755422CB180650020046F6A8 /* WebOriginDataManager.cpp in Sources */, -
TabularUnified trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp ¶
r159765 r159876 854 854 } 855 855 856 void WebPage::loadURLInFrame(const String& url, uint64_t frameID) 857 { 858 WebFrame* frame = WebProcess::shared().webFrame(frameID); 859 if (!frame) 860 return; 861 862 frame->coreFrame()->loader().load(FrameLoadRequest(frame->coreFrame(), ResourceRequest(URL(URL(), url)))); 863 } 864 856 865 void WebPage::loadURLRequest(const ResourceRequest& request, const SandboxExtension::Handle& sandboxExtensionHandle, CoreIPC::MessageDecoder& decoder) 857 866 { -
TabularUnified trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h ¶
r159724 r159876 739 739 static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity); 740 740 741 void loadURLInFrame(const String&, uint64_t frameID); 742 741 743 uint64_t restoreSession(const SessionState&); 742 744 void restoreSessionAndNavigateToCurrentItem(const SessionState&); -
TabularUnified trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in ¶
r159724 r159876 73 73 74 74 LoadURL(WTF::String url, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::WebContextUserMessageEncoder userData) Variadic 75 LoadURLInFrame(WTF::String url, uint64_t frameID) 75 76 LoadURLRequest(WebCore::ResourceRequest request, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::WebContextUserMessageEncoder userData) Variadic 76 77 LoadData(CoreIPC::DataReference data, WTF::String MIMEType, WTF::String encoding, WTF::String baseURL, WebKit::WebContextUserMessageEncoder userData) Variadic
Note:
See TracChangeset
for help on using the changeset viewer.