| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2157 | 2157 |
| 2158 if (is_main_frame) { | 2158 if (is_main_frame) { |
| 2159 FOR_EACH_OBSERVER( | 2159 FOR_EACH_OBSERVER( |
| 2160 WebContentsObserver, | 2160 WebContentsObserver, |
| 2161 observers_, | 2161 observers_, |
| 2162 ProvisionalChangeToMainFrameUrl(validated_url, | 2162 ProvisionalChangeToMainFrameUrl(validated_url, |
| 2163 render_frame_host->render_view_host())); | 2163 render_frame_host->render_view_host())); |
| 2164 } | 2164 } |
| 2165 } | 2165 } |
| 2166 | 2166 |
| 2167 void WebContentsImpl::DidFailProvisionalLoadWithError( |
| 2168 RenderFrameHostImpl* render_frame_host, |
| 2169 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
| 2170 GURL validated_url(params.url); |
| 2171 FOR_EACH_OBSERVER( |
| 2172 WebContentsObserver, |
| 2173 observers_, |
| 2174 DidFailProvisionalLoad(params.frame_id, |
| 2175 params.frame_unique_name, |
| 2176 params.is_main_frame, |
| 2177 validated_url, |
| 2178 params.error_code, |
| 2179 params.error_description, |
| 2180 render_frame_host->render_view_host())); |
| 2181 } |
| 2182 |
| 2167 void WebContentsImpl::NotifyChangedNavigationState( | 2183 void WebContentsImpl::NotifyChangedNavigationState( |
| 2168 InvalidateTypes changed_flags) { | 2184 InvalidateTypes changed_flags) { |
| 2169 NotifyNavigationStateChanged(changed_flags); | 2185 NotifyNavigationStateChanged(changed_flags); |
| 2170 } | 2186 } |
| 2171 | 2187 |
| 2172 void WebContentsImpl::DidRedirectProvisionalLoad( | 2188 void WebContentsImpl::DidRedirectProvisionalLoad( |
| 2173 RenderViewHost* render_view_host, | 2189 RenderViewHost* render_view_host, |
| 2174 int32 page_id, | 2190 int32 page_id, |
| 2175 const GURL& source_url, | 2191 const GURL& source_url, |
| 2176 const GURL& target_url) { | 2192 const GURL& target_url) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2192 } | 2208 } |
| 2193 if (!entry || entry->GetURL() != validated_source_url) | 2209 if (!entry || entry->GetURL() != validated_source_url) |
| 2194 return; | 2210 return; |
| 2195 | 2211 |
| 2196 // Notify observers about the provisional change in the main frame URL. | 2212 // Notify observers about the provisional change in the main frame URL. |
| 2197 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2213 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2198 ProvisionalChangeToMainFrameUrl(validated_target_url, | 2214 ProvisionalChangeToMainFrameUrl(validated_target_url, |
| 2199 render_view_host)); | 2215 render_view_host)); |
| 2200 } | 2216 } |
| 2201 | 2217 |
| 2202 void WebContentsImpl::DidFailProvisionalLoadWithError( | |
| 2203 RenderViewHost* render_view_host, | |
| 2204 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { | |
| 2205 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | |
| 2206 << ", error_code: " << params.error_code | |
| 2207 << ", error_description: " << params.error_description | |
| 2208 << ", is_main_frame: " << params.is_main_frame | |
| 2209 << ", showing_repost_interstitial: " << | |
| 2210 params.showing_repost_interstitial | |
| 2211 << ", frame_id: " << params.frame_id; | |
| 2212 GURL validated_url(params.url); | |
| 2213 RenderProcessHost* render_process_host = | |
| 2214 render_view_host->GetProcess(); | |
| 2215 render_process_host->FilterURL(false, &validated_url); | |
| 2216 | |
| 2217 if (net::ERR_ABORTED == params.error_code) { | |
| 2218 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | |
| 2219 // This means that the interstitial won't be torn down properly, which is | |
| 2220 // bad. But if we have an interstitial, go back to another tab type, and | |
| 2221 // then load the same interstitial again, we could end up getting the first | |
| 2222 // interstitial's "failed" message (as a result of the cancel) when we're on | |
| 2223 // the second one. | |
| 2224 // | |
| 2225 // We can't tell this apart, so we think we're tearing down the current page | |
| 2226 // which will cause a crash later one. There is also some code in | |
| 2227 // RenderFrameHostManager::RendererAbortedProvisionalLoad that is commented | |
| 2228 // out because of this problem. | |
| 2229 // | |
| 2230 // http://code.google.com/p/chromium/issues/detail?id=2855 | |
| 2231 // Because this will not tear down the interstitial properly, if "back" is | |
| 2232 // back to another tab type, the interstitial will still be somewhat alive | |
| 2233 // in the previous tab type. If you navigate somewhere that activates the | |
| 2234 // tab with the interstitial again, you'll see a flash before the new load | |
| 2235 // commits of the interstitial page. | |
| 2236 if (ShowingInterstitialPage()) { | |
| 2237 LOG(WARNING) << "Discarding message during interstitial."; | |
| 2238 return; | |
| 2239 } | |
| 2240 | |
| 2241 GetRenderManager()->RendererAbortedProvisionalLoad(render_view_host); | |
| 2242 } | |
| 2243 | |
| 2244 // Do not usually clear the pending entry if one exists, so that the user's | |
| 2245 // typed URL is not lost when a navigation fails or is aborted. However, in | |
| 2246 // cases that we don't show the pending entry (e.g., renderer-initiated | |
| 2247 // navigations in an existing tab), we don't keep it around. That prevents | |
| 2248 // spoofs on in-page navigations that don't go through | |
| 2249 // DidStartProvisionalLoadForFrame. | |
| 2250 // In general, we allow the view to clear the pending entry and typed URL if | |
| 2251 // the user requests (e.g., hitting Escape with focus in the address bar). | |
| 2252 // Note: don't touch the transient entry, since an interstitial may exist. | |
| 2253 if (controller_.GetPendingEntry() != controller_.GetVisibleEntry()) | |
| 2254 controller_.DiscardPendingEntry(); | |
| 2255 | |
| 2256 FOR_EACH_OBSERVER(WebContentsObserver, | |
| 2257 observers_, | |
| 2258 DidFailProvisionalLoad(params.frame_id, | |
| 2259 params.frame_unique_name, | |
| 2260 params.is_main_frame, | |
| 2261 validated_url, | |
| 2262 params.error_code, | |
| 2263 params.error_description, | |
| 2264 render_view_host)); | |
| 2265 } | |
| 2266 | |
| 2267 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( | 2218 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( |
| 2268 const GURL& url, | 2219 const GURL& url, |
| 2269 const std::string& security_info, | 2220 const std::string& security_info, |
| 2270 const std::string& http_method, | 2221 const std::string& http_method, |
| 2271 const std::string& mime_type, | 2222 const std::string& mime_type, |
| 2272 ResourceType::Type resource_type) { | 2223 ResourceType::Type resource_type) { |
| 2273 base::StatsCounter cache("WebKit.CacheHit"); | 2224 base::StatsCounter cache("WebKit.CacheHit"); |
| 2274 cache.Increment(); | 2225 cache.Increment(); |
| 2275 | 2226 |
| 2276 // Send out a notification that we loaded a resource from our memory cache. | 2227 // Send out a notification that we loaded a resource from our memory cache. |
| (...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3896 } | 3847 } |
| 3897 | 3848 |
| 3898 void WebContentsImpl::OnFrameRemoved( | 3849 void WebContentsImpl::OnFrameRemoved( |
| 3899 RenderViewHostImpl* render_view_host, | 3850 RenderViewHostImpl* render_view_host, |
| 3900 int64 frame_id) { | 3851 int64 frame_id) { |
| 3901 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3852 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3902 FrameDetached(render_view_host, frame_id)); | 3853 FrameDetached(render_view_host, frame_id)); |
| 3903 } | 3854 } |
| 3904 | 3855 |
| 3905 } // namespace content | 3856 } // namespace content |
| OLD | NEW |