Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: components/error_page/renderer/net_error_helper_core.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Rebase and address comments from mmenke@ Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/drive/service/fake_drive_service.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
11 #include <utility> 12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/bind.h" 15 #include "base/bind.h"
15 #include "base/callback.h" 16 #include "base/callback.h"
16 #include "base/i18n/rtl.h" 17 #include "base/i18n/rtl.h"
17 #include "base/json/json_reader.h" 18 #include "base/json/json_reader.h"
18 #include "base/json/json_value_converter.h" 19 #include "base/json/json_value_converter.h"
19 #include "base/json/json_writer.h" 20 #include "base/json/json_writer.h"
20 #include "base/location.h" 21 #include "base/location.h"
21 #include "base/logging.h" 22 #include "base/logging.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/memory/scoped_vector.h"
24 #include "base/metrics/histogram_macros.h" 24 #include "base/metrics/histogram_macros.h"
25 #include "base/metrics/sparse_histogram.h" 25 #include "base/metrics/sparse_histogram.h"
26 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/values.h" 28 #include "base/values.h"
29 #include "build/build_config.h" 29 #include "build/build_config.h"
30 #include "components/error_page/common/error_page_params.h" 30 #include "components/error_page/common/error_page_params.h"
31 #include "components/url_formatter/url_formatter.h" 31 #include "components/url_formatter/url_formatter.h"
32 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
33 #include "grit/components_strings.h" 33 #include "grit/components_strings.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 std::string url_correction; 96 std::string url_correction;
97 std::string click_type; 97 std::string click_type;
98 std::string click_data; 98 std::string click_data;
99 bool is_porn; 99 bool is_porn;
100 bool is_soft_porn; 100 bool is_soft_porn;
101 }; 101 };
102 102
103 struct NavigationCorrectionResponse { 103 struct NavigationCorrectionResponse {
104 std::string event_id; 104 std::string event_id;
105 std::string fingerprint; 105 std::string fingerprint;
106 ScopedVector<NavigationCorrection> corrections; 106 std::vector<std::unique_ptr<NavigationCorrection>> corrections;
107 107
108 static void RegisterJSONConverter( 108 static void RegisterJSONConverter(
109 base::JSONValueConverter<NavigationCorrectionResponse>* converter) { 109 base::JSONValueConverter<NavigationCorrectionResponse>* converter) {
110 converter->RegisterStringField("result.eventId", 110 converter->RegisterStringField("result.eventId",
111 &NavigationCorrectionResponse::event_id); 111 &NavigationCorrectionResponse::event_id);
112 converter->RegisterStringField("result.fingerprint", 112 converter->RegisterStringField("result.fingerprint",
113 &NavigationCorrectionResponse::fingerprint); 113 &NavigationCorrectionResponse::fingerprint);
114 converter->RegisterRepeatedMessage( 114 converter->RegisterRepeatedMessage(
115 "result.UrlCorrections", 115 "result.UrlCorrections",
116 &NavigationCorrectionResponse::corrections); 116 &NavigationCorrectionResponse::corrections);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 const NetErrorHelperCore::NavigationCorrectionParams& correction_params, 295 const NetErrorHelperCore::NavigationCorrectionParams& correction_params,
296 bool is_rtl) { 296 bool is_rtl) {
297 // Version of URL for display in suggestions. It has to be sanitized first 297 // 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. 298 // because any received suggestions will be relative to the sanitized URL.
299 base::string16 original_url_for_display = 299 base::string16 original_url_for_display =
300 FormatURLForDisplay(SanitizeURL(GURL(error.unreachableURL)), is_rtl); 300 FormatURLForDisplay(SanitizeURL(GURL(error.unreachableURL)), is_rtl);
301 301
302 std::unique_ptr<ErrorPageParams> params(new ErrorPageParams()); 302 std::unique_ptr<ErrorPageParams> params(new ErrorPageParams());
303 params->override_suggestions.reset(new base::ListValue()); 303 params->override_suggestions.reset(new base::ListValue());
304 std::unique_ptr<base::ListValue> parsed_corrections(new base::ListValue()); 304 std::unique_ptr<base::ListValue> parsed_corrections(new base::ListValue());
305 for (ScopedVector<NavigationCorrection>::const_iterator it = 305 for (auto it = response.corrections.begin(); it != response.corrections.end();
306 response.corrections.begin(); 306 ++it) {
307 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;
316 params->reload_tracking_id = tracking_id; 315 params->reload_tracking_id = tracking_id;
317 continue; 316 continue;
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 committed_error_page_info_->error, 1048 committed_error_page_info_->error,
1050 *committed_error_page_info_->navigation_correction_params, 1049 *committed_error_page_info_->navigation_correction_params,
1051 *response, 1050 *response,
1052 *response->corrections[tracking_id]); 1051 *response->corrections[tracking_id]);
1053 delegate_->SendTrackingRequest( 1052 delegate_->SendTrackingRequest(
1054 committed_error_page_info_->navigation_correction_params->url, 1053 committed_error_page_info_->navigation_correction_params->url,
1055 request_body); 1054 request_body);
1056 } 1055 }
1057 1056
1058 } // namespace error_page 1057 } // namespace error_page
OLDNEW
« no previous file with comments | « components/drive/service/fake_drive_service.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698