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

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

Issue 2295053003: [ios] Implemented LoadHtml w/o using data:// URLs. (Closed)
Patch Set: Addressed review comments 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";
4771 _loadPhase = web::LOAD_REQUESTED; 4770 _loadPhase = web::LOAD_REQUESTED;
4771 [self ensureWebViewCreated];
4772 DCHECK(_webView) << "_webView null while trying to load HTML";
4772 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)]; 4773 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)];
4773 } 4774 }
4774 4775
4775 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL { 4776 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL {
4776 CHECK(web::GetWebClient()->IsAppSpecificURL(URL)); 4777 CHECK(web::GetWebClient()->IsAppSpecificURL(URL));
4777 [self loadHTML:HTML forURL:URL]; 4778 [self loadHTML:HTML forURL:URL];
4778 } 4779 }
4779 4780
4780 - (void)loadHTMLForCurrentURL:(NSString*)HTML { 4781 - (void)loadHTMLForCurrentURL:(NSString*)HTML {
4781 [self loadHTML:HTML forURL:self.currentURL]; 4782 [self loadHTML:HTML forURL:self.currentURL];
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 4969
4969 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; 4970 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action];
4970 4971
4971 if (allowLoad) { 4972 if (allowLoad) {
4972 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); 4973 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request);
4973 if (!allowLoad && action.targetFrame.mainFrame) { 4974 if (!allowLoad && action.targetFrame.mainFrame) {
4974 [_pendingNavigationInfo setCancelled:YES]; 4975 [_pendingNavigationInfo setCancelled:YES];
4975 } 4976 }
4976 } 4977 }
4977 4978
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
4985 decisionHandler(allowLoad ? WKNavigationActionPolicyAllow 4979 decisionHandler(allowLoad ? WKNavigationActionPolicyAllow
4986 : WKNavigationActionPolicyCancel); 4980 : WKNavigationActionPolicyCancel);
4987 } 4981 }
4988 4982
4989 - (void)webView:(WKWebView*)webView 4983 - (void)webView:(WKWebView*)webView
4990 decidePolicyForNavigationResponse:(WKNavigationResponse*)navigationResponse 4984 decidePolicyForNavigationResponse:(WKNavigationResponse*)navigationResponse
4991 decisionHandler: 4985 decisionHandler:
4992 (void (^)(WKNavigationResponsePolicy))handler { 4986 (void (^)(WKNavigationResponsePolicy))handler {
4993 if ([navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]) { 4987 if ([navigationResponse.response isKindOfClass:[NSHTTPURLResponse class]]) {
4994 // Create HTTP headers from the response. 4988 // Create HTTP headers from the response.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
5635 } 5629 }
5636 5630
5637 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5631 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5638 } 5632 }
5639 5633
5640 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5634 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5641 return [action.request valueForHTTPHeaderField:@"Referer"]; 5635 return [action.request valueForHTTPHeaderField:@"Referer"];
5642 } 5636 }
5643 5637
5644 @end 5638 @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