| 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/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 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3540 } | 3540 } |
| 3541 | 3541 |
| 3542 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, | 3542 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, |
| 3543 const WebURLError& error) { | 3543 const WebURLError& error) { |
| 3544 // Notify the browser that we failed a provisional load with an error. | 3544 // Notify the browser that we failed a provisional load with an error. |
| 3545 // | 3545 // |
| 3546 // Note: It is important this notification occur before DidStopLoading so the | 3546 // Note: It is important this notification occur before DidStopLoading so the |
| 3547 // SSL manager can react to the provisional load failure before being | 3547 // SSL manager can react to the provisional load failure before being |
| 3548 // notified the load stopped. | 3548 // notified the load stopped. |
| 3549 // | 3549 // |
| 3550 WebDataSource* ds = frame->provisionalDataSource(); | |
| 3551 DCHECK(ds); | |
| 3552 | |
| 3553 const WebURLRequest& failed_request = ds->request(); | |
| 3554 | |
| 3555 FOR_EACH_OBSERVER( | 3550 FOR_EACH_OBSERVER( |
| 3556 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); | 3551 RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); |
| 3557 | |
| 3558 bool show_repost_interstitial = | |
| 3559 (error.reason == net::ERR_CACHE_MISS && | |
| 3560 EqualsASCII(failed_request.httpMethod(), "POST")); | |
| 3561 | |
| 3562 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | |
| 3563 params.frame_id = frame->identifier(); | |
| 3564 params.frame_unique_name = frame->uniqueName(); | |
| 3565 params.is_main_frame = !frame->parent(); | |
| 3566 params.error_code = error.reason; | |
| 3567 GetContentClient()->renderer()->GetNavigationErrorStrings( | |
| 3568 frame, | |
| 3569 failed_request, | |
| 3570 error, | |
| 3571 renderer_preferences_.accept_languages, | |
| 3572 NULL, | |
| 3573 ¶ms.error_description); | |
| 3574 params.url = error.unreachableURL; | |
| 3575 params.showing_repost_interstitial = show_repost_interstitial; | |
| 3576 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( | |
| 3577 routing_id_, params)); | |
| 3578 | |
| 3579 // Don't display an error page if this is simply a cancelled load. Aside | |
| 3580 // from being dumb, WebCore doesn't expect it and it will cause a crash. | |
| 3581 if (error.reason == net::ERR_ABORTED) | |
| 3582 return; | |
| 3583 | |
| 3584 // Don't display "client blocked" error page if browser has asked us not to. | |
| 3585 if (error.reason == net::ERR_BLOCKED_BY_CLIENT && | |
| 3586 renderer_preferences_.disable_client_blocked_error_page) { | |
| 3587 return; | |
| 3588 } | |
| 3589 | |
| 3590 // Allow the embedder to suppress an error page. | |
| 3591 if (GetContentClient()->renderer()->ShouldSuppressErrorPage( | |
| 3592 error.unreachableURL)) { | |
| 3593 return; | |
| 3594 } | |
| 3595 | |
| 3596 if (RenderThreadImpl::current() && | |
| 3597 RenderThreadImpl::current()->layout_test_mode()) { | |
| 3598 return; | |
| 3599 } | |
| 3600 | |
| 3601 // Make sure we never show errors in view source mode. | |
| 3602 frame->enableViewSourceMode(false); | |
| 3603 | |
| 3604 DocumentState* document_state = DocumentState::FromDataSource(ds); | |
| 3605 NavigationState* navigation_state = document_state->navigation_state(); | |
| 3606 | |
| 3607 // If this is a failed back/forward/reload navigation, then we need to do a | |
| 3608 // 'replace' load. This is necessary to avoid messing up session history. | |
| 3609 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | |
| 3610 // as session history is concerned. | |
| 3611 // | |
| 3612 // AUTO_SUBFRAME loads should always be treated as loads that do not advance | |
| 3613 // the page id. | |
| 3614 // | |
| 3615 // TODO(davidben): This should also take the failed navigation's replacement | |
| 3616 // state into account, if a location.replace() failed. | |
| 3617 bool replace = | |
| 3618 navigation_state->pending_page_id() != -1 || | |
| 3619 PageTransitionCoreTypeIs(navigation_state->transition_type(), | |
| 3620 PAGE_TRANSITION_AUTO_SUBFRAME); | |
| 3621 | |
| 3622 // If we failed on a browser initiated request, then make sure that our error | |
| 3623 // page load is regarded as the same browser initiated request. | |
| 3624 if (!navigation_state->is_content_initiated()) { | |
| 3625 pending_navigation_params_.reset(new ViewMsg_Navigate_Params); | |
| 3626 pending_navigation_params_->page_id = | |
| 3627 navigation_state->pending_page_id(); | |
| 3628 pending_navigation_params_->pending_history_list_offset = | |
| 3629 navigation_state->pending_history_list_offset(); | |
| 3630 pending_navigation_params_->should_clear_history_list = | |
| 3631 navigation_state->history_list_was_cleared(); | |
| 3632 pending_navigation_params_->transition = | |
| 3633 navigation_state->transition_type(); | |
| 3634 pending_navigation_params_->request_time = | |
| 3635 document_state->request_time(); | |
| 3636 pending_navigation_params_->should_replace_current_entry = replace; | |
| 3637 } | |
| 3638 | |
| 3639 // Provide the user with a more helpful error page? | |
| 3640 if (MaybeLoadAlternateErrorPage(frame, error, replace)) | |
| 3641 return; | |
| 3642 | |
| 3643 // Fallback to a local error page. | |
| 3644 LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); | |
| 3645 } | 3552 } |
| 3646 | 3553 |
| 3647 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, | 3554 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, |
| 3648 bool is_new_navigation) { | 3555 bool is_new_navigation) { |
| 3649 DocumentState* document_state = | 3556 DocumentState* document_state = |
| 3650 DocumentState::FromDataSource(frame->dataSource()); | 3557 DocumentState::FromDataSource(frame->dataSource()); |
| 3651 NavigationState* navigation_state = document_state->navigation_state(); | 3558 NavigationState* navigation_state = document_state->navigation_state(); |
| 3652 InternalDocumentStateData* internal_data = | 3559 InternalDocumentStateData* internal_data = |
| 3653 InternalDocumentStateData::FromDocumentState(document_state); | 3560 InternalDocumentStateData::FromDocumentState(document_state); |
| 3654 | 3561 |
| (...skipping 2793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6448 for (size_t i = 0; i < icon_urls.size(); i++) { | 6355 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6449 WebURL url = icon_urls[i].iconURL(); | 6356 WebURL url = icon_urls[i].iconURL(); |
| 6450 if (!url.isEmpty()) | 6357 if (!url.isEmpty()) |
| 6451 urls.push_back(FaviconURL(url, | 6358 urls.push_back(FaviconURL(url, |
| 6452 ToFaviconType(icon_urls[i].iconType()))); | 6359 ToFaviconType(icon_urls[i].iconType()))); |
| 6453 } | 6360 } |
| 6454 SendUpdateFaviconURL(urls); | 6361 SendUpdateFaviconURL(urls); |
| 6455 } | 6362 } |
| 6456 | 6363 |
| 6457 } // namespace content | 6364 } // namespace content |
| OLD | NEW |