Chromium Code Reviews| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 #include "content/renderer/websharedworker_proxy.h" | 126 #include "content/renderer/websharedworker_proxy.h" |
| 127 #include "media/audio/audio_output_device.h" | 127 #include "media/audio/audio_output_device.h" |
| 128 #include "media/base/audio_renderer_mixer_input.h" | 128 #include "media/base/audio_renderer_mixer_input.h" |
| 129 #include "media/base/filter_collection.h" | 129 #include "media/base/filter_collection.h" |
| 130 #include "media/base/media_switches.h" | 130 #include "media/base/media_switches.h" |
| 131 #include "media/filters/audio_renderer_impl.h" | 131 #include "media/filters/audio_renderer_impl.h" |
| 132 #include "media/filters/gpu_video_accelerator_factories.h" | 132 #include "media/filters/gpu_video_accelerator_factories.h" |
| 133 #include "net/base/data_url.h" | 133 #include "net/base/data_url.h" |
| 134 #include "net/base/escape.h" | 134 #include "net/base/escape.h" |
| 135 #include "net/base/net_errors.h" | 135 #include "net/base/net_errors.h" |
| 136 #include "net/base/net_util.h" | |
| 136 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 137 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 137 #include "net/http/http_util.h" | 138 #include "net/http/http_util.h" |
| 138 #include "third_party/WebKit/public/platform/WebCString.h" | 139 #include "third_party/WebKit/public/platform/WebCString.h" |
| 139 #include "third_party/WebKit/public/platform/WebDragData.h" | 140 #include "third_party/WebKit/public/platform/WebDragData.h" |
| 140 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 141 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 141 #include "third_party/WebKit/public/platform/WebImage.h" | 142 #include "third_party/WebKit/public/platform/WebImage.h" |
| 142 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 143 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 143 #include "third_party/WebKit/public/platform/WebPoint.h" | 144 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 144 #include "third_party/WebKit/public/platform/WebRect.h" | 145 #include "third_party/WebKit/public/platform/WebRect.h" |
| 145 #include "third_party/WebKit/public/platform/WebSize.h" | 146 #include "third_party/WebKit/public/platform/WebSize.h" |
| (...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2192 const WebURLError& error, | 2193 const WebURLError& error, |
| 2193 const std::string& html, | 2194 const std::string& html, |
| 2194 bool replace) { | 2195 bool replace) { |
| 2195 std::string alt_html; | 2196 std::string alt_html; |
| 2196 const std::string* error_html; | 2197 const std::string* error_html; |
| 2197 | 2198 |
| 2198 if (!html.empty()) { | 2199 if (!html.empty()) { |
| 2199 error_html = &html; | 2200 error_html = &html; |
| 2200 } else { | 2201 } else { |
| 2201 GetContentClient()->renderer()->GetNavigationErrorStrings( | 2202 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 2202 frame, failed_request, error, &alt_html, NULL); | 2203 frame, failed_request, error, renderer_preferences_.accept_languages, |
| 2204 &alt_html, NULL); | |
| 2203 error_html = &alt_html; | 2205 error_html = &alt_html; |
| 2204 } | 2206 } |
| 2205 | 2207 |
| 2206 frame->loadHTMLString(*error_html, | 2208 frame->loadHTMLString(*error_html, |
| 2207 GURL(kUnreachableWebDataURL), | 2209 GURL(kUnreachableWebDataURL), |
| 2208 error.unreachableURL, | 2210 error.unreachableURL, |
| 2209 replace); | 2211 replace); |
| 2210 } | 2212 } |
| 2211 | 2213 |
| 2212 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, | 2214 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3127 | 3129 |
| 3128 SSLStatus ssl_status; | 3130 SSLStatus ssl_status; |
| 3129 DeserializeSecurityInfo(security_info, | 3131 DeserializeSecurityInfo(security_info, |
| 3130 &ssl_status.cert_id, | 3132 &ssl_status.cert_id, |
| 3131 &ssl_status.cert_status, | 3133 &ssl_status.cert_status, |
| 3132 &ssl_status.security_bits, | 3134 &ssl_status.security_bits, |
| 3133 &ssl_status.connection_status); | 3135 &ssl_status.connection_status); |
| 3134 return ssl_status; | 3136 return ssl_status; |
| 3135 } | 3137 } |
| 3136 | 3138 |
| 3139 const std::string& RenderViewImpl::GetAcceptLanguages() const { | |
| 3140 return renderer_preferences_.accept_languages; | |
| 3141 } | |
| 3142 | |
| 3137 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( | 3143 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
| 3138 WebFrame* frame, WebDataSource::ExtraData* extraData, | 3144 WebFrame* frame, WebDataSource::ExtraData* extraData, |
| 3139 const WebURLRequest& request, WebNavigationType type, | 3145 const WebURLRequest& request, WebNavigationType type, |
| 3140 WebNavigationPolicy default_policy, bool is_redirect) { | 3146 WebNavigationPolicy default_policy, bool is_redirect) { |
| 3141 if (request.url() != GURL(kSwappedOutURL) && | 3147 if (request.url() != GURL(kSwappedOutURL) && |
| 3142 GetContentClient()->renderer()->HandleNavigation(frame, request, type, | 3148 GetContentClient()->renderer()->HandleNavigation(frame, request, type, |
| 3143 default_policy, | 3149 default_policy, |
| 3144 is_redirect)) { | 3150 is_redirect)) { |
| 3145 return WebKit::WebNavigationPolicyIgnore; | 3151 return WebKit::WebNavigationPolicyIgnore; |
| 3146 } | 3152 } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3616 EqualsASCII(failed_request.httpMethod(), "POST")); | 3622 EqualsASCII(failed_request.httpMethod(), "POST")); |
| 3617 | 3623 |
| 3618 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; | 3624 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 3619 params.frame_id = frame->identifier(); | 3625 params.frame_id = frame->identifier(); |
| 3620 params.is_main_frame = !frame->parent(); | 3626 params.is_main_frame = !frame->parent(); |
| 3621 params.error_code = error.reason; | 3627 params.error_code = error.reason; |
| 3622 GetContentClient()->renderer()->GetNavigationErrorStrings( | 3628 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3623 frame, | 3629 frame, |
| 3624 failed_request, | 3630 failed_request, |
| 3625 error, | 3631 error, |
| 3632 renderer_preferences_.accept_languages, | |
| 3626 NULL, | 3633 NULL, |
| 3627 ¶ms.error_description); | 3634 ¶ms.error_description); |
| 3628 params.url = error.unreachableURL; | 3635 params.url = error.unreachableURL; |
| 3629 params.showing_repost_interstitial = show_repost_interstitial; | 3636 params.showing_repost_interstitial = show_repost_interstitial; |
| 3630 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( | 3637 Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
| 3631 routing_id_, params)); | 3638 routing_id_, params)); |
| 3632 | 3639 |
| 3633 // Don't display an error page if this is simply a cancelled load. Aside | 3640 // 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. | 3641 // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 3635 if (error.reason == net::ERR_ABORTED) | 3642 if (error.reason == net::ERR_ABORTED) |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3862 | 3869 |
| 3863 | 3870 |
| 3864 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); | 3871 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
| 3865 | 3872 |
| 3866 const WebURLRequest& failed_request = ds->request(); | 3873 const WebURLRequest& failed_request = ds->request(); |
| 3867 string16 error_description; | 3874 string16 error_description; |
| 3868 GetContentClient()->renderer()->GetNavigationErrorStrings( | 3875 GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3869 frame, | 3876 frame, |
| 3870 failed_request, | 3877 failed_request, |
| 3871 error, | 3878 error, |
| 3879 renderer_preferences_.accept_languages, | |
| 3872 NULL, | 3880 NULL, |
| 3873 &error_description); | 3881 &error_description); |
| 3874 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, | 3882 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
| 3875 frame->identifier(), | 3883 frame->identifier(), |
| 3876 failed_request.url(), | 3884 failed_request.url(), |
| 3877 !frame->parent(), | 3885 !frame->parent(), |
| 3878 error.reason, | 3886 error.reason, |
| 3879 error_description)); | 3887 error_description)); |
| 3880 } | 3888 } |
| 3881 | 3889 |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4558 if (!alternate_error_page_url_.is_valid()) | 4566 if (!alternate_error_page_url_.is_valid()) |
| 4559 return GURL(); | 4567 return GURL(); |
| 4560 | 4568 |
| 4561 // Strip query params from the failed URL. | 4569 // Strip query params from the failed URL. |
| 4562 GURL::Replacements remove_params; | 4570 GURL::Replacements remove_params; |
| 4563 remove_params.ClearUsername(); | 4571 remove_params.ClearUsername(); |
| 4564 remove_params.ClearPassword(); | 4572 remove_params.ClearPassword(); |
| 4565 remove_params.ClearQuery(); | 4573 remove_params.ClearQuery(); |
| 4566 remove_params.ClearRef(); | 4574 remove_params.ClearRef(); |
| 4567 const GURL url_to_send = failed_url.ReplaceComponents(remove_params); | 4575 const GURL url_to_send = failed_url.ReplaceComponents(remove_params); |
| 4568 std::string spec_to_send = url_to_send.spec(); | 4576 std::string spec_to_send = UTF16ToUTF8(net::FormatUrl(url_to_send, |
| 4577 renderer_preferences_.accept_languages, net::kFormatUrlOmitNothing, | |
| 4578 net::UnescapeRule::NORMAL, NULL, NULL, NULL)); | |
|
mmenke
2013/09/26 16:23:01
Believe this formatting violates the style guide.
mmenke
2013/09/26 16:23:01
I've reached out to the Link Doctor team to make s
mmenke
2013/09/26 18:28:22
After talking to the Link Doctor team, it looks li
yuusuke
2013/09/27 14:16:52
Done.
| |
| 4569 // Notify link doctor of the url truncation by sending of "?" at the end. | 4579 // Notify link doctor of the url truncation by sending of "?" at the end. |
| 4570 if (failed_url.has_query()) | 4580 if (failed_url.has_query()) |
| 4571 spec_to_send.append("?"); | 4581 spec_to_send.append("?"); |
| 4572 | 4582 |
| 4573 // Construct the query params to send to link doctor. | 4583 // Construct the query params to send to link doctor. |
| 4574 std::string params(alternate_error_page_url_.query()); | 4584 std::string params(alternate_error_page_url_.query()); |
| 4575 params.append("&url="); | 4585 params.append("&url="); |
| 4576 params.append(net::EscapeQueryParamValue(spec_to_send, true)); | 4586 params.append(net::EscapeQueryParamValue(spec_to_send, true)); |
| 4577 params.append("&sourceid=chrome"); | 4587 params.append("&sourceid=chrome"); |
| 4578 params.append("&error="); | 4588 params.append("&error="); |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6506 for (size_t i = 0; i < icon_urls.size(); i++) { | 6516 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6507 WebURL url = icon_urls[i].iconURL(); | 6517 WebURL url = icon_urls[i].iconURL(); |
| 6508 if (!url.isEmpty()) | 6518 if (!url.isEmpty()) |
| 6509 urls.push_back(FaviconURL(url, | 6519 urls.push_back(FaviconURL(url, |
| 6510 ToFaviconType(icon_urls[i].iconType()))); | 6520 ToFaviconType(icon_urls[i].iconType()))); |
| 6511 } | 6521 } |
| 6512 SendUpdateFaviconURL(urls); | 6522 SendUpdateFaviconURL(urls); |
| 6513 } | 6523 } |
| 6514 | 6524 |
| 6515 } // namespace content | 6525 } // namespace content |
| OLD | NEW |