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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
18 #include "base/json/json_value_converter.h" | 18 #include "base/json/json_value_converter.h" |
19 #include "base/json/json_writer.h" | 19 #include "base/json/json_writer.h" |
20 #include "base/location.h" | 20 #include "base/location.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/scoped_vector.h" | |
24 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
25 #include "base/metrics/sparse_histogram.h" | 24 #include "base/metrics/sparse_histogram.h" |
26 #include "base/strings/string16.h" | 25 #include "base/strings/string16.h" |
27 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
28 #include "base/values.h" | 27 #include "base/values.h" |
29 #include "build/build_config.h" | 28 #include "build/build_config.h" |
30 #include "components/error_page/common/error_page_params.h" | 29 #include "components/error_page/common/error_page_params.h" |
31 #include "components/url_formatter/url_formatter.h" | 30 #include "components/url_formatter/url_formatter.h" |
32 #include "content/public/common/url_constants.h" | 31 #include "content/public/common/url_constants.h" |
33 #include "grit/components_strings.h" | 32 #include "grit/components_strings.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 std::string url_correction; | 95 std::string url_correction; |
97 std::string click_type; | 96 std::string click_type; |
98 std::string click_data; | 97 std::string click_data; |
99 bool is_porn; | 98 bool is_porn; |
100 bool is_soft_porn; | 99 bool is_soft_porn; |
101 }; | 100 }; |
102 | 101 |
103 struct NavigationCorrectionResponse { | 102 struct NavigationCorrectionResponse { |
104 std::string event_id; | 103 std::string event_id; |
105 std::string fingerprint; | 104 std::string fingerprint; |
106 ScopedVector<NavigationCorrection> corrections; | 105 std::vector<std::unique_ptr<NavigationCorrection>> corrections; |
107 | 106 |
108 static void RegisterJSONConverter( | 107 static void RegisterJSONConverter( |
109 base::JSONValueConverter<NavigationCorrectionResponse>* converter) { | 108 base::JSONValueConverter<NavigationCorrectionResponse>* converter) { |
110 converter->RegisterStringField("result.eventId", | 109 converter->RegisterStringField("result.eventId", |
111 &NavigationCorrectionResponse::event_id); | 110 &NavigationCorrectionResponse::event_id); |
112 converter->RegisterStringField("result.fingerprint", | 111 converter->RegisterStringField("result.fingerprint", |
113 &NavigationCorrectionResponse::fingerprint); | 112 &NavigationCorrectionResponse::fingerprint); |
114 converter->RegisterRepeatedMessage( | 113 converter->RegisterRepeatedMessage( |
115 "result.UrlCorrections", | 114 "result.UrlCorrections", |
116 &NavigationCorrectionResponse::corrections); | 115 &NavigationCorrectionResponse::corrections); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 const NetErrorHelperCore::NavigationCorrectionParams& correction_params, | 294 const NetErrorHelperCore::NavigationCorrectionParams& correction_params, |
296 bool is_rtl) { | 295 bool is_rtl) { |
297 // Version of URL for display in suggestions. It has to be sanitized first | 296 // Version of URL for display in suggestions. It has to be sanitized first |
298 // because any received suggestions will be relative to the sanitized URL. | 297 // because any received suggestions will be relative to the sanitized URL. |
299 base::string16 original_url_for_display = | 298 base::string16 original_url_for_display = |
300 FormatURLForDisplay(SanitizeURL(GURL(error.unreachableURL)), is_rtl); | 299 FormatURLForDisplay(SanitizeURL(GURL(error.unreachableURL)), is_rtl); |
301 | 300 |
302 std::unique_ptr<ErrorPageParams> params(new ErrorPageParams()); | 301 std::unique_ptr<ErrorPageParams> params(new ErrorPageParams()); |
303 params->override_suggestions.reset(new base::ListValue()); | 302 params->override_suggestions.reset(new base::ListValue()); |
304 std::unique_ptr<base::ListValue> parsed_corrections(new base::ListValue()); | 303 std::unique_ptr<base::ListValue> parsed_corrections(new base::ListValue()); |
305 for (ScopedVector<NavigationCorrection>::const_iterator it = | 304 for (std::vector<std::unique_ptr<NavigationCorrection>>::const_iterator it = |
Avi (use Gerrit)
2017/01/09 17:18:29
for (auto it = ...)?
leonhsl(Using Gerrit)
2017/01/10 04:39:36
Done.
| |
306 response.corrections.begin(); | 305 response.corrections.begin(); |
307 it != response.corrections.end(); ++it) { | 306 it != response.corrections.end(); ++it) { |
308 // Doesn't seem like a good idea to show these. | 307 // Doesn't seem like a good idea to show these. |
309 if ((*it)->is_porn || (*it)->is_soft_porn) | 308 if ((*it)->is_porn || (*it)->is_soft_porn) |
310 continue; | 309 continue; |
311 | 310 |
312 int tracking_id = it - response.corrections.begin(); | 311 int tracking_id = it - response.corrections.begin(); |
313 | 312 |
314 if ((*it)->correction_type == "reloadPage") { | 313 if ((*it)->correction_type == "reloadPage") { |
315 params->suggest_reload = true; | 314 params->suggest_reload = true; |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1046 committed_error_page_info_->error, | 1045 committed_error_page_info_->error, |
1047 *committed_error_page_info_->navigation_correction_params, | 1046 *committed_error_page_info_->navigation_correction_params, |
1048 *response, | 1047 *response, |
1049 *response->corrections[tracking_id]); | 1048 *response->corrections[tracking_id]); |
1050 delegate_->SendTrackingRequest( | 1049 delegate_->SendTrackingRequest( |
1051 committed_error_page_info_->navigation_correction_params->url, | 1050 committed_error_page_info_->navigation_correction_params->url, |
1052 request_body); | 1051 request_body); |
1053 } | 1052 } |
1054 | 1053 |
1055 } // namespace error_page | 1054 } // namespace error_page |
OLD | NEW |