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

Unified Diff: content/browser/frame_host/navigator_impl.cc

Issue 118553006: Move DidFailProvisionalLoad handling from RenderView(Host) to RenderFrame(Host). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Huh? Created 6 years, 12 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
Index: content/browser/frame_host/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 362f64cb03683179b02b3f5736da25e606c63d21..0a65ff1fe46beb4ec10ea3d6a753828d315e64dd 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -5,6 +5,7 @@
#include "content/browser/frame_host/navigator_impl.h"
#include "base/command_line.h"
+#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
@@ -12,6 +13,7 @@
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/site_instance_impl.h"
+#include "content/common/frame_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_controller.h"
@@ -91,4 +93,63 @@ void NavigatorImpl::DidStartProvisionalLoad(
}
}
+
+void NavigatorImpl::DidFailProvisionalLoadWithError(
+ RenderFrameHostImpl* render_frame_host,
+ const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
+ VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec()
+ << ", error_code: " << params.error_code
+ << ", error_description: " << params.error_description
+ << ", is_main_frame: " << params.is_main_frame
+ << ", showing_repost_interstitial: " <<
+ params.showing_repost_interstitial
+ << ", frame_id: " << params.frame_id;
+ GURL validated_url(params.url);
+ RenderProcessHost* render_process_host = render_frame_host->GetProcess();
+ render_process_host->FilterURL(false, &validated_url);
+
+ if (net::ERR_ABORTED == params.error_code) {
+ // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials.
+ // This means that the interstitial won't be torn down properly, which is
+ // bad. But if we have an interstitial, go back to another tab type, and
+ // then load the same interstitial again, we could end up getting the first
+ // interstitial's "failed" message (as a result of the cancel) when we're on
+ // the second one.
+ //
+ // We can't tell this apart, so we think we're tearing down the current page
Charlie Reis 2014/01/06 19:07:17 Please keep the first sentence (and put it at the
nasko 2014/01/06 19:16:31 Done.
+ // which will cause a crash later one. There is also some code in
+ // RenderFrameHostManager::RendererAbortedProvisionalLoad that is commented
Charlie Reis 2014/01/06 18:13:35 We can remove this mention of RFHM::RendererAborte
nasko 2014/01/06 18:47:03 Done.
+ // out because of this problem.
+ //
+ // http://code.google.com/p/chromium/issues/detail?id=2855
+ // Because this will not tear down the interstitial properly, if "back" is
+ // back to another tab type, the interstitial will still be somewhat alive
+ // in the previous tab type. If you navigate somewhere that activates the
+ // tab with the interstitial again, you'll see a flash before the new load
+ // commits of the interstitial page.
+ RenderFrameHostManager* root_rfhm = render_frame_host->frame_tree_node()
Charlie Reis 2014/01/06 18:13:35 Nit: I wonder if there's a better way to format th
nasko 2014/01/06 18:47:03 Done.
+ ->frame_tree()
+ ->root()
+ ->render_manager();
+ if (root_rfhm->interstitial_page() != NULL) {
+ LOG(WARNING) << "Discarding message during interstitial.";
+ return;
+ }
Charlie Reis 2014/01/06 18:13:35 Let's put the useful part of the RFHM::RendererAbo
nasko 2014/01/06 18:47:03 Done.
+ }
+
+ // Do not usually clear the pending entry if one exists, so that the user's
+ // typed URL is not lost when a navigation fails or is aborted. However, in
+ // cases that we don't show the pending entry (e.g., renderer-initiated
+ // navigations in an existing tab), we don't keep it around. That prevents
+ // spoofs on in-page navigations that don't go through
+ // DidStartProvisionalLoadForFrame.
+ // In general, we allow the view to clear the pending entry and typed URL if
+ // the user requests (e.g., hitting Escape with focus in the address bar).
+ // Note: don't touch the transient entry, since an interstitial may exist.
+ if (controller_->GetPendingEntry() != controller_->GetVisibleEntry())
+ controller_->DiscardPendingEntry();
+
+ delegate_->DidFailProvisionalLoadWithError(render_frame_host, params);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698