| 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 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 const WebURLError& error, | 2192 const WebURLError& error, |
| 2193 const std::string& html, | 2193 const std::string& html, |
| 2194 bool replace) { | 2194 bool replace) { |
| 2195 std::string alt_html; | 2195 std::string alt_html; |
| 2196 const std::string* error_html; | 2196 const std::string* error_html; |
| 2197 | 2197 |
| 2198 if (!html.empty()) { | 2198 if (!html.empty()) { |
| 2199 error_html = &html; | 2199 error_html = &html; |
| 2200 } else { | 2200 } else { |
| 2201 GetContentClient()->renderer()->GetNavigationErrorStrings( | 2201 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 2202 frame, failed_request, error, &alt_html, NULL); | 2202 frame, failed_request, error, renderer_preferences_.accept_languages, |
| 2203 &alt_html, NULL); |
| 2203 error_html = &alt_html; | 2204 error_html = &alt_html; |
| 2204 } | 2205 } |
| 2205 | 2206 |
| 2206 frame->loadHTMLString(*error_html, | 2207 frame->loadHTMLString(*error_html, |
| 2207 GURL(kUnreachableWebDataURL), | 2208 GURL(kUnreachableWebDataURL), |
| 2208 error.unreachableURL, | 2209 error.unreachableURL, |
| 2209 replace); | 2210 replace); |
| 2210 } | 2211 } |
| 2211 | 2212 |
| 2212 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, | 2213 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3127 | 3128 |
| 3128 SSLStatus ssl_status; | 3129 SSLStatus ssl_status; |
| 3129 DeserializeSecurityInfo(security_info, | 3130 DeserializeSecurityInfo(security_info, |
| 3130 &ssl_status.cert_id, | 3131 &ssl_status.cert_id, |
| 3131 &ssl_status.cert_status, | 3132 &ssl_status.cert_status, |
| 3132 &ssl_status.security_bits, | 3133 &ssl_status.security_bits, |
| 3133 &ssl_status.connection_status); | 3134 &ssl_status.connection_status); |
| 3134 return ssl_status; | 3135 return ssl_status; |
| 3135 } | 3136 } |
| 3136 | 3137 |
| 3138 const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 3139 return renderer_preferences_.accept_languages; |
| 3140 } |
| 3141 |
| 3137 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 3142 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
| 3138 WebFrame* frame, WebDataSource::ExtraData* extraData, | 3143 WebFrame* frame, WebDataSource::ExtraData* extraData, |
| 3139 const WebURLRequest& request, WebNavigationType type, | 3144 const WebURLRequest& request, WebNavigationType type, |
| 3140 WebNavigationPolicy default_policy, bool is_redirect) { | 3145 WebNavigationPolicy default_policy, bool is_redirect) { |
| 3141 if (request.url() != GURL(kSwappedOutURL) && | 3146 if (request.url() != GURL(kSwappedOutURL) && |
| 3142 GetContentClient()->renderer()->HandleNavigation(frame, request, type, | 3147 GetContentClient()->renderer()->HandleNavigation(frame, request, type, |
| 3143 default_policy, | 3148 default_policy, |
| 3144 is_redirect)) { | 3149 is_redirect)) { |
| 3145 return WebKit::WebNavigationPolicyIgnore; | 3150 return WebKit::WebNavigationPolicyIgnore; |
| 3146 } | 3151 } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3616 EqualsASCII(failed_request.httpMethod(), "POST")); | 3621 EqualsASCII(failed_request.httpMethod(), "POST")); |
| 3617 | 3622 |
| 3618 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 3623 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 3619 params.frame_id = frame->identifier(); | 3624 params.frame_id = frame->identifier(); |
| 3620 params.is_main_frame = !frame->parent(); | 3625 params.is_main_frame = !frame->parent(); |
| 3621 params.error_code = error.reason; | 3626 params.error_code = error.reason; |
| 3622 GetContentClient()->renderer()->GetNavigationErrorStrings( | 3627 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3623 frame, | 3628 frame, |
| 3624 failed_request, | 3629 failed_request, |
| 3625 error, | 3630 error, |
| 3631 renderer_preferences_.accept_languages, |
| 3626 NULL, | 3632 NULL, |
| 3627 ¶ms.error_description); | 3633 ¶ms.error_description); |
| 3628 params.url = error.unreachableURL; | 3634 params.url = error.unreachableURL; |
| 3629 params.showing_repost_interstitial = show_repost_interstitial; | 3635 params.showing_repost_interstitial = show_repost_interstitial; |
| 3630 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( | 3636 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
| 3631 routing_id_, params)); | 3637 routing_id_, params)); |
| 3632 | 3638 |
| 3633 // Don't display an error page if this is simply a cancelled load. Aside | 3639 // Don't display an error page if this is simply a cancelled load. Aside |
| 3634 // from being dumb, WebCore doesn't expect it and it will cause a crash. | 3640 // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 3635 if (error.reason == net::ERR_ABORTED) | 3641 if (error.reason == net::ERR_ABORTED) |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3862 | 3868 |
| 3863 | 3869 |
| 3864 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); | 3870 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
| 3865 | 3871 |
| 3866 const WebURLRequest& failed_request = ds->request(); | 3872 const WebURLRequest& failed_request = ds->request(); |
| 3867 string16 error_description; | 3873 string16 error_description; |
| 3868 GetContentClient()->renderer()->GetNavigationErrorStrings( | 3874 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3869 frame, | 3875 frame, |
| 3870 failed_request, | 3876 failed_request, |
| 3871 error, | 3877 error, |
| 3878 renderer_preferences_.accept_languages, |
| 3872 NULL, | 3879 NULL, |
| 3873 &error_description); | 3880 &error_description); |
| 3874 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, | 3881 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
| 3875 frame->identifier(), | 3882 frame->identifier(), |
| 3876 failed_request.url(), | 3883 failed_request.url(), |
| 3877 !frame->parent(), | 3884 !frame->parent(), |
| 3878 error.reason, | 3885 error.reason, |
| 3879 error_description)); | 3886 error_description)); |
| 3880 } | 3887 } |
| 3881 | 3888 |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4558 if (!alternate_error_page_url_.is_valid()) | 4565 if (!alternate_error_page_url_.is_valid()) |
| 4559 return GURL(); | 4566 return GURL(); |
| 4560 | 4567 |
| 4561 // Strip query params from the failed URL. | 4568 // Strip query params from the failed URL. |
| 4562 GURL::Replacements remove_params; | 4569 GURL::Replacements remove_params; |
| 4563 remove_params.ClearUsername(); | 4570 remove_params.ClearUsername(); |
| 4564 remove_params.ClearPassword(); | 4571 remove_params.ClearPassword(); |
| 4565 remove_params.ClearQuery(); | 4572 remove_params.ClearQuery(); |
| 4566 remove_params.ClearRef(); | 4573 remove_params.ClearRef(); |
| 4567 const GURL url_to_send = failed_url.ReplaceComponents(remove_params); | 4574 const GURL url_to_send = failed_url.ReplaceComponents(remove_params); |
| 4575 // TODO(yuusuke): change to net::FormatUrl when link doctor |
| 4576 // becomes unicode-capable. |
| 4568 std::string spec_to_send = url_to_send.spec(); | 4577 std::string spec_to_send = url_to_send.spec(); |
| 4569 // Notify link doctor of the url truncation by sending of "?" at the end. | 4578 // Notify link doctor of the url truncation by sending of "?" at the end. |
| 4570 if (failed_url.has_query()) | 4579 if (failed_url.has_query()) |
| 4571 spec_to_send.append("?"); | 4580 spec_to_send.append("?"); |
| 4572 | 4581 |
| 4573 // Construct the query params to send to link doctor. | 4582 // Construct the query params to send to link doctor. |
| 4574 std::string params(alternate_error_page_url_.query()); | 4583 std::string params(alternate_error_page_url_.query()); |
| 4575 params.append("&url="); | 4584 params.append("&url="); |
| 4576 params.append(net::EscapeQueryParamValue(spec_to_send, true)); | 4585 params.append(net::EscapeQueryParamValue(spec_to_send, true)); |
| 4577 params.append("&sourceid=chrome"); | 4586 params.append("&sourceid=chrome"); |
| (...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6506 for (size_t i = 0; i < icon_urls.size(); i++) { | 6515 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6507 WebURL url = icon_urls[i].iconURL(); | 6516 WebURL url = icon_urls[i].iconURL(); |
| 6508 if (!url.isEmpty()) | 6517 if (!url.isEmpty()) |
| 6509 urls.push_back(FaviconURL(url, | 6518 urls.push_back(FaviconURL(url, |
| 6510 ToFaviconType(icon_urls[i].iconType()))); | 6519 ToFaviconType(icon_urls[i].iconType()))); |
| 6511 } | 6520 } |
| 6512 SendUpdateFaviconURL(urls); | 6521 SendUpdateFaviconURL(urls); |
| 6513 } | 6522 } |
| 6514 | 6523 |
| 6515 } // namespace content | 6524 } // namespace content |
| OLD | NEW |