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 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 5 #include "chrome/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 "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 } | 1123 } |
1124 | 1124 |
1125 void WebViewGuest::NavigateGuest(const std::string& src) { | 1125 void WebViewGuest::NavigateGuest(const std::string& src) { |
1126 GURL url = ResolveURL(src); | 1126 GURL url = ResolveURL(src); |
1127 | 1127 |
1128 // Do not allow navigating a guest to schemes other than known safe schemes. | 1128 // Do not allow navigating a guest to schemes other than known safe schemes. |
1129 // This will block the embedder trying to load unwanted schemes, e.g. | 1129 // This will block the embedder trying to load unwanted schemes, e.g. |
1130 // chrome://settings. | 1130 // chrome://settings. |
1131 bool scheme_is_blocked = | 1131 bool scheme_is_blocked = |
1132 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 1132 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
1133 url.scheme()) && | 1133 url.scheme()) && |
1134 !url.SchemeIs(content::kAboutScheme)) || | 1134 !url.SchemeIs(url::kAboutScheme)) || |
1135 url.SchemeIs(url::kJavaScriptScheme); | 1135 url.SchemeIs(url::kJavaScriptScheme); |
1136 if (scheme_is_blocked || !url.is_valid()) { | 1136 if (scheme_is_blocked || !url.is_valid()) { |
1137 std::string error_type(net::ErrorToString(net::ERR_ABORTED)); | 1137 std::string error_type(net::ErrorToString(net::ERR_ABORTED)); |
1138 DCHECK(StartsWithASCII(error_type, "net::", true)); | 1138 DCHECK(StartsWithASCII(error_type, "net::", true)); |
1139 error_type.erase(0, 5); | 1139 error_type.erase(0, 5); |
1140 LoadAbort(true /* is_top_level */, url, error_type); | 1140 LoadAbort(true /* is_top_level */, url, error_type); |
1141 return; | 1141 return; |
1142 } | 1142 } |
1143 | 1143 |
1144 GURL validated_url(url); | 1144 GURL validated_url(url); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 bool allow, | 1484 bool allow, |
1485 const std::string& user_input) { | 1485 const std::string& user_input) { |
1486 WebViewGuest* guest = | 1486 WebViewGuest* guest = |
1487 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1487 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1488 if (!guest) | 1488 if (!guest) |
1489 return; | 1489 return; |
1490 | 1490 |
1491 if (!allow) | 1491 if (!allow) |
1492 guest->Destroy(); | 1492 guest->Destroy(); |
1493 } | 1493 } |
OLD | NEW |