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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 815 |
816 void WebViewGuest::DidFailProvisionalLoad( | 816 void WebViewGuest::DidFailProvisionalLoad( |
817 int64 frame_id, | 817 int64 frame_id, |
818 const base::string16& frame_unique_name, | 818 const base::string16& frame_unique_name, |
819 bool is_main_frame, | 819 bool is_main_frame, |
820 const GURL& validated_url, | 820 const GURL& validated_url, |
821 int error_code, | 821 int error_code, |
822 const base::string16& error_description, | 822 const base::string16& error_description, |
823 content::RenderViewHost* render_view_host) { | 823 content::RenderViewHost* render_view_host) { |
824 // Translate the |error_code| into an error string. | 824 // Translate the |error_code| into an error string. |
825 std::string error_type; | 825 std::string error_type(net::ErrorToString(error_code)); |
826 base::RemoveChars(net::ErrorToString(error_code), "net::", &error_type); | 826 DCHECK(StartsWithASCII(error_type, "net::", true)); |
| 827 error_type.erase(0, 5); |
827 LoadAbort(is_main_frame, validated_url, error_type); | 828 LoadAbort(is_main_frame, validated_url, error_type); |
828 } | 829 } |
829 | 830 |
830 void WebViewGuest::DidStartProvisionalLoadForFrame( | 831 void WebViewGuest::DidStartProvisionalLoadForFrame( |
831 int64 frame_id, | 832 int64 frame_id, |
832 int64 parent_frame_id, | 833 int64 parent_frame_id, |
833 bool is_main_frame, | 834 bool is_main_frame, |
834 const GURL& validated_url, | 835 const GURL& validated_url, |
835 bool is_error_page, | 836 bool is_error_page, |
836 bool is_iframe_srcdoc, | 837 bool is_iframe_srcdoc, |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 | 1067 |
1067 // Do not allow navigating a guest to schemes other than known safe schemes. | 1068 // Do not allow navigating a guest to schemes other than known safe schemes. |
1068 // This will block the embedder trying to load unwanted schemes, e.g. | 1069 // This will block the embedder trying to load unwanted schemes, e.g. |
1069 // chrome://settings. | 1070 // chrome://settings. |
1070 bool scheme_is_blocked = | 1071 bool scheme_is_blocked = |
1071 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 1072 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
1072 url.scheme()) && | 1073 url.scheme()) && |
1073 !url.SchemeIs(content::kAboutScheme)) || | 1074 !url.SchemeIs(content::kAboutScheme)) || |
1074 url.SchemeIs(url::kJavaScriptScheme); | 1075 url.SchemeIs(url::kJavaScriptScheme); |
1075 if (scheme_is_blocked || !url.is_valid()) { | 1076 if (scheme_is_blocked || !url.is_valid()) { |
1076 std::string error_type; | 1077 std::string error_type(net::ErrorToString(net::ERR_ABORTED)); |
1077 base::RemoveChars(net::ErrorToString(net::ERR_ABORTED), "net::", | 1078 DCHECK(StartsWithASCII(error_type, "net::", true)); |
1078 &error_type); | 1079 error_type.erase(0, 5); |
1079 LoadAbort(true /* is_top_level */, url, error_type); | 1080 LoadAbort(true /* is_top_level */, url, error_type); |
1080 return; | 1081 return; |
1081 } | 1082 } |
1082 | 1083 |
1083 GURL validated_url(url); | 1084 GURL validated_url(url); |
1084 guest_web_contents()->GetRenderProcessHost()-> | 1085 guest_web_contents()->GetRenderProcessHost()-> |
1085 FilterURL(false, &validated_url); | 1086 FilterURL(false, &validated_url); |
1086 // As guests do not swap processes on navigation, only navigations to | 1087 // As guests do not swap processes on navigation, only navigations to |
1087 // normal web URLs are supported. No protocol handlers are installed for | 1088 // normal web URLs are supported. No protocol handlers are installed for |
1088 // other schemes (e.g., WebUI or extensions), and no permissions or bindings | 1089 // other schemes (e.g., WebUI or extensions), and no permissions or bindings |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 bool allow, | 1410 bool allow, |
1410 const std::string& user_input) { | 1411 const std::string& user_input) { |
1411 WebViewGuest* guest = | 1412 WebViewGuest* guest = |
1412 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1413 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1413 if (!guest) | 1414 if (!guest) |
1414 return; | 1415 return; |
1415 | 1416 |
1416 if (!allow) | 1417 if (!allow) |
1417 guest->Destroy(); | 1418 guest->Destroy(); |
1418 } | 1419 } |
OLD | NEW |