diff options
author | rzhao <rzhao@chromium.org> | 2015-08-17 09:29:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-17 16:30:02 +0000 |
commit | 10a8621789abed527c0850c4dcc10b3ff68aef2b (patch) | |
tree | 8cc117c46e612128d2a0c689a5c43e1834f1e1df /extensions/browser | |
parent | 0894b58caf8f5ad5dc32a9b9516147801885e171 (diff) | |
download | chromium_src-10a8621789abed527c0850c4dcc10b3ff68aef2b.zip chromium_src-10a8621789abed527c0850c4dcc10b3ff68aef2b.tar.gz chromium_src-10a8621789abed527c0850c4dcc10b3ff68aef2b.tar.bz2 |
<webview>: Add better loadabort reason messages
BUG=341097
Note: ERR_INVALID_URL and ERR_DISALLOWED_SCHEME are not defined in webview tag docs (https://developer.chrome.com/apps/tags/webview#event-loadabort)
Review URL: https://codereview.chromium.org/1292353003
Cr-Commit-Position: refs/heads/master@{#343696}
Diffstat (limited to 'extensions/browser')
-rw-r--r-- | extensions/browser/guest_view/web_view/web_view_guest.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc index eee9cc9..aea5054 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.cc +++ b/extensions/browser/guest_view/web_view/web_view_guest.cc @@ -1325,17 +1325,25 @@ void WebViewGuest::LoadURLWithParams( ui::PageTransition transition_type, const GlobalRequestID& transferred_global_request_id, bool force_navigation) { - // Do not allow navigating a guest to schemes other than known safe schemes. - // This will block the embedder trying to load unwanted schemes, e.g. - // chrome://. + if (!url.is_valid()) { + LoadAbort(true /* is_top_level */, url, net::ERR_INVALID_URL, + net::ErrorToShortString(net::ERR_INVALID_URL)); + NavigateGuest(url::kAboutBlankURL, false /* force_navigation */); + return; + } + bool scheme_is_blocked = (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( url.scheme()) && !url.SchemeIs(url::kAboutScheme)) || url.SchemeIs(url::kJavaScriptScheme); - if (scheme_is_blocked || !url.is_valid()) { - LoadAbort(true /* is_top_level */, url, net::ERR_ABORTED, - net::ErrorToShortString(net::ERR_ABORTED)); + + // Do not allow navigating a guest to schemes other than known safe schemes. + // This will block the embedder trying to load unwanted schemes, e.g. + // chrome://. + if (scheme_is_blocked) { + LoadAbort(true /* is_top_level */, url, net::ERR_DISALLOWED_URL_SCHEME, + net::ErrorToShortString(net::ERR_DISALLOWED_URL_SCHEME)); NavigateGuest(url::kAboutBlankURL, false /* force_navigation */); return; } |