| 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 5234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5245 // This must be reset at the end, since code above may need information about | 5245 // This must be reset at the end, since code above may need information about |
| 5246 // the pending load. | 5246 // the pending load. |
| 5247 _pendingNavigationInfo.reset(); | 5247 _pendingNavigationInfo.reset(); |
| 5248 _certVerificationErrors->Clear(); | 5248 _certVerificationErrors->Clear(); |
| 5249 } | 5249 } |
| 5250 | 5250 |
| 5251 - (void)webView:(WKWebView*)webView | 5251 - (void)webView:(WKWebView*)webView |
| 5252 didCommitNavigation:(WKNavigation*)navigation { | 5252 didCommitNavigation:(WKNavigation*)navigation { |
| 5253 DCHECK_EQ(_webView, webView); | 5253 DCHECK_EQ(_webView, webView); |
| 5254 _certVerificationErrors->Clear(); | 5254 _certVerificationErrors->Clear(); |
| 5255 // This point should closely approximate the document object change, so reset | |
| 5256 // the list of injected scripts to those that are automatically injected. | |
| 5257 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); | |
| 5258 [self injectWindowID]; | |
| 5259 | 5255 |
| 5260 // This is the point where the document's URL has actually changed, and | 5256 // This is the point where the document's URL has actually changed, and |
| 5261 // pending navigation information should be applied to state information. | 5257 // pending navigation information should be applied to state information. |
| 5262 [self setDocumentURL:net::GURLWithNSURL([_webView URL])]; | 5258 [self setDocumentURL:net::GURLWithNSURL([_webView URL])]; |
| 5263 | 5259 |
| 5264 if (!_lastRegisteredRequestURL.is_valid() && | 5260 if (!_lastRegisteredRequestURL.is_valid() && |
| 5265 _documentURL != _lastRegisteredRequestURL) { | 5261 _documentURL != _lastRegisteredRequestURL) { |
| 5266 // if |_lastRegisteredRequestURL| is an invalid URL, then |_documentURL| | 5262 // if |_lastRegisteredRequestURL| is an invalid URL, then |_documentURL| |
| 5267 // will be "about:blank". | 5263 // will be "about:blank". |
| 5268 [[self sessionController] updatePendingEntry:_documentURL]; | 5264 [[self sessionController] updatePendingEntry:_documentURL]; |
| 5269 } | 5265 } |
| 5270 DCHECK(_documentURL == _lastRegisteredRequestURL || | 5266 DCHECK(_documentURL == _lastRegisteredRequestURL || |
| 5271 (!_lastRegisteredRequestURL.is_valid() && | 5267 (!_lastRegisteredRequestURL.is_valid() && |
| 5272 _documentURL.spec() == url::kAboutBlankURL)); | 5268 _documentURL.spec() == url::kAboutBlankURL)); |
| 5273 | 5269 |
| 5274 self.webStateImpl->OnNavigationCommitted(_documentURL); | 5270 self.webStateImpl->OnNavigationCommitted(_documentURL); |
| 5275 [self commitPendingNavigationInfo]; | 5271 [self commitPendingNavigationInfo]; |
| 5276 if ([self currentBackForwardListItemHolder]->navigation_type() == | 5272 if ([self currentBackForwardListItemHolder]->navigation_type() == |
| 5277 WKNavigationTypeBackForward) { | 5273 WKNavigationTypeBackForward) { |
| 5278 // A fast back/forward won't call decidePolicyForNavigationResponse, so | 5274 // A fast back/forward won't call decidePolicyForNavigationResponse, so |
| 5279 // the MIME type needs to be updated explicitly. | 5275 // the MIME type needs to be updated explicitly. |
| 5280 NSString* storedMIMEType = | 5276 NSString* storedMIMEType = |
| 5281 [self currentBackForwardListItemHolder]->mime_type(); | 5277 [self currentBackForwardListItemHolder]->mime_type(); |
| 5282 if (storedMIMEType) { | 5278 if (storedMIMEType) { |
| 5283 self.webStateImpl->SetContentsMimeType( | 5279 self.webStateImpl->SetContentsMimeType( |
| 5284 base::SysNSStringToUTF8(storedMIMEType)); | 5280 base::SysNSStringToUTF8(storedMIMEType)); |
| 5285 } | 5281 } |
| 5286 } | 5282 } |
| 5283 |
| 5284 // This point should closely approximate the document object change, so reset |
| 5285 // the list of injected scripts to those that are automatically injected. |
| 5286 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); |
| 5287 if ([self contentIsHTML] || self.webState->GetContentsMimeType().empty()) { |
| 5288 // In unit tests MIME type will be empty, because loadHTML:forURL: does not |
| 5289 // notify web view delegate about received response, so web controller does |
| 5290 // not get a chance to properly update MIME type. |
| 5291 [self injectWindowID]; |
| 5292 } |
| 5293 |
| 5287 [self webPageChanged]; | 5294 [self webPageChanged]; |
| 5288 | 5295 |
| 5289 [self updateSSLStatusForCurrentNavigationItem]; | 5296 [self updateSSLStatusForCurrentNavigationItem]; |
| 5290 | 5297 |
| 5291 // Attempt to update the HTML5 history state. | 5298 // Attempt to update the HTML5 history state. |
| 5292 [self updateHTML5HistoryState]; | 5299 [self updateHTML5HistoryState]; |
| 5293 | 5300 |
| 5294 // Report cases where SSL cert is missing for a secure connection. | 5301 // Report cases where SSL cert is missing for a secure connection. |
| 5295 if (_documentURL.SchemeIsCryptographic()) { | 5302 if (_documentURL.SchemeIsCryptographic()) { |
| 5296 scoped_refptr<net::X509Certificate> cert = | 5303 scoped_refptr<net::X509Certificate> cert = |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5785 } | 5792 } |
| 5786 | 5793 |
| 5787 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5794 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5788 } | 5795 } |
| 5789 | 5796 |
| 5790 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5797 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5791 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5798 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5792 } | 5799 } |
| 5793 | 5800 |
| 5794 @end | 5801 @end |
| OLD | NEW |