summaryrefslogtreecommitdiffstats
path: root/ios/web
diff options
context:
space:
mode:
authorjyquinn <jyquinn@chromium.org>2015-06-08 16:55:40 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-08 23:56:18 +0000
commit51988e8602ea739e6287de793961174a90ab2b38 (patch)
tree03b3b929e38a98335a31a37088e846f0c0b61ab8 /ios/web
parenta7282fae4b5c51e2ac7678fa8eb7bb3a0d038aba (diff)
downloadchromium_src-51988e8602ea739e6287de793961174a90ab2b38.zip
chromium_src-51988e8602ea739e6287de793961174a90ab2b38.tar.gz
chromium_src-51988e8602ea739e6287de793961174a90ab2b38.tar.bz2
Ignore NSURLErrorCancelled errors for app specific URLs
Errors originating in WKWebView are translated into net errors for better handling. The translation causes improper handling of errors generated by WebUI loads, so ignore those errors for app specific URLs. BUG=492757 Review URL: https://codereview.chromium.org/1165003007 Cr-Commit-Position: refs/heads/master@{#333392}
Diffstat (limited to 'ios/web')
-rw-r--r--ios/web/web_state/ui/crw_ui_web_view_web_controller.mm4
-rw-r--r--ios/web/web_state/ui/crw_web_controller+protected.h4
-rw-r--r--ios/web/web_state/ui/crw_web_controller.mm11
-rw-r--r--ios/web/web_state/ui/crw_wk_web_view_web_controller.mm20
4 files changed, 32 insertions, 7 deletions
diff --git a/ios/web/web_state/ui/crw_ui_web_view_web_controller.mm b/ios/web/web_state/ui/crw_ui_web_view_web_controller.mm
index 1aff4fb..424b549 100644
--- a/ios/web/web_state/ui/crw_ui_web_view_web_controller.mm
+++ b/ios/web/web_state/ui/crw_ui_web_view_web_controller.mm
@@ -815,6 +815,10 @@ const size_t kMaxMessageQueueSize = 262144;
self.webScrollView.zoomScale = zoomScale;
}
+-(BOOL)shouldAbortLoadForCancelledURL:(const GURL&)cancelledURL {
+ return YES;
+}
+
#pragma mark - JS to ObjC messaging
- (void)respondToJSInvoke {
diff --git a/ios/web/web_state/ui/crw_web_controller+protected.h b/ios/web/web_state/ui/crw_web_controller+protected.h
index 5087983..688e71f 100644
--- a/ios/web/web_state/ui/crw_web_controller+protected.h
+++ b/ios/web/web_state/ui/crw_web_controller+protected.h
@@ -167,6 +167,10 @@ struct NewWindowInfo {
- (void)applyWebViewScrollZoomScaleFromScrollState:
(const web::PageScrollState&)scrollState;
+// Returns YES if load should be aborted when NSURLCancelledError is
+// encountered for |cancelledURL|.
+- (BOOL)shouldAbortLoadForCancelledURL:(const GURL&)cancelledURL;
+
#pragma mark - Optional methods for subclasses
// Subclasses may overwrite methods in this section.
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 7d6f5b6..cc0e66a5 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -2884,10 +2884,13 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
return;
}
+ // TODO(ios): Audit comments and behavior below regarding error origin. The
+ // error has been translated and may appear to have originated in the Chrome
+ // network stack when that is not true (crbug.com/496972)
// Ignore cancelled errors.
if ([error code] == NSURLErrorCancelled) {
NSError* underlyingError = [userInfo objectForKey:NSUnderlyingErrorKey];
- if (underlyingError) {
+ if (underlyingError && [self shouldAbortLoadForCancelledURL:errorGURL]) {
DCHECK([underlyingError isKindOfClass:[NSError class]]);
// The Error contains an NSUnderlyingErrorKey so it's being generated
@@ -2919,6 +2922,12 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
[self loadErrorInNativeView:error];
}
+- (BOOL)shouldAbortLoadForCancelledURL:(const GURL &)cancelledURL {
+ // Subclasses must implement this method.
+ NOTREACHED();
+ return YES;
+}
+
#pragma mark -
#pragma mark WebUI
diff --git a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
index 3ee70f3..d772698 100644
--- a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
+++ b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
@@ -421,6 +421,12 @@ NSString* const kScriptImmediateName = @"crwebinvokeimmediate";
self.webScrollView.zoomScale = zoomScale;
}
+- (BOOL)shouldAbortLoadForCancelledURL:(const GURL&)cancelledURL {
+ // Do not abort the load if it is for an app specific URL, as such errors
+ // are produced during the app specific URL load process.
+ return !web::GetWebClient()->IsAppSpecificURL(cancelledURL);
+}
+
#pragma mark Private methods
- (NSString*)documentMIMEType {
@@ -975,17 +981,19 @@ NSString* const kScriptImmediateName = @"crwebinvokeimmediate";
- (void)webView:(WKWebView *)webView
didStartProvisionalNavigation:(WKNavigation *)navigation {
GURL webViewURL = net::GURLWithNSURL(webView.URL);
- // If this navigation has not yet been registered, do so. loadPhase check is
- // necessary because lastRegisteredRequestURL may be the same as the
- // webViewURL on a new tab created by window.open (default is about::blank).
- // TODO(jyquinn): Audit [CRWWebController loadCurrentURL] for other tasks that
+ // Intercept renderer-initiated navigations. If this navigation has not yet
+ // been registered, do so. loadPhase check is necessary because
+ // lastRegisteredRequestURL may be the same as the webViewURL on a new tab
+ // created by window.open (default is about::blank).
+ // TODO(jyquinn): Audit [CRWWebController loadWithParams] for other tasks that
// should be performed here.
if (self.lastRegisteredRequestURL != webViewURL ||
self.loadPhase != web::LOAD_REQUESTED) {
// Reset current WebUI if one exists.
[self clearWebUI];
- // If webViewURL is a chrome URL, abort the current load and initialize the
- // load from the web controller.
+ // Restart app specific URL loads to properly capture state.
+ // TODO(jyquinn): Extract necessary tasks for app specific URL navigation
+ // rather than restarting the load.
if (web::GetWebClient()->IsAppSpecificURL(webViewURL)) {
[self abortWebLoad];
web::WebLoadParams params(webViewURL);