| 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 4797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4808 // This happens during tests. | 4808 // This happens during tests. |
| 4809 if (!_webView) { | 4809 if (!_webView) { |
| 4810 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 4810 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 4811 } | 4811 } |
| 4812 | 4812 |
| 4813 std::string MIMEType = self.webState->GetContentsMimeType(); | 4813 std::string MIMEType = self.webState->GetContentsMimeType(); |
| 4814 return [self documentTypeFromMIMEType:base::SysUTF8ToNSString(MIMEType)]; | 4814 return [self documentTypeFromMIMEType:base::SysUTF8ToNSString(MIMEType)]; |
| 4815 } | 4815 } |
| 4816 | 4816 |
| 4817 - (void)loadRequest:(NSMutableURLRequest*)request { | 4817 - (void)loadRequest:(NSMutableURLRequest*)request { |
| 4818 _latestWKNavigation.reset([[_webView loadRequest:request] retain]); | 4818 if ([[request URL] isFileURL]) { |
| 4819 NSURL* url = [request URL]; |
| 4820 NSMutableArray* partsArray = |
| 4821 [NSMutableArray arrayWithArray:[url pathComponents]]; |
| 4822 [partsArray removeLastObject]; |
| 4823 _latestWKNavigation.reset([[_webView |
| 4824 loadFileURL:url |
| 4825 allowingReadAccessToURL:[NSURL fileURLWithPathComponents:partsArray]] |
| 4826 retain]); |
| 4827 } else { |
| 4828 _latestWKNavigation.reset([[_webView loadRequest:request] retain]); |
| 4829 } |
| 4819 } | 4830 } |
| 4820 | 4831 |
| 4821 - (void)loadPOSTRequest:(NSMutableURLRequest*)request { | 4832 - (void)loadPOSTRequest:(NSMutableURLRequest*)request { |
| 4822 if (!_POSTRequestLoader) { | 4833 if (!_POSTRequestLoader) { |
| 4823 _POSTRequestLoader.reset([[CRWJSPOSTRequestLoader alloc] init]); | 4834 _POSTRequestLoader.reset([[CRWJSPOSTRequestLoader alloc] init]); |
| 4824 } | 4835 } |
| 4825 | 4836 |
| 4826 CRWWKScriptMessageRouter* messageRouter = | 4837 CRWWKScriptMessageRouter* messageRouter = |
| 4827 [self webViewConfigurationProvider].GetScriptMessageRouter(); | 4838 [self webViewConfigurationProvider].GetScriptMessageRouter(); |
| 4828 | 4839 |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5748 } | 5759 } |
| 5749 | 5760 |
| 5750 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5761 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5751 } | 5762 } |
| 5752 | 5763 |
| 5753 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5764 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5754 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5765 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5755 } | 5766 } |
| 5756 | 5767 |
| 5757 @end | 5768 @end |
| OLD | NEW |