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

Side by Side Diff: content/renderer/render_view_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: Rebase on ToT. Created 6 years, 11 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
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 3538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 } 3549 }
3550 3550
3551 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, 3551 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame,
3552 const WebURLError& error) { 3552 const WebURLError& error) {
3553 // Notify the browser that we failed a provisional load with an error. 3553 // Notify the browser that we failed a provisional load with an error.
3554 // 3554 //
3555 // Note: It is important this notification occur before DidStopLoading so the 3555 // Note: It is important this notification occur before DidStopLoading so the
3556 // SSL manager can react to the provisional load failure before being 3556 // SSL manager can react to the provisional load failure before being
3557 // notified the load stopped. 3557 // notified the load stopped.
3558 // 3558 //
3559 WebDataSource* ds = frame->provisionalDataSource();
3560 DCHECK(ds);
3561
3562 const WebURLRequest& failed_request = ds->request();
3563
3564 FOR_EACH_OBSERVER( 3559 FOR_EACH_OBSERVER(
3565 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); 3560 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error));
3566
3567 bool show_repost_interstitial =
3568 (error.reason == net::ERR_CACHE_MISS &&
3569 EqualsASCII(failed_request.httpMethod(), "POST"));
3570
3571 ViewHostMsg_DidFailProvisionalLoadWithError_Params params;
3572 params.frame_id = frame->identifier();
3573 params.frame_unique_name = frame->uniqueName();
3574 params.is_main_frame = !frame->parent();
3575 params.error_code = error.reason;
3576 GetContentClient()->renderer()->GetNavigationErrorStrings(
3577 frame,
3578 failed_request,
3579 error,
3580 renderer_preferences_.accept_languages,
3581 NULL,
3582 &params.error_description);
3583 params.url = error.unreachableURL;
3584 params.showing_repost_interstitial = show_repost_interstitial;
3585 Send(new ViewHostMsg_DidFailProvisionalLoadWithError(
3586 routing_id_, params));
3587
3588 // Don't display an error page if this is simply a cancelled load. Aside
3589 // from being dumb, WebCore doesn't expect it and it will cause a crash.
3590 if (error.reason == net::ERR_ABORTED)
3591 return;
3592
3593 // Don't display "client blocked" error page if browser has asked us not to.
3594 if (error.reason == net::ERR_BLOCKED_BY_CLIENT &&
3595 renderer_preferences_.disable_client_blocked_error_page) {
3596 return;
3597 }
3598
3599 // Allow the embedder to suppress an error page.
3600 if (GetContentClient()->renderer()->ShouldSuppressErrorPage(
3601 error.unreachableURL)) {
3602 return;
3603 }
3604
3605 if (RenderThreadImpl::current() &&
3606 RenderThreadImpl::current()->layout_test_mode()) {
3607 return;
3608 }
3609
3610 // Make sure we never show errors in view source mode.
3611 frame->enableViewSourceMode(false);
3612
3613 DocumentState* document_state = DocumentState::FromDataSource(ds);
3614 NavigationState* navigation_state = document_state->navigation_state();
3615
3616 // If this is a failed back/forward/reload navigation, then we need to do a
3617 // 'replace' load. This is necessary to avoid messing up session history.
3618 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
3619 // as session history is concerned.
3620 //
3621 // AUTO_SUBFRAME loads should always be treated as loads that do not advance
3622 // the page id.
3623 //
3624 // TODO(davidben): This should also take the failed navigation's replacement
3625 // state into account, if a location.replace() failed.
3626 bool replace =
3627 navigation_state->pending_page_id() != -1 ||
3628 PageTransitionCoreTypeIs(navigation_state->transition_type(),
3629 PAGE_TRANSITION_AUTO_SUBFRAME);
3630
3631 // If we failed on a browser initiated request, then make sure that our error
3632 // page load is regarded as the same browser initiated request.
3633 if (!navigation_state->is_content_initiated()) {
3634 pending_navigation_params_.reset(new ViewMsg_Navigate_Params);
3635 pending_navigation_params_->page_id =
3636 navigation_state->pending_page_id();
3637 pending_navigation_params_->pending_history_list_offset =
3638 navigation_state->pending_history_list_offset();
3639 pending_navigation_params_->should_clear_history_list =
3640 navigation_state->history_list_was_cleared();
3641 pending_navigation_params_->transition =
3642 navigation_state->transition_type();
3643 pending_navigation_params_->request_time =
3644 document_state->request_time();
3645 pending_navigation_params_->should_replace_current_entry = replace;
3646 }
3647
3648 // Provide the user with a more helpful error page?
3649 if (MaybeLoadAlternateErrorPage(frame, error, replace))
3650 return;
3651
3652 // Fallback to a local error page.
3653 LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace);
3654 } 3561 }
3655 3562
3656 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, 3563 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame,
3657 bool is_new_navigation) { 3564 bool is_new_navigation) {
3658 DocumentState* document_state = 3565 DocumentState* document_state =
3659 DocumentState::FromDataSource(frame->dataSource()); 3566 DocumentState::FromDataSource(frame->dataSource());
3660 NavigationState* navigation_state = document_state->navigation_state(); 3567 NavigationState* navigation_state = document_state->navigation_state();
3661 InternalDocumentStateData* internal_data = 3568 InternalDocumentStateData* internal_data =
3662 InternalDocumentStateData::FromDocumentState(document_state); 3569 InternalDocumentStateData::FromDocumentState(document_state);
3663 3570
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after
6466 for (size_t i = 0; i < icon_urls.size(); i++) { 6373 for (size_t i = 0; i < icon_urls.size(); i++) {
6467 WebURL url = icon_urls[i].iconURL(); 6374 WebURL url = icon_urls[i].iconURL();
6468 if (!url.isEmpty()) 6375 if (!url.isEmpty())
6469 urls.push_back(FaviconURL(url, 6376 urls.push_back(FaviconURL(url,
6470 ToFaviconType(icon_urls[i].iconType()))); 6377 ToFaviconType(icon_urls[i].iconType())));
6471 } 6378 }
6472 SendUpdateFaviconURL(urls); 6379 SendUpdateFaviconURL(urls);
6473 } 6380 }
6474 6381
6475 } // namespace content 6382 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698