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

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

Issue 296593003: Make various string_util functions take StringPieces instead of char[]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 | Annotate | Revision Log
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 "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/debug/stack_trace.h" 7 #include "base/debug/stack_trace.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 800
801 void WebViewGuest::DidFailProvisionalLoad( 801 void WebViewGuest::DidFailProvisionalLoad(
802 int64 frame_id, 802 int64 frame_id,
803 const base::string16& frame_unique_name, 803 const base::string16& frame_unique_name,
804 bool is_main_frame, 804 bool is_main_frame,
805 const GURL& validated_url, 805 const GURL& validated_url,
806 int error_code, 806 int error_code,
807 const base::string16& error_description, 807 const base::string16& error_description,
808 content::RenderViewHost* render_view_host) { 808 content::RenderViewHost* render_view_host) {
809 // Translate the |error_code| into an error string. 809 // Translate the |error_code| into an error string.
810 std::string error_type; 810 std::string error_type(net::ErrorToString(error_code));
811 base::RemoveChars(net::ErrorToString(error_code), "net::", &error_type); 811 DCHECK(StartsWithASCII(error_type, "net::", true));
darin (slow to review) 2014/05/22 23:49:46 I don't know that it is guaranteed that the error
Peter Kasting 2014/05/22 23:54:50 net::ErrorToString() prefixes "net::" onto all ret
darin (slow to review) 2014/05/30 00:03:17 Oh, nevermind. I was mistakenly thinking the strin
812 error_type.erase(0, 5);
812 LoadAbort(is_main_frame, validated_url, error_type); 813 LoadAbort(is_main_frame, validated_url, error_type);
813 } 814 }
814 815
815 void WebViewGuest::DidStartProvisionalLoadForFrame( 816 void WebViewGuest::DidStartProvisionalLoadForFrame(
816 int64 frame_id, 817 int64 frame_id,
817 int64 parent_frame_id, 818 int64 parent_frame_id,
818 bool is_main_frame, 819 bool is_main_frame,
819 const GURL& validated_url, 820 const GURL& validated_url,
820 bool is_error_page, 821 bool is_error_page,
821 bool is_iframe_srcdoc, 822 bool is_iframe_srcdoc,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 1017
1017 // Do not allow navigating a guest to schemes other than known safe schemes. 1018 // Do not allow navigating a guest to schemes other than known safe schemes.
1018 // This will block the embedder trying to load unwanted schemes, e.g. 1019 // This will block the embedder trying to load unwanted schemes, e.g.
1019 // chrome://settings. 1020 // chrome://settings.
1020 bool scheme_is_blocked = 1021 bool scheme_is_blocked =
1021 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 1022 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
1022 url.scheme()) && 1023 url.scheme()) &&
1023 !url.SchemeIs(content::kAboutScheme)) || 1024 !url.SchemeIs(content::kAboutScheme)) ||
1024 url.SchemeIs(content::kJavaScriptScheme); 1025 url.SchemeIs(content::kJavaScriptScheme);
1025 if (scheme_is_blocked || !url.is_valid()) { 1026 if (scheme_is_blocked || !url.is_valid()) {
1026 std::string error_type; 1027 std::string error_type(net::ErrorToString(net::ERR_ABORTED));
1027 base::RemoveChars(net::ErrorToString(net::ERR_ABORTED), "net::", 1028 DCHECK(StartsWithASCII(error_type, "net::", true));
1028 &error_type); 1029 error_type.erase(0, 5);
1029 LoadAbort(true /* is_top_level */, url, error_type); 1030 LoadAbort(true /* is_top_level */, url, error_type);
1030 return; 1031 return;
1031 } 1032 }
1032 1033
1033 GURL validated_url(url); 1034 GURL validated_url(url);
1034 guest_web_contents()->GetRenderProcessHost()-> 1035 guest_web_contents()->GetRenderProcessHost()->
1035 FilterURL(false, &validated_url); 1036 FilterURL(false, &validated_url);
1036 // As guests do not swap processes on navigation, only navigations to 1037 // As guests do not swap processes on navigation, only navigations to
1037 // normal web URLs are supported. No protocol handlers are installed for 1038 // normal web URLs are supported. No protocol handlers are installed for
1038 // other schemes (e.g., WebUI or extensions), and no permissions or bindings 1039 // other schemes (e.g., WebUI or extensions), and no permissions or bindings
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 bool allow, 1351 bool allow,
1351 const std::string& user_input) { 1352 const std::string& user_input) {
1352 WebViewGuest* guest = 1353 WebViewGuest* guest =
1353 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1354 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1354 if (!guest) 1355 if (!guest)
1355 return; 1356 return;
1356 1357
1357 if (!allow) 1358 if (!allow)
1358 guest->Destroy(); 1359 guest->Destroy();
1359 } 1360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698