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

Unified Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 2411293002: Fix cross-renderer resource loads for <webview> with PlzNavigate. (Closed)
Patch Set: review comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_guest.h ('k') | extensions/browser/url_request_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/guest_view/web_view/web_view_guest.cc
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc
index 692e490b24e85894f9fd9ce0c30f49204b5521e6..645d9afdc139e9effa2a255a711af8bf86520c26 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_guest.cc
@@ -23,6 +23,7 @@
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -600,13 +601,12 @@ void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) {
void WebViewGuest::LoadAbort(bool is_top_level,
const GURL& url,
- int error_code,
- const std::string& error_type) {
+ int error_code) {
std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetBoolean(guest_view::kIsTopLevel, is_top_level);
args->SetString(guest_view::kUrl, url.possibly_invalid_spec());
args->SetInteger(guest_view::kCode, error_code);
- args->SetString(guest_view::kReason, error_type);
+ args->SetString(guest_view::kReason, net::ErrorToShortString(error_code));
DispatchEventToView(base::MakeUnique<GuestViewEvent>(webview::kEventLoadAbort,
std::move(args)));
}
@@ -806,11 +806,26 @@ WebViewGuest::WebViewGuest(WebContents* owner_web_contents)
WebViewGuest::~WebViewGuest() {
}
-void WebViewGuest::DidCommitProvisionalLoadForFrame(
- content::RenderFrameHost* render_frame_host,
- const GURL& url,
- ui::PageTransition transition_type) {
- if (!render_frame_host->GetParent()) {
+void WebViewGuest::DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (navigation_handle->IsErrorPage() || !navigation_handle->HasCommitted()) {
+ // Suppress loadabort for "mailto" URLs.
+ // Also during destruction, owner_web_contents() is null so there's no point
+ // trying to send the event.
+ if (!navigation_handle->GetURL().SchemeIs(url::kMailToScheme) &&
+ owner_web_contents()) {
+ // If it's not an error page, the request was blocked by the webrequest
+ // API.
+ int error_code = navigation_handle->IsErrorPage()
+ ? navigation_handle->GetNetErrorCode()
+ : net::ERR_BLOCKED_BY_CLIENT;
+ LoadAbort(navigation_handle->IsInMainFrame(), navigation_handle->GetURL(),
+ error_code);
+ }
+ return;
+ }
+
+ if (navigation_handle->IsInMainFrame()) {
// For LoadDataWithBaseURL loads, |url| contains the data URL, but the
// virtual URL is needed in that case. So use WebContents::GetURL instead.
src_ = web_contents()->GetURL();
@@ -822,7 +837,7 @@ void WebViewGuest::DidCommitProvisionalLoadForFrame(
}
std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(guest_view::kUrl, src_.spec());
- args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent());
+ args->SetBoolean(guest_view::kIsTopLevel, navigation_handle->IsInMainFrame());
args->SetString(webview::kInternalBaseURLForDataURL,
web_contents()
->GetController()
@@ -841,28 +856,11 @@ void WebViewGuest::DidCommitProvisionalLoadForFrame(
find_helper_.CancelAllFindSessions();
}
-void WebViewGuest::DidFailProvisionalLoad(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- int error_code,
- const base::string16& error_description,
- bool was_ignored_by_handler) {
- // Suppress loadabort for "mailto" URLs.
- if (validated_url.SchemeIs(url::kMailToScheme))
- return;
-
- LoadAbort(!render_frame_host->GetParent(), validated_url, error_code,
- net::ErrorToShortString(error_code));
-}
-
-void WebViewGuest::DidStartProvisionalLoadForFrame(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- bool is_error_page,
- bool is_iframe_srcdoc) {
+void WebViewGuest::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
- args->SetString(guest_view::kUrl, validated_url.spec());
- args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent());
+ args->SetString(guest_view::kUrl, navigation_handle->GetURL().spec());
+ args->SetBoolean(guest_view::kIsTopLevel, navigation_handle->IsInMainFrame());
DispatchEventToView(base::MakeUnique<GuestViewEvent>(webview::kEventLoadStart,
std::move(args)));
}
@@ -1381,8 +1379,7 @@ void WebViewGuest::LoadURLWithParams(
ui::PageTransition transition_type,
bool force_navigation) {
if (!url.is_valid()) {
- LoadAbort(true /* is_top_level */, url, net::ERR_INVALID_URL,
- net::ErrorToShortString(net::ERR_INVALID_URL));
+ LoadAbort(true /* is_top_level */, url, net::ERR_INVALID_URL);
NavigateGuest(url::kAboutBlankURL, false /* force_navigation */);
return;
}
@@ -1397,8 +1394,7 @@ void WebViewGuest::LoadURLWithParams(
// This will block the embedder trying to load unwanted schemes, e.g.
// chrome://.
if (scheme_is_blocked) {
- LoadAbort(true /* is_top_level */, url, net::ERR_DISALLOWED_URL_SCHEME,
- net::ErrorToShortString(net::ERR_DISALLOWED_URL_SCHEME));
+ LoadAbort(true /* is_top_level */, url, net::ERR_DISALLOWED_URL_SCHEME);
NavigateGuest(url::kAboutBlankURL, false /* force_navigation */);
return;
}
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_guest.h ('k') | extensions/browser/url_request_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698