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

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

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Address comments from hidehiko@ 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 <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
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;
mmenke 2017/01/10 17:19:14 need to include <memory>
leonhsl(Using Gerrit) 2017/01/12 08:27:44 Done.
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
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 (auto it = response.corrections.begin(); it != response.corrections.end();
306 response.corrections.begin(); 305 ++it) {
307 it != response.corrections.end(); ++it) {
308 // Doesn't seem like a good idea to show these. 306 // Doesn't seem like a good idea to show these.
309 if ((*it)->is_porn || (*it)->is_soft_porn) 307 if ((*it)->is_porn || (*it)->is_soft_porn)
310 continue; 308 continue;
311 309
312 int tracking_id = it - response.corrections.begin(); 310 int tracking_id = it - response.corrections.begin();
313 311
314 if ((*it)->correction_type == "reloadPage") { 312 if ((*it)->correction_type == "reloadPage") {
315 params->suggest_reload = true; 313 params->suggest_reload = true;
316 params->reload_tracking_id = tracking_id; 314 params->reload_tracking_id = tracking_id;
317 continue; 315 continue;
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 committed_error_page_info_->error, 1044 committed_error_page_info_->error,
1047 *committed_error_page_info_->navigation_correction_params, 1045 *committed_error_page_info_->navigation_correction_params,
1048 *response, 1046 *response,
1049 *response->corrections[tracking_id]); 1047 *response->corrections[tracking_id]);
1050 delegate_->SendTrackingRequest( 1048 delegate_->SendTrackingRequest(
1051 committed_error_page_info_->navigation_correction_params->url, 1049 committed_error_page_info_->navigation_correction_params->url,
1052 request_body); 1050 request_body);
1053 } 1051 }
1054 1052
1055 } // namespace error_page 1053 } // 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