| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/error_page/renderer/net_error_helper_core.h" | 5 #include "components/error_page/renderer/net_error_helper_core.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 15 #include "base/json/json_value_converter.h" | 15 #include "base/json/json_value_converter.h" |
| 16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
| 20 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
| 21 #include "base/metrics/sparse_histogram.h" | 21 #include "base/metrics/sparse_histogram.h" |
| 22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "components/error_page/common/error_page_params.h" | 25 #include "components/error_page/common/error_page_params.h" |
| 26 #include "components/url_formatter/url_formatter.h" |
| 26 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 27 #include "grit/components_strings.h" | 28 #include "grit/components_strings.h" |
| 28 #include "net/base/escape.h" | 29 #include "net/base/escape.h" |
| 29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 30 #include "net/base/net_util.h" | |
| 31 #include "third_party/WebKit/public/platform/WebString.h" | 31 #include "third_party/WebKit/public/platform/WebString.h" |
| 32 #include "third_party/WebKit/public/platform/WebURLError.h" | 32 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 35 #include "url/url_constants.h" | 35 #include "url/url_constants.h" |
| 36 | 36 |
| 37 namespace error_page { | 37 namespace error_page { |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 GURL::Replacements remove_params; | 139 GURL::Replacements remove_params; |
| 140 remove_params.ClearUsername(); | 140 remove_params.ClearUsername(); |
| 141 remove_params.ClearPassword(); | 141 remove_params.ClearPassword(); |
| 142 remove_params.ClearQuery(); | 142 remove_params.ClearQuery(); |
| 143 remove_params.ClearRef(); | 143 remove_params.ClearRef(); |
| 144 return url.ReplaceComponents(remove_params); | 144 return url.ReplaceComponents(remove_params); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Sanitizes and formats a URL for upload to the error correction service. | 147 // Sanitizes and formats a URL for upload to the error correction service. |
| 148 std::string PrepareUrlForUpload(const GURL& url) { | 148 std::string PrepareUrlForUpload(const GURL& url) { |
| 149 // TODO(yuusuke): Change to net::FormatUrl when Link Doctor becomes | 149 // TODO(yuusuke): Change to url_formatter::FormatUrl when Link Doctor becomes |
| 150 // unicode-capable. | 150 // unicode-capable. |
| 151 std::string spec_to_send = SanitizeURL(url).spec(); | 151 std::string spec_to_send = SanitizeURL(url).spec(); |
| 152 | 152 |
| 153 // Notify navigation correction service of the url truncation by sending of | 153 // Notify navigation correction service of the url truncation by sending of |
| 154 // "?" at the end. | 154 // "?" at the end. |
| 155 if (url.has_query()) | 155 if (url.has_query()) |
| 156 spec_to_send.append("?"); | 156 spec_to_send.append("?"); |
| 157 return spec_to_send; | 157 return spec_to_send; |
| 158 } | 158 } |
| 159 | 159 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 params->SetString("eventId", response.event_id); | 258 params->SetString("eventId", response.event_id); |
| 259 params->SetString("fingerprint", response.fingerprint); | 259 params->SetString("fingerprint", response.fingerprint); |
| 260 | 260 |
| 261 return CreateRequestBody("linkdoctor.fixurl.clicktracking", error_param, | 261 return CreateRequestBody("linkdoctor.fixurl.clicktracking", error_param, |
| 262 correction_params, params.Pass()); | 262 correction_params, params.Pass()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 base::string16 FormatURLForDisplay(const GURL& url, bool is_rtl, | 265 base::string16 FormatURLForDisplay(const GURL& url, bool is_rtl, |
| 266 const std::string accept_languages) { | 266 const std::string accept_languages) { |
| 267 // Translate punycode into UTF8, unescape UTF8 URLs. | 267 // Translate punycode into UTF8, unescape UTF8 URLs. |
| 268 base::string16 url_for_display(net::FormatUrl( | 268 base::string16 url_for_display(url_formatter::FormatUrl( |
| 269 url, accept_languages, net::kFormatUrlOmitNothing, | 269 url, accept_languages, url_formatter::kFormatUrlOmitNothing, |
| 270 net::UnescapeRule::NORMAL, NULL, NULL, NULL)); | 270 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr)); |
| 271 // URLs are always LTR. | 271 // URLs are always LTR. |
| 272 if (is_rtl) | 272 if (is_rtl) |
| 273 base::i18n::WrapStringWithLTRFormatting(&url_for_display); | 273 base::i18n::WrapStringWithLTRFormatting(&url_for_display); |
| 274 return url_for_display; | 274 return url_for_display; |
| 275 } | 275 } |
| 276 | 276 |
| 277 scoped_ptr<NavigationCorrectionResponse> ParseNavigationCorrectionResponse( | 277 scoped_ptr<NavigationCorrectionResponse> ParseNavigationCorrectionResponse( |
| 278 const std::string raw_response) { | 278 const std::string raw_response) { |
| 279 // TODO(mmenke): Open source related protocol buffers and use them directly. | 279 // TODO(mmenke): Open source related protocol buffers and use them directly. |
| 280 scoped_ptr<base::Value> parsed = base::JSONReader::Read(raw_response); | 280 scoped_ptr<base::Value> parsed = base::JSONReader::Read(raw_response); |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 committed_error_page_info_->error, | 1043 committed_error_page_info_->error, |
| 1044 *committed_error_page_info_->navigation_correction_params, | 1044 *committed_error_page_info_->navigation_correction_params, |
| 1045 *response, | 1045 *response, |
| 1046 *response->corrections[tracking_id]); | 1046 *response->corrections[tracking_id]); |
| 1047 delegate_->SendTrackingRequest( | 1047 delegate_->SendTrackingRequest( |
| 1048 committed_error_page_info_->navigation_correction_params->url, | 1048 committed_error_page_info_->navigation_correction_params->url, |
| 1049 request_body); | 1049 request_body); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 } // namespace error_page | 1052 } // namespace error_page |
| OLD | NEW |