| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 | 732 |
| 733 if (!render_frame_host->GetParent()) | 733 if (!render_frame_host->GetParent()) |
| 734 chromevox_injected_ = false; | 734 chromevox_injected_ = false; |
| 735 } | 735 } |
| 736 | 736 |
| 737 void WebViewGuest::DidFailProvisionalLoad( | 737 void WebViewGuest::DidFailProvisionalLoad( |
| 738 content::RenderFrameHost* render_frame_host, | 738 content::RenderFrameHost* render_frame_host, |
| 739 const GURL& validated_url, | 739 const GURL& validated_url, |
| 740 int error_code, | 740 int error_code, |
| 741 const base::string16& error_description) { | 741 const base::string16& error_description) { |
| 742 // Translate the |error_code| into an error string. | 742 LoadAbort(!render_frame_host->GetParent(), validated_url, |
| 743 std::string error_type(net::ErrorToString(error_code)); | 743 net::ErrorToShortString(error_code)); |
| 744 DCHECK(StartsWithASCII(error_type, "net::", true)); | |
| 745 error_type.erase(0, 5); | |
| 746 LoadAbort(!render_frame_host->GetParent(), validated_url, error_type); | |
| 747 } | 744 } |
| 748 | 745 |
| 749 void WebViewGuest::DidStartProvisionalLoadForFrame( | 746 void WebViewGuest::DidStartProvisionalLoadForFrame( |
| 750 content::RenderFrameHost* render_frame_host, | 747 content::RenderFrameHost* render_frame_host, |
| 751 const GURL& validated_url, | 748 const GURL& validated_url, |
| 752 bool is_error_page, | 749 bool is_error_page, |
| 753 bool is_iframe_srcdoc) { | 750 bool is_iframe_srcdoc) { |
| 754 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 751 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 755 args->SetString(guestview::kUrl, validated_url.spec()); | 752 args->SetString(guestview::kUrl, validated_url.spec()); |
| 756 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); | 753 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 | 953 |
| 957 // Do not allow navigating a guest to schemes other than known safe schemes. | 954 // Do not allow navigating a guest to schemes other than known safe schemes. |
| 958 // This will block the embedder trying to load unwanted schemes, e.g. | 955 // This will block the embedder trying to load unwanted schemes, e.g. |
| 959 // chrome://settings. | 956 // chrome://settings. |
| 960 bool scheme_is_blocked = | 957 bool scheme_is_blocked = |
| 961 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 958 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
| 962 url.scheme()) && | 959 url.scheme()) && |
| 963 !url.SchemeIs(url::kAboutScheme)) || | 960 !url.SchemeIs(url::kAboutScheme)) || |
| 964 url.SchemeIs(url::kJavaScriptScheme); | 961 url.SchemeIs(url::kJavaScriptScheme); |
| 965 if (scheme_is_blocked || !url.is_valid()) { | 962 if (scheme_is_blocked || !url.is_valid()) { |
| 966 std::string error_type(net::ErrorToString(net::ERR_ABORTED)); | 963 LoadAbort(true /* is_top_level */, url, |
| 967 DCHECK(StartsWithASCII(error_type, "net::", true)); | 964 net::ErrorToShortString(net::ERR_ABORTED)); |
| 968 error_type.erase(0, 5); | |
| 969 LoadAbort(true /* is_top_level */, url, error_type); | |
| 970 return; | 965 return; |
| 971 } | 966 } |
| 972 | 967 |
| 973 GURL validated_url(url); | 968 GURL validated_url(url); |
| 974 guest_web_contents()->GetRenderProcessHost()-> | 969 guest_web_contents()->GetRenderProcessHost()-> |
| 975 FilterURL(false, &validated_url); | 970 FilterURL(false, &validated_url); |
| 976 // As guests do not swap processes on navigation, only navigations to | 971 // As guests do not swap processes on navigation, only navigations to |
| 977 // normal web URLs are supported. No protocol handlers are installed for | 972 // normal web URLs are supported. No protocol handlers are installed for |
| 978 // other schemes (e.g., WebUI or extensions), and no permissions or bindings | 973 // other schemes (e.g., WebUI or extensions), and no permissions or bindings |
| 979 // can be granted to the guest process. | 974 // can be granted to the guest process. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 bool allow, | 1234 bool allow, |
| 1240 const std::string& user_input) { | 1235 const std::string& user_input) { |
| 1241 WebViewGuest* guest = | 1236 WebViewGuest* guest = |
| 1242 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1237 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
| 1243 if (!guest) | 1238 if (!guest) |
| 1244 return; | 1239 return; |
| 1245 | 1240 |
| 1246 if (!allow) | 1241 if (!allow) |
| 1247 guest->Destroy(); | 1242 guest->Destroy(); |
| 1248 } | 1243 } |
| OLD | NEW |