OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 3458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3469 CRWSessionEntry* currentEntry = [self currentSessionEntry]; | 3469 CRWSessionEntry* currentEntry = [self currentSessionEntry]; |
3470 // TODO(crbug.com/570699): Remove this check once it's no longer possible to | 3470 // TODO(crbug.com/570699): Remove this check once it's no longer possible to |
3471 // have no current entries. | 3471 // have no current entries. |
3472 if (currentEntry) | 3472 if (currentEntry) |
3473 [self cachePOSTDataForRequest:request inSessionEntry:currentEntry]; | 3473 [self cachePOSTDataForRequest:request inSessionEntry:currentEntry]; |
3474 } | 3474 } |
3475 | 3475 |
3476 return YES; | 3476 return YES; |
3477 } | 3477 } |
3478 | 3478 |
| 3479 - (void)displayOfflineVersionForURL:(const GURL&)URL { |
| 3480 if ([_nativeProvider hasControllerForURL:URL]) { |
| 3481 id<CRWNativeContent> controller = [_nativeProvider controllerForURL:URL]; |
| 3482 web::NavigationItem* item = |
| 3483 self.webState->GetNavigationManager()->GetItemAtIndex( |
| 3484 self.webState->GetNavigationManager()->GetCurrentItemIndex()); |
| 3485 // Allows the native content to set the displayed URL. |
| 3486 if (item) { |
| 3487 item->SetURL([controller url]); |
| 3488 if ([controller respondsToSelector:@selector(virtualURL)]) { |
| 3489 item->SetVirtualURL([controller virtualURL]); |
| 3490 } |
| 3491 } |
| 3492 [self loadCompleteWithSuccess:NO]; |
| 3493 [self removeWebViewAllowingCachedReconstruction:NO]; |
| 3494 [self setNativeController:controller]; |
| 3495 [self loadNativeViewWithSuccess:YES]; |
| 3496 } |
| 3497 } |
| 3498 |
3479 - (void)handleLoadError:(NSError*)error inMainFrame:(BOOL)inMainFrame { | 3499 - (void)handleLoadError:(NSError*)error inMainFrame:(BOOL)inMainFrame { |
3480 NSString* MIMEType = [_pendingNavigationInfo MIMEType]; | 3500 NSString* MIMEType = [_pendingNavigationInfo MIMEType]; |
3481 if ([_passKitDownloader isMIMETypePassKitType:MIMEType]) | 3501 if ([_passKitDownloader isMIMETypePassKitType:MIMEType]) |
3482 return; | 3502 return; |
3483 if ([error code] == NSURLErrorUnsupportedURL) | 3503 if ([error code] == NSURLErrorUnsupportedURL) |
3484 return; | 3504 return; |
3485 // In cases where a Plug-in handles the load do not take any further action. | 3505 // In cases where a Plug-in handles the load do not take any further action. |
3486 if ([error.domain isEqual:base::SysUTF8ToNSString(web::kWebKitErrorDomain)] && | 3506 if ([error.domain isEqual:base::SysUTF8ToNSString(web::kWebKitErrorDomain)] && |
3487 (error.code == web::kWebKitErrorPlugInLoadFailed || | 3507 (error.code == web::kWebKitErrorPlugInLoadFailed || |
3488 error.code == web::kWebKitErrorCannotShowUrl)) | 3508 error.code == web::kWebKitErrorCannotShowUrl)) |
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5792 } | 5812 } |
5793 | 5813 |
5794 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5814 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
5795 } | 5815 } |
5796 | 5816 |
5797 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5817 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
5798 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5818 return [action.request valueForHTTPHeaderField:@"Referer"]; |
5799 } | 5819 } |
5800 | 5820 |
5801 @end | 5821 @end |
OLD | NEW |