Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2306053002: Revert of [ios] Implemented LoadHtml w/o using data:// URLs. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4749 matching lines...) Expand 10 before | Expand all | Expand 10 after
4760 [self handleLoadError:loadError inMainFrame:YES]; 4760 [self handleLoadError:loadError inMainFrame:YES];
4761 else 4761 else
4762 self.webStateImpl->SetContentsMimeType("text/html"); 4762 self.webStateImpl->SetContentsMimeType("text/html");
4763 }]; 4763 }];
4764 } 4764 }
4765 4765
4766 - (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL { 4766 - (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL {
4767 // Remove the transient content view. 4767 // Remove the transient content view.
4768 [self clearTransientContentView]; 4768 [self clearTransientContentView];
4769 4769
4770 DLOG_IF(WARNING, !_webView) << "_webView null while trying to load HTML";
4770 _loadPhase = web::LOAD_REQUESTED; 4771 _loadPhase = web::LOAD_REQUESTED;
4771 [self ensureWebViewCreated];
4772 DCHECK(_webView) << "_webView null while trying to load HTML";
4773 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)]; 4772 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)];
4774 } 4773 }
4775 4774
4776 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL { 4775 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL {
4777 CHECK(web::GetWebClient()->IsAppSpecificURL(URL)); 4776 CHECK(web::GetWebClient()->IsAppSpecificURL(URL));
4778 [self loadHTML:HTML forURL:URL]; 4777 [self loadHTML:HTML forURL:URL];
4779 } 4778 }
4780 4779
4781 - (void)loadHTMLForCurrentURL:(NSString*)HTML { 4780 - (void)loadHTMLForCurrentURL:(NSString*)HTML {
4782 [self loadHTML:HTML forURL:self.currentURL]; 4781 [self loadHTML:HTML forURL:self.currentURL];
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 4968
4970 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; 4969 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action];
4971 4970
4972 if (allowLoad) { 4971 if (allowLoad) {
4973 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); 4972 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request);
4974 if (!allowLoad && action.targetFrame.mainFrame) { 4973 if (!allowLoad && action.targetFrame.mainFrame) {
4975 [_pendingNavigationInfo setCancelled:YES]; 4974 [_pendingNavigationInfo setCancelled:YES];
4976 } 4975 }
4977 } 4976 }
4978 4977
4978 if (!allowLoad && action.targetFrame.isMainFrame) {
4979 // WKWebView will stop this navigation without calling any further
4980 // callbacks, so change load phase to loaded now.
4981 _loadPhase = web::PAGE_LOADED;
4982 _webStateImpl->SetIsLoading(false);
4983 }
4984
4979 decisionHandler(allowLoad ? WKNavigationActionPolicyAllow 4985 decisionHandler(allowLoad ? WKNavigationActionPolicyAllow
4980 : WKNavigationActionPolicyCancel); 4986 : WKNavigationActionPolicyCancel);
4981 } 4987 }
4982 4988
4983 - (void)webView:(WKWebView*)webView 4989 - (void)webView:(WKWebView*)webView
4984 decidePolicyForNavigationResponse:(WKNavigationResponse*)navigationResponse 4990 decidePolicyForNavigationResponse:(WKNavigationResponse*)navigationResponse
4985 decisionHandler: 4991 decisionHandler:
4986 (void (^)(WKNavigationResponsePolicy))handler { 4992 (void (^)(WKNavigationResponsePolicy))handler {
4987 if ([navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]) { 4993 if ([navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]) {
4988 // Create HTTP headers from the response. 4994 // Create HTTP headers from the response.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
5629 } 5635 }
5630 5636
5631 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5637 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5632 } 5638 }
5633 5639
5634 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5640 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5635 return [action.request valueForHTTPHeaderField:@"Referer"]; 5641 return [action.request valueForHTTPHeaderField:@"Referer"];
5636 } 5642 }
5637 5643
5638 @end 5644 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.h ('k') | ios/web/web_state/ui/crw_web_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698