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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/safe_browsing/incident_reporting/preference_validation_ delegate.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/preference_validation_ delegate.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/memory/ptr_util.h"
12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" 13 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
13 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_inc ident.h" 14 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_inc ident.h"
14 #include "chrome/common/safe_browsing/csd.pb.h" 15 #include "chrome/common/safe_browsing/csd.pb.h"
15 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" 16 #include "components/user_prefs/tracked/pref_hash_store_transaction.h"
16 #include "components/user_prefs/tracked/tracked_preference_helper.h" 17 #include "components/user_prefs/tracked/tracked_preference_helper.h"
17 18
18 namespace safe_browsing { 19 namespace safe_browsing {
19 20
20 namespace { 21 namespace {
21 22
(...skipping 14 matching lines...) Expand all
36 return TPIncident::UNTRUSTED_UNKNOWN_VALUE; 37 return TPIncident::UNTRUSTED_UNKNOWN_VALUE;
37 default: 38 default:
38 return TPIncident::UNKNOWN; 39 return TPIncident::UNKNOWN;
39 } 40 }
40 } 41 }
41 42
42 } // namespace 43 } // namespace
43 44
44 PreferenceValidationDelegate::PreferenceValidationDelegate( 45 PreferenceValidationDelegate::PreferenceValidationDelegate(
45 Profile* profile, 46 Profile* profile,
46 scoped_ptr<IncidentReceiver> incident_receiver) 47 std::unique_ptr<IncidentReceiver> incident_receiver)
47 : profile_(profile), incident_receiver_(std::move(incident_receiver)) {} 48 : profile_(profile), incident_receiver_(std::move(incident_receiver)) {}
48 49
49 PreferenceValidationDelegate::~PreferenceValidationDelegate() { 50 PreferenceValidationDelegate::~PreferenceValidationDelegate() {
50 } 51 }
51 52
52 void PreferenceValidationDelegate::OnAtomicPreferenceValidation( 53 void PreferenceValidationDelegate::OnAtomicPreferenceValidation(
53 const std::string& pref_path, 54 const std::string& pref_path,
54 const base::Value* value, 55 const base::Value* value,
55 PrefHashStoreTransaction::ValueState value_state, 56 PrefHashStoreTransaction::ValueState value_state,
56 bool is_personal) { 57 bool is_personal) {
57 TPIncident_ValueState proto_value_state = MapValueState(value_state); 58 TPIncident_ValueState proto_value_state = MapValueState(value_state);
58 if (proto_value_state != TPIncident::UNKNOWN) { 59 if (proto_value_state != TPIncident::UNKNOWN) {
59 scoped_ptr<TPIncident> incident( 60 std::unique_ptr<TPIncident> incident(
60 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); 61 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident());
61 incident->set_path(pref_path); 62 incident->set_path(pref_path);
62 if (!value || 63 if (!value ||
63 (!value->GetAsString(incident->mutable_atomic_value()) && 64 (!value->GetAsString(incident->mutable_atomic_value()) &&
64 !base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) { 65 !base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) {
65 incident->clear_atomic_value(); 66 incident->clear_atomic_value();
66 } 67 }
67 incident->set_value_state(proto_value_state); 68 incident->set_value_state(proto_value_state);
68 incident_receiver_->AddIncidentForProfile( 69 incident_receiver_->AddIncidentForProfile(
69 profile_, make_scoped_ptr(new TrackedPreferenceIncident( 70 profile_, base::WrapUnique(new TrackedPreferenceIncident(
70 std::move(incident), is_personal))); 71 std::move(incident), is_personal)));
71 } 72 }
72 } 73 }
73 74
74 void PreferenceValidationDelegate::OnSplitPreferenceValidation( 75 void PreferenceValidationDelegate::OnSplitPreferenceValidation(
75 const std::string& pref_path, 76 const std::string& pref_path,
76 const base::DictionaryValue* /* dict_value */, 77 const base::DictionaryValue* /* dict_value */,
77 const std::vector<std::string>& invalid_keys, 78 const std::vector<std::string>& invalid_keys,
78 PrefHashStoreTransaction::ValueState value_state, 79 PrefHashStoreTransaction::ValueState value_state,
79 bool is_personal) { 80 bool is_personal) {
80 TPIncident_ValueState proto_value_state = MapValueState(value_state); 81 TPIncident_ValueState proto_value_state = MapValueState(value_state);
81 if (proto_value_state != TPIncident::UNKNOWN) { 82 if (proto_value_state != TPIncident::UNKNOWN) {
82 scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident> 83 std::unique_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
83 incident( 84 incident(
84 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); 85 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident());
85 incident->set_path(pref_path); 86 incident->set_path(pref_path);
86 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin()); 87 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin());
87 scan != invalid_keys.end(); 88 scan != invalid_keys.end();
88 ++scan) { 89 ++scan) {
89 incident->add_split_key(*scan); 90 incident->add_split_key(*scan);
90 } 91 }
91 incident->set_value_state(proto_value_state); 92 incident->set_value_state(proto_value_state);
92 incident_receiver_->AddIncidentForProfile( 93 incident_receiver_->AddIncidentForProfile(
93 profile_, make_scoped_ptr(new TrackedPreferenceIncident( 94 profile_, base::WrapUnique(new TrackedPreferenceIncident(
94 std::move(incident), is_personal))); 95 std::move(incident), is_personal)));
95 } 96 }
96 } 97 }
97 98
98 } // namespace safe_browsing 99 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698