Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 888563003: <webview>: Navigate to about:blank if attempting to navigate to bad URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 30 matching lines...) Expand all
41 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" 41 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h"
42 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 42 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
43 #include "extensions/common/constants.h" 43 #include "extensions/common/constants.h"
44 #include "extensions/common/extension_messages.h" 44 #include "extensions/common/extension_messages.h"
45 #include "extensions/common/guest_view/guest_view_constants.h" 45 #include "extensions/common/guest_view/guest_view_constants.h"
46 #include "extensions/strings/grit/extensions_strings.h" 46 #include "extensions/strings/grit/extensions_strings.h"
47 #include "ipc/ipc_message_macros.h" 47 #include "ipc/ipc_message_macros.h"
48 #include "net/base/escape.h" 48 #include "net/base/escape.h"
49 #include "net/base/net_errors.h" 49 #include "net/base/net_errors.h"
50 #include "ui/base/models/simple_menu_model.h" 50 #include "ui/base/models/simple_menu_model.h"
51 #include "url/url_constants.h"
51 52
52 using base::UserMetricsAction; 53 using base::UserMetricsAction;
53 using content::RenderFrameHost; 54 using content::RenderFrameHost;
54 using content::ResourceType; 55 using content::ResourceType;
55 using content::WebContents; 56 using content::WebContents;
56 57
57 namespace extensions { 58 namespace extensions {
58 59
59 namespace { 60 namespace {
60 61
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 // This will block the embedder trying to load unwanted schemes, e.g. 873 // This will block the embedder trying to load unwanted schemes, e.g.
873 // chrome://settings. 874 // chrome://settings.
874 bool scheme_is_blocked = 875 bool scheme_is_blocked =
875 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 876 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
876 url.scheme()) && 877 url.scheme()) &&
877 !url.SchemeIs(url::kAboutScheme)) || 878 !url.SchemeIs(url::kAboutScheme)) ||
878 url.SchemeIs(url::kJavaScriptScheme); 879 url.SchemeIs(url::kJavaScriptScheme);
879 if (scheme_is_blocked || !url.is_valid()) { 880 if (scheme_is_blocked || !url.is_valid()) {
880 LoadAbort(true /* is_top_level */, url, 881 LoadAbort(true /* is_top_level */, url,
881 net::ErrorToShortString(net::ERR_ABORTED)); 882 net::ErrorToShortString(net::ERR_ABORTED));
883 NavigateGuest(url::kAboutBlankURL, true /* force_navigation */);
882 return; 884 return;
883 } 885 }
884 if (!force_navigation && (src_ == url)) 886 if (!force_navigation && (src_ == url))
885 return; 887 return;
886 888
887 GURL validated_url(url); 889 GURL validated_url(url);
888 web_contents()->GetRenderProcessHost()->FilterURL(false, &validated_url); 890 web_contents()->GetRenderProcessHost()->FilterURL(false, &validated_url);
889 // As guests do not swap processes on navigation, only navigations to 891 // As guests do not swap processes on navigation, only navigations to
890 // normal web URLs are supported. No protocol handlers are installed for 892 // normal web URLs are supported. No protocol handlers are installed for
891 // other schemes (e.g., WebUI or extensions), and no permissions or bindings 893 // other schemes (e.g., WebUI or extensions), and no permissions or bindings
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), 1215 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(),
1214 new_window_instance_id); 1216 new_window_instance_id);
1215 if (!guest) 1217 if (!guest)
1216 return; 1218 return;
1217 1219
1218 if (!allow) 1220 if (!allow)
1219 guest->Destroy(); 1221 guest->Destroy();
1220 } 1222 }
1221 1223
1222 } // namespace extensions 1224 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/platform_apps/web_view/shim/main.js ('k') | extensions/test/data/web_view/apitest/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698