OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_wk_web_view_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #include "base/containers/mru_cache.h" | 9 #include "base/containers/mru_cache.h" |
10 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
11 #include "base/ios/weak_nsobject.h" | 11 #include "base/ios/weak_nsobject.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/mac/objc_property_releaser.h" | 13 #import "base/mac/objc_property_releaser.h" |
14 #import "base/mac/scoped_nsobject.h" | 14 #import "base/mac/scoped_nsobject.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #import "ios/net/http_response_headers_util.h" | 19 #import "ios/net/http_response_headers_util.h" |
20 #import "ios/web/crw_network_activity_indicator_manager.h" | 20 #import "ios/web/crw_network_activity_indicator_manager.h" |
21 #import "ios/web/navigation/crw_session_controller.h" | 21 #import "ios/web/navigation/crw_session_controller.h" |
22 #import "ios/web/navigation/crw_session_entry.h" | 22 #import "ios/web/navigation/crw_session_entry.h" |
23 #include "ios/web/navigation/navigation_item_impl.h" | 23 #include "ios/web/navigation/navigation_item_impl.h" |
24 #include "ios/web/navigation/web_load_params.h" | 24 #include "ios/web/navigation/web_load_params.h" |
25 #include "ios/web/net/cert_host_pair.h" | 25 #include "ios/web/net/cert_host_pair.h" |
26 #import "ios/web/net/crw_cert_verification_controller.h" | 26 #import "ios/web/net/crw_cert_verification_controller.h" |
27 #include "ios/web/public/browser_state.h" | 27 #include "ios/web/public/browser_state.h" |
28 #include "ios/web/public/cert_store.h" | 28 #include "ios/web/public/cert_store.h" |
29 #include "ios/web/public/navigation_item.h" | 29 #include "ios/web/public/navigation_item.h" |
30 #include "ios/web/public/ssl_status.h" | 30 #include "ios/web/public/ssl_status.h" |
31 #include "ios/web/public/url_util.h" | 31 #include "ios/web/public/url_util.h" |
32 #include "ios/web/public/web_client.h" | 32 #include "ios/web/public/web_client.h" |
33 #import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h" | 33 #import "ios/web/public/web_state/crw_web_view_scroll_view_proxy.h" |
34 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" | 34 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" |
35 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" | 35 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" |
36 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" | 36 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" |
37 #import "ios/web/ui_web_view_util.h" | 37 #import "ios/web/ui_web_view_util.h" |
38 #include "ios/web/web_state/blocked_popup_info.h" | 38 #include "ios/web/web_state/blocked_popup_info.h" |
39 #import "ios/web/web_state/crw_pass_kit_downloader.h" | 39 #import "ios/web/web_state/crw_pass_kit_downloader.h" |
40 #import "ios/web/web_state/error_translation_util.h" | 40 #import "ios/web/web_state/error_translation_util.h" |
41 #include "ios/web/web_state/frame_info.h" | 41 #include "ios/web/web_state/frame_info.h" |
42 #import "ios/web/web_state/js/crw_js_post_request_loader.h" | |
42 #import "ios/web/web_state/js/crw_js_window_id_manager.h" | 43 #import "ios/web/web_state/js/crw_js_window_id_manager.h" |
43 #import "ios/web/web_state/ui/crw_web_controller+protected.h" | 44 #import "ios/web/web_state/ui/crw_web_controller+protected.h" |
44 #import "ios/web/web_state/ui/crw_wk_script_message_router.h" | 45 #import "ios/web/web_state/ui/crw_wk_script_message_router.h" |
45 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h" | 46 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h" |
46 #import "ios/web/web_state/ui/web_view_js_utils.h" | 47 #import "ios/web/web_state/ui/web_view_js_utils.h" |
47 #import "ios/web/web_state/ui/wk_back_forward_list_item_holder.h" | 48 #import "ios/web/web_state/ui/wk_back_forward_list_item_holder.h" |
48 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" | 49 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" |
49 #import "ios/web/web_state/web_state_impl.h" | 50 #import "ios/web/web_state/web_state_impl.h" |
50 #import "ios/web/web_state/web_view_internal_creation_util.h" | 51 #import "ios/web/web_state/web_view_internal_creation_util.h" |
51 #import "ios/web/web_state/wk_web_view_security_util.h" | 52 #import "ios/web/web_state/wk_web_view_security_util.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 // |didFailProvisionalNavigation|. | 181 // |didFailProvisionalNavigation|. |
181 base::scoped_nsobject<CRWWebControllerPendingNavigationInfo> | 182 base::scoped_nsobject<CRWWebControllerPendingNavigationInfo> |
182 _pendingNavigationInfo; | 183 _pendingNavigationInfo; |
183 | 184 |
184 // Referrer for the current page. | 185 // Referrer for the current page. |
185 base::scoped_nsobject<NSString> _currentReferrerString; | 186 base::scoped_nsobject<NSString> _currentReferrerString; |
186 | 187 |
187 // Handles downloading PassKit data for WKWebView. Lazy initialized. | 188 // Handles downloading PassKit data for WKWebView. Lazy initialized. |
188 base::scoped_nsobject<CRWPassKitDownloader> _passKitDownloader; | 189 base::scoped_nsobject<CRWPassKitDownloader> _passKitDownloader; |
189 | 190 |
191 // Object for loading POST requests with body. | |
192 base::scoped_nsobject<CRWJSPOSTRequestLoader> _POSTRequestLoader; | |
193 | |
190 // Whether the web page is currently performing window.history.pushState or | 194 // Whether the web page is currently performing window.history.pushState or |
191 // window.history.replaceState | 195 // window.history.replaceState |
192 // Set to YES on window.history.willChangeState message. To NO on | 196 // Set to YES on window.history.willChangeState message. To NO on |
193 // window.history.didPushState or window.history.didReplaceState. | 197 // window.history.didPushState or window.history.didReplaceState. |
194 BOOL _changingHistoryState; | 198 BOOL _changingHistoryState; |
195 | 199 |
196 // CRWWebUIManager object for loading WebUI pages. | 200 // CRWWebUIManager object for loading WebUI pages. |
197 base::scoped_nsobject<CRWWebUIManager> _webUIManager; | 201 base::scoped_nsobject<CRWWebUIManager> _webUIManager; |
198 | 202 |
199 // Controller used for certs verification to help with blocking requests with | 203 // Controller used for certs verification to help with blocking requests with |
(...skipping 26 matching lines...) Expand all Loading... | |
226 | 230 |
227 // Activity indicator group ID for this web controller. | 231 // Activity indicator group ID for this web controller. |
228 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; | 232 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; |
229 | 233 |
230 // Identifier used for storing and retrieving certificates. | 234 // Identifier used for storing and retrieving certificates. |
231 @property(nonatomic, readonly) int certGroupID; | 235 @property(nonatomic, readonly) int certGroupID; |
232 | 236 |
233 // Downloader for PassKit files. Lazy initialized. | 237 // Downloader for PassKit files. Lazy initialized. |
234 @property(nonatomic, readonly) CRWPassKitDownloader* passKitDownloader; | 238 @property(nonatomic, readonly) CRWPassKitDownloader* passKitDownloader; |
235 | 239 |
240 // Loads POST request with body in |_wkWebView| by constructing an HTML page | |
241 // that executes the request through JavaScript and replaces document with the | |
242 // result. | |
243 // Note that this approach includes multiple body encodings and decodings, plus | |
244 // the data is passed to |_wkWebView| on main thread. | |
245 // This is necessary because WKWebView ignores POST request body. | |
246 // Workaround for https://bugs.webkit.org/show_bug.cgi?id=145410 | |
247 - (void)loadPOSTRequest:(NSMutableURLRequest*)request; | |
248 | |
236 // Returns the WKWebViewConfigurationProvider associated with the web | 249 // Returns the WKWebViewConfigurationProvider associated with the web |
237 // controller's BrowserState. | 250 // controller's BrowserState. |
238 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; | 251 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; |
239 | 252 |
240 // Creates a web view with given |config|. No-op if web view is already created. | 253 // Creates a web view with given |config|. No-op if web view is already created. |
241 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; | 254 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; |
242 | 255 |
243 // Returns a new autoreleased web view created with given configuration. | 256 // Returns a new autoreleased web view created with given configuration. |
244 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; | 257 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; |
245 | 258 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 [_injectedScriptManagers addObject:JSInjectionManagerClass]; | 563 [_injectedScriptManagers addObject:JSInjectionManagerClass]; |
551 } | 564 } |
552 | 565 |
553 - (void)willLoadCurrentURLInWebView { | 566 - (void)willLoadCurrentURLInWebView { |
554 // TODO(stuartmorgan): Get a WKWebView version of the request ID verification | 567 // TODO(stuartmorgan): Get a WKWebView version of the request ID verification |
555 // code working for debug builds. | 568 // code working for debug builds. |
556 } | 569 } |
557 | 570 |
558 - (void)loadRequestForCurrentNavigationItem { | 571 - (void)loadRequestForCurrentNavigationItem { |
559 DCHECK(self.webView && !self.nativeController); | 572 DCHECK(self.webView && !self.nativeController); |
573 DCHECK([self currentSessionEntry]); | |
574 | |
575 web::WKBackForwardListItemHolder* holder = | |
576 [self currentBackForwardListItemHolder]; | |
577 BOOL isFormResubmission = | |
578 (holder->navigation_type() == WKNavigationTypeFormResubmitted || | |
579 holder->navigation_type() == WKNavigationTypeFormSubmitted); | |
580 web::NavigationItemImpl* currentItem = | |
581 [self currentSessionEntry].navigationItemImpl; | |
582 NSData* POSTData = currentItem->GetPostData(); | |
583 NSMutableURLRequest* request = [self requestForCurrentNavigationItem]; | |
584 | |
585 // If the request has POST data and is not a form resubmission, configure and | |
586 // run the POST request. | |
587 if (POSTData.length && !isFormResubmission) { | |
588 [request setHTTPMethod:@"POST"]; | |
589 [request setHTTPBody:POSTData]; | |
590 [request setAllHTTPHeaderFields:[self currentHTTPHeaders]]; | |
591 [self registerLoadRequest:[self currentNavigationURL] | |
592 referrer:[self currentSessionEntryReferrer] | |
593 transition:[self currentTransition]]; | |
594 [self loadPOSTRequest:request]; | |
595 return; | |
596 } | |
560 | 597 |
561 ProceduralBlock defaultNavigationBlock = ^{ | 598 ProceduralBlock defaultNavigationBlock = ^{ |
562 [self registerLoadRequest:[self currentNavigationURL] | 599 [self registerLoadRequest:[self currentNavigationURL] |
563 referrer:[self currentSessionEntryReferrer] | 600 referrer:[self currentSessionEntryReferrer] |
564 transition:[self currentTransition]]; | 601 transition:[self currentTransition]]; |
565 [self loadRequest:[self requestForCurrentNavigationItem]]; | 602 [self loadRequest:request]; |
566 }; | 603 }; |
567 | 604 |
568 // If there is no corresponding WKBackForwardListItem, or the item is not in | 605 // If there is no corresponding WKBackForwardListItem, or the item is not in |
569 // the current WKWebView's back-forward list, navigating using WKWebView API | 606 // the current WKWebView's back-forward list, navigating using WKWebView API |
570 // is not possible. In this case, fall back to the default navigation | 607 // is not possible. In this case, fall back to the default navigation |
571 // mechanism. | 608 // mechanism. |
572 web::WKBackForwardListItemHolder* holder = | |
573 [self currentBackForwardListItemHolder]; | |
574 if (!holder->back_forward_list_item() || | 609 if (!holder->back_forward_list_item() || |
575 ![self isBackForwardListItemValid:holder->back_forward_list_item()]) { | 610 ![self isBackForwardListItemValid:holder->back_forward_list_item()]) { |
576 defaultNavigationBlock(); | 611 defaultNavigationBlock(); |
577 return; | 612 return; |
578 } | 613 } |
579 | 614 |
580 ProceduralBlock webViewNavigationBlock = ^{ | 615 ProceduralBlock webViewNavigationBlock = ^{ |
581 // If the current navigation URL is the same as the URL of the visible | 616 // If the current navigation URL is the same as the URL of the visible |
582 // page, that means the user requested a reload. |goToBackForwardListItem| | 617 // page, that means the user requested a reload. |goToBackForwardListItem| |
583 // will be a no-op when it is passed the current back forward list item, | 618 // will be a no-op when it is passed the current back forward list item, |
584 // so |reload| must be explicitly called. | 619 // so |reload| must be explicitly called. |
585 [self registerLoadRequest:[self currentNavigationURL] | 620 [self registerLoadRequest:[self currentNavigationURL] |
586 referrer:[self currentSessionEntryReferrer] | 621 referrer:[self currentSessionEntryReferrer] |
587 transition:[self currentTransition]]; | 622 transition:[self currentTransition]]; |
588 if ([self currentNavigationURL] == net::GURLWithNSURL([_wkWebView URL])) { | 623 if ([self currentNavigationURL] == net::GURLWithNSURL([_wkWebView URL])) { |
589 [_wkWebView reload]; | 624 [_wkWebView reload]; |
590 } else { | 625 } else { |
591 [_wkWebView goToBackForwardListItem:holder->back_forward_list_item()]; | 626 [_wkWebView goToBackForwardListItem:holder->back_forward_list_item()]; |
592 } | 627 } |
593 }; | 628 }; |
594 | 629 |
595 // If the request is not a form submission or resubmission, or the user | 630 // If the request is not a form submission or resubmission, or the user |
596 // doesn't need to confirm the load, then continue right away. | 631 // doesn't need to confirm the load, then continue right away. |
597 web::NavigationItemImpl* currentItem = | 632 if (!isFormResubmission || |
598 [self currentSessionEntry].navigationItemImpl; | |
599 if ((holder->navigation_type() != WKNavigationTypeFormResubmitted && | |
600 holder->navigation_type() != WKNavigationTypeFormSubmitted) || | |
601 currentItem->ShouldSkipResubmitDataConfirmation()) { | 633 currentItem->ShouldSkipResubmitDataConfirmation()) { |
602 webViewNavigationBlock(); | 634 webViewNavigationBlock(); |
603 return; | 635 return; |
604 } | 636 } |
605 | 637 |
606 // If the request is form submission or resubmission, then prompt the | 638 // If the request is form submission or resubmission, then prompt the |
607 // user before proceeding. | 639 // user before proceeding. |
640 DCHECK(isFormResubmission); | |
608 [self.delegate webController:self | 641 [self.delegate webController:self |
609 onFormResubmissionForRequest:nil | 642 onFormResubmissionForRequest:nil |
610 continueBlock:webViewNavigationBlock | 643 continueBlock:webViewNavigationBlock |
611 cancelBlock:defaultNavigationBlock]; | 644 cancelBlock:defaultNavigationBlock]; |
612 } | 645 } |
613 | 646 |
614 // Overrides the hashchange workaround in the super class that manually | 647 // Overrides the hashchange workaround in the super class that manually |
615 // triggers Javascript hashchange events. If navigating with native API, | 648 // triggers Javascript hashchange events. If navigating with native API, |
616 // i.e. using a back forward list item, hashchange events will be triggered | 649 // i.e. using a back forward list item, hashchange events will be triggered |
617 // automatically, so no URL tampering is required. | 650 // automatically, so no URL tampering is required. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 @"WKWebViewWebController.NetworkActivityIndicatorKey.%@", | 741 @"WKWebViewWebController.NetworkActivityIndicatorKey.%@", |
709 self.webStateImpl->GetRequestGroupID()]; | 742 self.webStateImpl->GetRequestGroupID()]; |
710 } | 743 } |
711 | 744 |
712 - (int)certGroupID { | 745 - (int)certGroupID { |
713 DCHECK(self.webStateImpl); | 746 DCHECK(self.webStateImpl); |
714 // Request tracker IDs are used as certificate groups. | 747 // Request tracker IDs are used as certificate groups. |
715 return self.webStateImpl->GetRequestTracker()->identifier(); | 748 return self.webStateImpl->GetRequestTracker()->identifier(); |
716 } | 749 } |
717 | 750 |
751 - (void)loadPOSTRequest:(NSMutableURLRequest*)request { | |
752 if (!_POSTRequestLoader) { | |
753 _POSTRequestLoader.reset([[CRWJSPOSTRequestLoader alloc] init]); | |
754 } | |
755 | |
756 CRWWKScriptMessageRouter* messageRouter = | |
757 [self webViewConfigurationProvider].GetScriptMessageRouter(); | |
758 | |
759 [_POSTRequestLoader loadPOSTRequest:request | |
760 inWebView:_wkWebView | |
761 messageRouter:messageRouter | |
762 completionBlock:^(NSError* loadError) { | |
763 if (loadError) | |
764 [self handleLoadError:loadError inMainFrame:YES]; | |
765 else | |
766 self.webStateImpl->SetContentsMimeType("text/html"); | |
767 }]; | |
768 } | |
769 | |
718 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { | 770 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { |
719 DCHECK(self.webStateImpl); | 771 DCHECK(self.webStateImpl); |
720 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 772 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
721 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); | 773 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); |
722 } | 774 } |
723 | 775 |
724 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { | 776 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { |
725 if (!_wkWebView) { | 777 if (!_wkWebView) { |
726 [self setWebView:[self createWebViewWithConfiguration:config]]; | 778 [self setWebView:[self createWebViewWithConfiguration:config]]; |
727 // Notify super class about created web view. -webViewDidChange is not | 779 // Notify super class about created web view. -webViewDidChange is not |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 | 895 |
844 - (void)updateCurrentBackForwardListItemHolder { | 896 - (void)updateCurrentBackForwardListItemHolder { |
845 // WebUI pages (which are loaded via loadHTMLString:baseURL:) have no entry | 897 // WebUI pages (which are loaded via loadHTMLString:baseURL:) have no entry |
846 // in the back/forward list, so the current item will still be the previous | 898 // in the back/forward list, so the current item will still be the previous |
847 // page, and should not be associated. | 899 // page, and should not be associated. |
848 if (_webUIManager) | 900 if (_webUIManager) |
849 return; | 901 return; |
850 | 902 |
851 web::WKBackForwardListItemHolder* holder = | 903 web::WKBackForwardListItemHolder* holder = |
852 [self currentBackForwardListItemHolder]; | 904 [self currentBackForwardListItemHolder]; |
853 | |
854 WKNavigationType navigationType = | 905 WKNavigationType navigationType = |
855 _pendingNavigationInfo ? [_pendingNavigationInfo navigationType] | 906 _pendingNavigationInfo ? [_pendingNavigationInfo navigationType] |
856 : WKNavigationTypeOther; | 907 : WKNavigationTypeOther; |
857 holder->set_back_forward_list_item([_wkWebView backForwardList].currentItem); | 908 holder->set_back_forward_list_item([_wkWebView backForwardList].currentItem); |
858 holder->set_navigation_type(navigationType); | 909 holder->set_navigation_type(navigationType); |
859 | |
860 // Only update the MIME type in the holder if there was MIME type information | |
861 // as part of this pending load. It will be nil when doing a fast | |
862 // back/forward navigation, for instance, because the callback that would | |
863 // populate it is not called in that flow. | |
864 if ([_pendingNavigationInfo MIMEType]) | |
865 holder->set_mime_type([_pendingNavigationInfo MIMEType]); | |
866 } | 910 } |
867 | 911 |
868 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { | 912 - (BOOL)isBackForwardListItemValid:(WKBackForwardListItem*)item { |
869 // The current back-forward list item MUST be in the WKWebView's back-forward | 913 // The current back-forward list item MUST be in the WKWebView's back-forward |
870 // list to be valid. | 914 // list to be valid. |
871 WKBackForwardList* list = [_wkWebView backForwardList]; | 915 WKBackForwardList* list = [_wkWebView backForwardList]; |
872 return list.currentItem == item || | 916 return list.currentItem == item || |
873 [list.forwardList indexOfObject:item] != NSNotFound || | 917 [list.forwardList indexOfObject:item] != NSNotFound || |
874 [list.backList indexOfObject:item] != NSNotFound; | 918 [list.backList indexOfObject:item] != NSNotFound; |
875 } | 919 } |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1535 } else if ([self isKVOChangePotentialSameDocumentNavigationToURL:url]) { | 1579 } else if ([self isKVOChangePotentialSameDocumentNavigationToURL:url]) { |
1536 [_wkWebView evaluateJavaScript:@"window.location.href" | 1580 [_wkWebView evaluateJavaScript:@"window.location.href" |
1537 completionHandler:^(id result, NSError* error) { | 1581 completionHandler:^(id result, NSError* error) { |
1538 // If the web view has gone away, or the location | 1582 // If the web view has gone away, or the location |
1539 // couldn't be retrieved, abort. | 1583 // couldn't be retrieved, abort. |
1540 if (!_wkWebView || | 1584 if (!_wkWebView || |
1541 ![result isKindOfClass:[NSString class]]) { | 1585 ![result isKindOfClass:[NSString class]]) { |
1542 return; | 1586 return; |
1543 } | 1587 } |
1544 GURL jsURL([result UTF8String]); | 1588 GURL jsURL([result UTF8String]); |
1545 // Make sure that the window location is as expected, | 1589 // Make sure that the URL is as expected, and re-check |
Eugene But (OOO till 7-30)
2015/12/03 16:51:43
Please revert
stkhapugin
2015/12/03 17:51:03
Done.
| |
1546 // and re-check the origin and web view URL to prevent | 1590 // the origin to prevent race conditions. |
1547 // race conditions. | |
1548 // TODO(crbug.com/563568): The third check may drop same | |
1549 // document URL changes if pending URL change occurs | |
1550 // immediately after. Revisit heuristics to prevent this. | |
1551 if (jsURL == url && | 1591 if (jsURL == url && |
1552 _documentURL.GetOrigin() == url.GetOrigin() && | 1592 _documentURL.GetOrigin() == url.GetOrigin()) { |
Eugene But (OOO till 7-30)
2015/12/03 16:51:42
ditto
stkhapugin
2015/12/03 17:51:03
Done.
| |
1553 net::GURLWithNSURL([_wkWebView URL]) == url) { | |
1554 [self URLDidChangeWithoutDocumentChange:url]; | 1593 [self URLDidChangeWithoutDocumentChange:url]; |
1555 } | 1594 } |
1556 }]; | 1595 }]; |
1557 } | 1596 } |
1558 } | 1597 } |
1559 | 1598 |
1560 #pragma mark - | 1599 #pragma mark - |
1561 #pragma mark WKNavigationDelegate Methods | 1600 #pragma mark WKNavigationDelegate Methods |
1562 | 1601 |
1563 - (void)webView:(WKWebView *)webView | 1602 - (void)webView:(WKWebView *)webView |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1707 // the list of injected scripts to those that are automatically injected. | 1746 // the list of injected scripts to those that are automatically injected. |
1708 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); | 1747 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); |
1709 [self injectWindowID]; | 1748 [self injectWindowID]; |
1710 | 1749 |
1711 // This is the point where the document's URL has actually changed, and | 1750 // This is the point where the document's URL has actually changed, and |
1712 // pending navigation information should be applied to state information. | 1751 // pending navigation information should be applied to state information. |
1713 [self setDocumentURL:net::GURLWithNSURL([_wkWebView URL])]; | 1752 [self setDocumentURL:net::GURLWithNSURL([_wkWebView URL])]; |
1714 DCHECK(_documentURL == self.lastRegisteredRequestURL); | 1753 DCHECK(_documentURL == self.lastRegisteredRequestURL); |
1715 self.webStateImpl->OnNavigationCommitted(_documentURL); | 1754 self.webStateImpl->OnNavigationCommitted(_documentURL); |
1716 [self commitPendingNavigationInfo]; | 1755 [self commitPendingNavigationInfo]; |
1717 if ([self currentBackForwardListItemHolder]->navigation_type() == | |
Eugene But (OOO till 7-30)
2015/12/03 16:51:42
ditto
stkhapugin
2015/12/03 17:51:03
Done.
| |
1718 WKNavigationTypeBackForward) { | |
1719 // A fast back/forward won't call decidePolicyForNavigationResponse, so | |
1720 // the MIME type needs to be updated explicitly. | |
1721 NSString* storedMIMEType = | |
1722 [self currentBackForwardListItemHolder]->mime_type(); | |
1723 if (storedMIMEType) { | |
1724 self.webStateImpl->SetContentsMimeType( | |
1725 base::SysNSStringToUTF8(storedMIMEType)); | |
1726 } | |
1727 } | |
1728 [self webPageChanged]; | 1756 [self webPageChanged]; |
1729 | 1757 |
1730 [self updateSSLStatusForCurrentNavigationItem]; | 1758 [self updateSSLStatusForCurrentNavigationItem]; |
1731 | 1759 |
1732 // Report cases where SSL cert is missing for a secure connection. | 1760 // Report cases where SSL cert is missing for a secure connection. |
1733 if (_documentURL.SchemeIsCryptographic()) { | 1761 if (_documentURL.SchemeIsCryptographic()) { |
1734 scoped_refptr<net::X509Certificate> cert = | 1762 scoped_refptr<net::X509Certificate> cert = |
1735 web::CreateCertFromChain([_wkWebView certificateChain]); | 1763 web::CreateCertFromChain([_wkWebView certificateChain]); |
1736 UMA_HISTOGRAM_BOOLEAN("WebController.WKWebViewHasCertForSecureConnection", | 1764 UMA_HISTOGRAM_BOOLEAN("WebController.WKWebViewHasCertForSecureConnection", |
1737 cert); | 1765 cert); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1877 runJavaScriptTextInputPanelWithPrompt:prompt | 1905 runJavaScriptTextInputPanelWithPrompt:prompt |
1878 defaultText:defaultText | 1906 defaultText:defaultText |
1879 requestURL:requestURL | 1907 requestURL:requestURL |
1880 completionHandler:completionHandler]; | 1908 completionHandler:completionHandler]; |
1881 } else if (completionHandler) { | 1909 } else if (completionHandler) { |
1882 completionHandler(nil); | 1910 completionHandler(nil); |
1883 } | 1911 } |
1884 } | 1912 } |
1885 | 1913 |
1886 @end | 1914 @end |
OLD | NEW |