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" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // CertVerification errors which happened inside | 205 // CertVerification errors which happened inside |
206 // |webView:didReceiveAuthenticationChallenge:completionHandler:|. | 206 // |webView:didReceiveAuthenticationChallenge:completionHandler:|. |
207 // Key is leaf-cert/host pair. This storage is used to carry calculated | 207 // Key is leaf-cert/host pair. This storage is used to carry calculated |
208 // cert status from |didReceiveAuthenticationChallenge:| to | 208 // cert status from |didReceiveAuthenticationChallenge:| to |
209 // |didFailProvisionalNavigation:| delegate method. | 209 // |didFailProvisionalNavigation:| delegate method. |
210 scoped_ptr<CertVerificationErrorsCacheType> _certVerificationErrors; | 210 scoped_ptr<CertVerificationErrorsCacheType> _certVerificationErrors; |
211 | 211 |
212 // YES if the user has interacted with the content area since the last URL | 212 // YES if the user has interacted with the content area since the last URL |
213 // change. | 213 // change. |
214 BOOL _interactionRegisteredSinceLastURLChange; | 214 BOOL _interactionRegisteredSinceLastURLChange; |
| 215 |
| 216 // YES if the web process backing _wkWebView is believed to currently be dead. |
| 217 BOOL _webProcessIsDead; |
215 } | 218 } |
216 | 219 |
217 // Dictionary where keys are the names of WKWebView properties and values are | 220 // Dictionary where keys are the names of WKWebView properties and values are |
218 // selector names which should be called when a corresponding property has | 221 // selector names which should be called when a corresponding property has |
219 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that | 222 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that |
220 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is | 223 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is |
221 // changed. | 224 // changed. |
222 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; | 225 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; |
223 | 226 |
224 // Activity indicator group ID for this web controller. | 227 // Activity indicator group ID for this web controller. |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 883 |
881 base::WeakNSObject<CRWWKWebViewWebController> weakSelf(self); | 884 base::WeakNSObject<CRWWKWebViewWebController> weakSelf(self); |
882 id crashHandler = ^{ | 885 id crashHandler = ^{ |
883 [weakSelf webViewWebProcessDidCrash]; | 886 [weakSelf webViewWebProcessDidCrash]; |
884 }; | 887 }; |
885 return [[CRWWKWebViewCrashDetector alloc] initWithWebView:webView | 888 return [[CRWWKWebViewCrashDetector alloc] initWithWebView:webView |
886 crashHandler:crashHandler]; | 889 crashHandler:crashHandler]; |
887 } | 890 } |
888 | 891 |
889 - (void)webViewWebProcessDidCrash { | 892 - (void)webViewWebProcessDidCrash { |
| 893 _webProcessIsDead = YES; |
890 if ([self.delegate respondsToSelector: | 894 if ([self.delegate respondsToSelector: |
891 @selector(webControllerWebProcessDidCrash:)]) { | 895 @selector(webControllerWebProcessDidCrash:)]) { |
892 [self.delegate webControllerWebProcessDidCrash:self]; | 896 [self.delegate webControllerWebProcessDidCrash:self]; |
893 } | 897 } |
894 } | 898 } |
895 | 899 |
896 - (void)queryPageReferrerPolicy:(void(^)(NSString*))responseHandler { | 900 - (void)queryPageReferrerPolicy:(void(^)(NSString*))responseHandler { |
897 DCHECK(responseHandler); | 901 DCHECK(responseHandler); |
898 [self evaluateJavaScript:@"__gCrWeb.getPageReferrerPolicy()" | 902 [self evaluateJavaScript:@"__gCrWeb.getPageReferrerPolicy()" |
899 stringResultHandler:^(NSString* referrer, NSError* error) { | 903 stringResultHandler:^(NSString* referrer, NSError* error) { |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 | 1475 |
1472 - (void)webViewLoadingStateDidChange { | 1476 - (void)webViewLoadingStateDidChange { |
1473 if ([_wkWebView isLoading]) { | 1477 if ([_wkWebView isLoading]) { |
1474 [self addActivityIndicatorTask]; | 1478 [self addActivityIndicatorTask]; |
1475 } else { | 1479 } else { |
1476 [self clearActivityIndicatorTasks]; | 1480 [self clearActivityIndicatorTasks]; |
1477 } | 1481 } |
1478 } | 1482 } |
1479 | 1483 |
1480 - (void)webViewTitleDidChange { | 1484 - (void)webViewTitleDidChange { |
| 1485 // WKWebView's title becomes empty when the web process dies; ignore that |
| 1486 // update. |
| 1487 if (_webProcessIsDead) { |
| 1488 DCHECK_EQ(self.title.length, 0U); |
| 1489 return; |
| 1490 } |
| 1491 |
1481 if ([self.delegate respondsToSelector: | 1492 if ([self.delegate respondsToSelector: |
1482 @selector(webController:titleDidChange:)]) { | 1493 @selector(webController:titleDidChange:)]) { |
1483 DCHECK(self.title); | 1494 DCHECK(self.title); |
1484 [self.delegate webController:self titleDidChange:self.title]; | 1495 [self.delegate webController:self titleDidChange:self.title]; |
1485 } | 1496 } |
1486 } | 1497 } |
1487 | 1498 |
1488 - (void)webViewURLDidChange { | 1499 - (void)webViewURLDidChange { |
1489 // TODO(stuartmorgan): Determine if there are any cases where this still | 1500 // TODO(stuartmorgan): Determine if there are any cases where this still |
1490 // happens, and if so whether anything should be done when it does. | 1501 // happens, and if so whether anything should be done when it does. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 } | 1554 } |
1544 } | 1555 } |
1545 | 1556 |
1546 #pragma mark - | 1557 #pragma mark - |
1547 #pragma mark WKNavigationDelegate Methods | 1558 #pragma mark WKNavigationDelegate Methods |
1548 | 1559 |
1549 - (void)webView:(WKWebView *)webView | 1560 - (void)webView:(WKWebView *)webView |
1550 decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction | 1561 decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction |
1551 decisionHandler: | 1562 decisionHandler: |
1552 (void (^)(WKNavigationActionPolicy))decisionHandler { | 1563 (void (^)(WKNavigationActionPolicy))decisionHandler { |
| 1564 _webProcessIsDead = NO; |
1553 if (self.isBeingDestroyed) { | 1565 if (self.isBeingDestroyed) { |
1554 decisionHandler(WKNavigationActionPolicyCancel); | 1566 decisionHandler(WKNavigationActionPolicyCancel); |
1555 return; | 1567 return; |
1556 } | 1568 } |
1557 | 1569 |
1558 NSURLRequest* request = navigationAction.request; | 1570 NSURLRequest* request = navigationAction.request; |
1559 GURL url = net::GURLWithNSURL(request.URL); | 1571 GURL url = net::GURLWithNSURL(request.URL); |
1560 | 1572 |
1561 // The page will not be changed until this navigation is commited, so the | 1573 // The page will not be changed until this navigation is commited, so the |
1562 // retrieved state will be pending until |didCommitNavigation| callback. | 1574 // retrieved state will be pending until |didCommitNavigation| callback. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 runJavaScriptTextInputPanelWithPrompt:prompt | 1863 runJavaScriptTextInputPanelWithPrompt:prompt |
1852 defaultText:defaultText | 1864 defaultText:defaultText |
1853 requestURL:requestURL | 1865 requestURL:requestURL |
1854 completionHandler:completionHandler]; | 1866 completionHandler:completionHandler]; |
1855 } else if (completionHandler) { | 1867 } else if (completionHandler) { |
1856 completionHandler(nil); | 1868 completionHandler(nil); |
1857 } | 1869 } |
1858 } | 1870 } |
1859 | 1871 |
1860 @end | 1872 @end |
OLD | NEW |