| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; | 556 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; |
| 557 // Extracts "Referer" [sic] value from WKNavigationAction request header. | 557 // Extracts "Referer" [sic] value from WKNavigationAction request header. |
| 558 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action; | 558 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action; |
| 559 | 559 |
| 560 // Returns the current URL of the web view, and sets |trustLevel| accordingly | 560 // Returns the current URL of the web view, and sets |trustLevel| accordingly |
| 561 // based on the confidence in the verification. | 561 // based on the confidence in the verification. |
| 562 - (GURL)webURLWithTrustLevel:(web::URLVerificationTrustLevel*)trustLevel; | 562 - (GURL)webURLWithTrustLevel:(web::URLVerificationTrustLevel*)trustLevel; |
| 563 // Returns |YES| if |url| should be loaded in a native view. | 563 // Returns |YES| if |url| should be loaded in a native view. |
| 564 - (BOOL)shouldLoadURLInNativeView:(const GURL&)url; | 564 - (BOOL)shouldLoadURLInNativeView:(const GURL&)url; |
| 565 // Loads the request into the |webView|. | 565 // Loads the request into the |webView|. |
| 566 - (void)loadRequest:(NSMutableURLRequest*)request; | 566 - (WKNavigation*)loadRequest:(NSMutableURLRequest*)request; |
| 567 // Loads POST request with body in |_wkWebView| by constructing an HTML page | 567 // Loads POST request with body in |_wkWebView| by constructing an HTML page |
| 568 // that executes the request through JavaScript and replaces document with the | 568 // that executes the request through JavaScript and replaces document with the |
| 569 // result. | 569 // result. |
| 570 // Note that this approach includes multiple body encodings and decodings, plus | 570 // Note that this approach includes multiple body encodings and decodings, plus |
| 571 // the data is passed to |_wkWebView| on main thread. | 571 // the data is passed to |_wkWebView| on main thread. |
| 572 // This is necessary because WKWebView ignores POST request body. | 572 // This is necessary because WKWebView ignores POST request body. |
| 573 // Workaround for https://bugs.webkit.org/show_bug.cgi?id=145410 | 573 // Workaround for https://bugs.webkit.org/show_bug.cgi?id=145410 |
| 574 - (void)loadPOSTRequest:(NSMutableURLRequest*)request; | 574 - (WKNavigation*)loadPOSTRequest:(NSMutableURLRequest*)request; |
| 575 // Loads the HTML into the page at the given URL. | 575 // Loads the HTML into the page at the given URL. |
| 576 - (void)loadHTML:(NSString*)html forURL:(const GURL&)url; | 576 - (void)loadHTML:(NSString*)html forURL:(const GURL&)url; |
| 577 | 577 |
| 578 // Extracts navigation info from WKNavigationAction and sets it as a pending. | 578 // Extracts navigation info from WKNavigationAction and sets it as a pending. |
| 579 // Some pieces of navigation information are only known in | 579 // Some pieces of navigation information are only known in |
| 580 // |decidePolicyForNavigationAction|, but must be in a pending state until | 580 // |decidePolicyForNavigationAction|, but must be in a pending state until |
| 581 // |didgo/Navigation| where it becames current. | 581 // |didgo/Navigation| where it becames current. |
| 582 - (void)updatePendingNavigationInfoFromNavigationAction: | 582 - (void)updatePendingNavigationInfoFromNavigationAction: |
| 583 (WKNavigationAction*)action; | 583 (WKNavigationAction*)action; |
| 584 // Extracts navigation info from WKNavigationResponse and sets it as a pending. | 584 // Extracts navigation info from WKNavigationResponse and sets it as a pending. |
| (...skipping 3451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4036 _webProcessIsDead = YES; | 4036 _webProcessIsDead = YES; |
| 4037 _webStateImpl->CancelDialogs(); | 4037 _webStateImpl->CancelDialogs(); |
| 4038 _webStateImpl->OnRenderProcessGone(); | 4038 _webStateImpl->OnRenderProcessGone(); |
| 4039 } | 4039 } |
| 4040 | 4040 |
| 4041 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { | 4041 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { |
| 4042 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 4042 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
| 4043 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); | 4043 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); |
| 4044 } | 4044 } |
| 4045 | 4045 |
| 4046 - (void)loadRequest:(NSMutableURLRequest*)request { | 4046 - (WKNavigation*)loadRequest:(NSMutableURLRequest*)request { |
| 4047 WKNavigation* navigation = [_webView loadRequest:request]; |
| 4047 [_navigationStates setState:web::WKNavigationState::REQUESTED | 4048 [_navigationStates setState:web::WKNavigationState::REQUESTED |
| 4048 forNavigation:[_webView loadRequest:request]]; | 4049 forNavigation:navigation]; |
| 4050 return navigation; |
| 4049 } | 4051 } |
| 4050 | 4052 |
| 4051 - (void)loadPOSTRequest:(NSMutableURLRequest*)request { | 4053 - (WKNavigation*)loadPOSTRequest:(NSMutableURLRequest*)request { |
| 4052 if (!_POSTRequestLoader) { | 4054 if (!_POSTRequestLoader) { |
| 4053 _POSTRequestLoader.reset([[CRWJSPOSTRequestLoader alloc] init]); | 4055 _POSTRequestLoader.reset([[CRWJSPOSTRequestLoader alloc] init]); |
| 4054 } | 4056 } |
| 4055 | 4057 |
| 4056 CRWWKScriptMessageRouter* messageRouter = | 4058 CRWWKScriptMessageRouter* messageRouter = |
| 4057 [self webViewConfigurationProvider].GetScriptMessageRouter(); | 4059 [self webViewConfigurationProvider].GetScriptMessageRouter(); |
| 4058 | 4060 |
| 4059 [_POSTRequestLoader loadPOSTRequest:request | 4061 return [_POSTRequestLoader |
| 4060 inWebView:_webView | 4062 loadPOSTRequest:request |
| 4061 messageRouter:messageRouter | 4063 inWebView:_webView |
| 4062 completionHandler:^(NSError* loadError) { | 4064 messageRouter:messageRouter |
| 4063 if (loadError) | 4065 completionHandler:^(NSError* loadError) { |
| 4064 [self handleLoadError:loadError | 4066 if (loadError) |
| 4065 inMainFrame:YES | 4067 [self handleLoadError:loadError inMainFrame:YES forNavigation:nil]; |
| 4066 forNavigation:nil]; | 4068 else |
| 4067 else | 4069 self.webStateImpl->SetContentsMimeType("text/html"); |
| 4068 self.webStateImpl->SetContentsMimeType("text/html"); | 4070 }]; |
| 4069 }]; | |
| 4070 } | 4071 } |
| 4071 | 4072 |
| 4072 - (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL { | 4073 - (void)loadHTML:(NSString*)HTML forURL:(const GURL&)URL { |
| 4073 // Remove the transient content view. | 4074 // Remove the transient content view. |
| 4074 [self clearTransientContentView]; | 4075 [self clearTransientContentView]; |
| 4075 | 4076 |
| 4076 _loadPhase = web::LOAD_REQUESTED; | 4077 _loadPhase = web::LOAD_REQUESTED; |
| 4077 | 4078 |
| 4078 // Web View should not be created for App Specific URLs. | 4079 // Web View should not be created for App Specific URLs. |
| 4079 if (!web::GetWebClient()->IsAppSpecificURL(URL)) { | 4080 if (!web::GetWebClient()->IsAppSpecificURL(URL)) { |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5065 - (NSUInteger)observerCount { | 5066 - (NSUInteger)observerCount { |
| 5066 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5067 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
| 5067 return [_observers count]; | 5068 return [_observers count]; |
| 5068 } | 5069 } |
| 5069 | 5070 |
| 5070 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5071 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5071 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5072 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5072 } | 5073 } |
| 5073 | 5074 |
| 5074 @end | 5075 @end |
| OLD | NEW |