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 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2190 const WebURLError& error, | 2190 const WebURLError& error, |
2191 const std::string& html, | 2191 const std::string& html, |
2192 bool replace) { | 2192 bool replace) { |
2193 std::string alt_html; | 2193 std::string alt_html; |
2194 const std::string* error_html; | 2194 const std::string* error_html; |
2195 | 2195 |
2196 if (!html.empty()) { | 2196 if (!html.empty()) { |
2197 error_html = &html; | 2197 error_html = &html; |
2198 } else { | 2198 } else { |
2199 GetContentClient()->renderer()->GetNavigationErrorStrings( | 2199 GetContentClient()->renderer()->GetNavigationErrorStrings( |
2200 frame, failed_request, error, &alt_html, NULL); | 2200 frame, failed_request, error, renderer_preferences_.accept_languages, |
| 2201 &alt_html, NULL); |
2201 error_html = &alt_html; | 2202 error_html = &alt_html; |
2202 } | 2203 } |
2203 | 2204 |
2204 frame->loadHTMLString(*error_html, | 2205 frame->loadHTMLString(*error_html, |
2205 GURL(kUnreachableWebDataURL), | 2206 GURL(kUnreachableWebDataURL), |
2206 error.unreachableURL, | 2207 error.unreachableURL, |
2207 replace); | 2208 replace); |
2208 } | 2209 } |
2209 | 2210 |
2210 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, | 2211 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3144 | 3145 |
3145 SSLStatus ssl_status; | 3146 SSLStatus ssl_status; |
3146 DeserializeSecurityInfo(security_info, | 3147 DeserializeSecurityInfo(security_info, |
3147 &ssl_status.cert_id, | 3148 &ssl_status.cert_id, |
3148 &ssl_status.cert_status, | 3149 &ssl_status.cert_status, |
3149 &ssl_status.security_bits, | 3150 &ssl_status.security_bits, |
3150 &ssl_status.connection_status); | 3151 &ssl_status.connection_status); |
3151 return ssl_status; | 3152 return ssl_status; |
3152 } | 3153 } |
3153 | 3154 |
| 3155 const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 3156 return renderer_preferences_.accept_languages; |
| 3157 } |
| 3158 |
3154 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 3159 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
3155 WebFrame* frame, WebDataSource::ExtraData* extraData, | 3160 WebFrame* frame, WebDataSource::ExtraData* extraData, |
3156 const WebURLRequest& request, WebNavigationType type, | 3161 const WebURLRequest& request, WebNavigationType type, |
3157 WebNavigationPolicy default_policy, bool is_redirect) { | 3162 WebNavigationPolicy default_policy, bool is_redirect) { |
3158 if (request.url() != GURL(kSwappedOutURL) && | 3163 if (request.url() != GURL(kSwappedOutURL) && |
3159 GetContentClient()->renderer()->HandleNavigation(frame, request, type, | 3164 GetContentClient()->renderer()->HandleNavigation(frame, request, type, |
3160 default_policy, | 3165 default_policy, |
3161 is_redirect)) { | 3166 is_redirect)) { |
3162 return WebKit::WebNavigationPolicyIgnore; | 3167 return WebKit::WebNavigationPolicyIgnore; |
3163 } | 3168 } |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3634 EqualsASCII(failed_request.httpMethod(), "POST")); | 3639 EqualsASCII(failed_request.httpMethod(), "POST")); |
3635 | 3640 |
3636 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 3641 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
3637 params.frame_id = frame->identifier(); | 3642 params.frame_id = frame->identifier(); |
3638 params.is_main_frame = !frame->parent(); | 3643 params.is_main_frame = !frame->parent(); |
3639 params.error_code = error.reason; | 3644 params.error_code = error.reason; |
3640 GetContentClient()->renderer()->GetNavigationErrorStrings( | 3645 GetContentClient()->renderer()->GetNavigationErrorStrings( |
3641 frame, | 3646 frame, |
3642 failed_request, | 3647 failed_request, |
3643 error, | 3648 error, |
| 3649 renderer_preferences_.accept_languages, |
3644 NULL, | 3650 NULL, |
3645 ¶ms.error_description); | 3651 ¶ms.error_description); |
3646 params.url = error.unreachableURL; | 3652 params.url = error.unreachableURL; |
3647 params.showing_repost_interstitial = show_repost_interstitial; | 3653 params.showing_repost_interstitial = show_repost_interstitial; |
3648 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( | 3654 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
3649 routing_id_, params)); | 3655 routing_id_, params)); |
3650 | 3656 |
3651 // Don't display an error page if this is simply a cancelled load. Aside | 3657 // Don't display an error page if this is simply a cancelled load. Aside |
3652 // from being dumb, WebCore doesn't expect it and it will cause a crash. | 3658 // from being dumb, WebCore doesn't expect it and it will cause a crash. |
3653 if (error.reason == net::ERR_ABORTED) | 3659 if (error.reason == net::ERR_ABORTED) |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 | 3894 |
3889 | 3895 |
3890 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); | 3896 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
3891 | 3897 |
3892 const WebURLRequest& failed_request = ds->request(); | 3898 const WebURLRequest& failed_request = ds->request(); |
3893 string16 error_description; | 3899 string16 error_description; |
3894 GetContentClient()->renderer()->GetNavigationErrorStrings( | 3900 GetContentClient()->renderer()->GetNavigationErrorStrings( |
3895 frame, | 3901 frame, |
3896 failed_request, | 3902 failed_request, |
3897 error, | 3903 error, |
| 3904 renderer_preferences_.accept_languages, |
3898 NULL, | 3905 NULL, |
3899 &error_description); | 3906 &error_description); |
3900 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, | 3907 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
3901 frame->identifier(), | 3908 frame->identifier(), |
3902 failed_request.url(), | 3909 failed_request.url(), |
3903 !frame->parent(), | 3910 !frame->parent(), |
3904 error.reason, | 3911 error.reason, |
3905 error_description)); | 3912 error_description)); |
3906 } | 3913 } |
3907 | 3914 |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4584 if (!alternate_error_page_url_.is_valid()) | 4591 if (!alternate_error_page_url_.is_valid()) |
4585 return GURL(); | 4592 return GURL(); |
4586 | 4593 |
4587 // Strip query params from the failed URL. | 4594 // Strip query params from the failed URL. |
4588 GURL::Replacements remove_params; | 4595 GURL::Replacements remove_params; |
4589 remove_params.ClearUsername(); | 4596 remove_params.ClearUsername(); |
4590 remove_params.ClearPassword(); | 4597 remove_params.ClearPassword(); |
4591 remove_params.ClearQuery(); | 4598 remove_params.ClearQuery(); |
4592 remove_params.ClearRef(); | 4599 remove_params.ClearRef(); |
4593 const GURL url_to_send = failed_url.ReplaceComponents(remove_params); | 4600 const GURL url_to_send = failed_url.ReplaceComponents(remove_params); |
| 4601 // TODO(yuusuke): change to net::FormatUrl when link doctor |
| 4602 // becomes unicode-capable. |
4594 std::string spec_to_send = url_to_send.spec(); | 4603 std::string spec_to_send = url_to_send.spec(); |
4595 // Notify link doctor of the url truncation by sending of "?" at the end. | 4604 // Notify link doctor of the url truncation by sending of "?" at the end. |
4596 if (failed_url.has_query()) | 4605 if (failed_url.has_query()) |
4597 spec_to_send.append("?"); | 4606 spec_to_send.append("?"); |
4598 | 4607 |
4599 // Construct the query params to send to link doctor. | 4608 // Construct the query params to send to link doctor. |
4600 std::string params(alternate_error_page_url_.query()); | 4609 std::string params(alternate_error_page_url_.query()); |
4601 params.append("&url="); | 4610 params.append("&url="); |
4602 params.append(net::EscapeQueryParamValue(spec_to_send, true)); | 4611 params.append(net::EscapeQueryParamValue(spec_to_send, true)); |
4603 params.append("&sourceid=chrome"); | 4612 params.append("&sourceid=chrome"); |
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6523 for (size_t i = 0; i < icon_urls.size(); i++) { | 6532 for (size_t i = 0; i < icon_urls.size(); i++) { |
6524 WebURL url = icon_urls[i].iconURL(); | 6533 WebURL url = icon_urls[i].iconURL(); |
6525 if (!url.isEmpty()) | 6534 if (!url.isEmpty()) |
6526 urls.push_back(FaviconURL(url, | 6535 urls.push_back(FaviconURL(url, |
6527 ToFaviconType(icon_urls[i].iconType()))); | 6536 ToFaviconType(icon_urls[i].iconType()))); |
6528 } | 6537 } |
6529 SendUpdateFaviconURL(urls); | 6538 SendUpdateFaviconURL(urls); |
6530 } | 6539 } |
6531 | 6540 |
6532 } // namespace content | 6541 } // namespace content |
OLD | NEW |