OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
9 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
10 #include "content/browser/frame_host/navigation_entry_impl.h" | 11 #include "content/browser/frame_host/navigation_entry_impl.h" |
11 #include "content/browser/frame_host/navigator_delegate.h" | 12 #include "content/browser/frame_host/navigator_delegate.h" |
12 #include "content/browser/frame_host/render_frame_host_impl.h" | 13 #include "content/browser/frame_host/render_frame_host_impl.h" |
13 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
14 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
| 16 #include "content/common/frame_messages.h" |
15 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
16 #include "content/public/browser/invalidate_type.h" | 18 #include "content/public/browser/invalidate_type.h" |
17 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
20 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 | 25 |
24 NavigatorImpl::NavigatorImpl( | 26 NavigatorImpl::NavigatorImpl( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 86 } |
85 | 87 |
86 if (delegate_) { | 88 if (delegate_) { |
87 // Notify the observer about the start of the provisional load. | 89 // Notify the observer about the start of the provisional load. |
88 delegate_->DidStartProvisionalLoad( | 90 delegate_->DidStartProvisionalLoad( |
89 render_frame_host, frame_id, parent_frame_id, is_main_frame, | 91 render_frame_host, frame_id, parent_frame_id, is_main_frame, |
90 validated_url, is_error_page, is_iframe_srcdoc); | 92 validated_url, is_error_page, is_iframe_srcdoc); |
91 } | 93 } |
92 } | 94 } |
93 | 95 |
| 96 |
| 97 void NavigatorImpl::DidFailProvisionalLoadWithError( |
| 98 RenderFrameHostImpl* render_frame_host, |
| 99 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
| 100 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
| 101 << ", error_code: " << params.error_code |
| 102 << ", error_description: " << params.error_description |
| 103 << ", is_main_frame: " << params.is_main_frame |
| 104 << ", showing_repost_interstitial: " << |
| 105 params.showing_repost_interstitial |
| 106 << ", frame_id: " << params.frame_id; |
| 107 GURL validated_url(params.url); |
| 108 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); |
| 109 render_process_host->FilterURL(false, &validated_url); |
| 110 |
| 111 if (net::ERR_ABORTED == params.error_code) { |
| 112 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
| 113 // This means that the interstitial won't be torn down properly, which is |
| 114 // bad. But if we have an interstitial, go back to another tab type, and |
| 115 // then load the same interstitial again, we could end up getting the first |
| 116 // interstitial's "failed" message (as a result of the cancel) when we're on |
| 117 // the second one. We can't tell this apart, so we think we're tearing down |
| 118 // the current page which will cause a crash later on. |
| 119 // |
| 120 // http://code.google.com/p/chromium/issues/detail?id=2855 |
| 121 // Because this will not tear down the interstitial properly, if "back" is |
| 122 // back to another tab type, the interstitial will still be somewhat alive |
| 123 // in the previous tab type. If you navigate somewhere that activates the |
| 124 // tab with the interstitial again, you'll see a flash before the new load |
| 125 // commits of the interstitial page. |
| 126 FrameTreeNode* root = |
| 127 render_frame_host->frame_tree_node()->frame_tree()->root(); |
| 128 if (root->render_manager()->interstitial_page() != NULL) { |
| 129 LOG(WARNING) << "Discarding message during interstitial."; |
| 130 return; |
| 131 } |
| 132 |
| 133 // We used to cancel the pending renderer here for cross-site downloads. |
| 134 // However, it's not safe to do that because the download logic repeatedly |
| 135 // looks for this WebContents based on a render ID. Instead, we just |
| 136 // leave the pending renderer around until the next navigation event |
| 137 // (Navigate, DidNavigate, etc), which will clean it up properly. |
| 138 // |
| 139 // TODO(creis): Find a way to cancel any pending RFH here. |
| 140 } |
| 141 |
| 142 // Do not usually clear the pending entry if one exists, so that the user's |
| 143 // typed URL is not lost when a navigation fails or is aborted. However, in |
| 144 // cases that we don't show the pending entry (e.g., renderer-initiated |
| 145 // navigations in an existing tab), we don't keep it around. That prevents |
| 146 // spoofs on in-page navigations that don't go through |
| 147 // DidStartProvisionalLoadForFrame. |
| 148 // In general, we allow the view to clear the pending entry and typed URL if |
| 149 // the user requests (e.g., hitting Escape with focus in the address bar). |
| 150 // Note: don't touch the transient entry, since an interstitial may exist. |
| 151 if (controller_->GetPendingEntry() != controller_->GetVisibleEntry()) |
| 152 controller_->DiscardPendingEntry(); |
| 153 |
| 154 delegate_->DidFailProvisionalLoadWithError(render_frame_host, params); |
| 155 } |
| 156 |
94 } // namespace content | 157 } // namespace content |
OLD | NEW |