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

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

Issue 891793002: Take a Profile when adding an incident to the incident reporting service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment and formatting Created 5 years, 10 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 <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 23 matching lines...) Expand all
34 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: 34 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE:
35 return TPIncident::UNTRUSTED_UNKNOWN_VALUE; 35 return TPIncident::UNTRUSTED_UNKNOWN_VALUE;
36 default: 36 default:
37 return TPIncident::UNKNOWN; 37 return TPIncident::UNKNOWN;
38 } 38 }
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 PreferenceValidationDelegate::PreferenceValidationDelegate( 43 PreferenceValidationDelegate::PreferenceValidationDelegate(
44 Profile* profile,
44 const AddIncidentCallback& add_incident) 45 const AddIncidentCallback& add_incident)
45 : add_incident_(add_incident) { 46 : profile_(profile),
47 add_incident_(add_incident) {
46 } 48 }
47 49
48 PreferenceValidationDelegate::~PreferenceValidationDelegate() { 50 PreferenceValidationDelegate::~PreferenceValidationDelegate() {
49 } 51 }
50 52
51 void PreferenceValidationDelegate::OnAtomicPreferenceValidation( 53 void PreferenceValidationDelegate::OnAtomicPreferenceValidation(
52 const std::string& pref_path, 54 const std::string& pref_path,
53 const base::Value* value, 55 const base::Value* value,
54 PrefHashStoreTransaction::ValueState value_state, 56 PrefHashStoreTransaction::ValueState value_state,
55 bool is_personal) { 57 bool is_personal) {
56 TPIncident_ValueState proto_value_state = MapValueState(value_state); 58 TPIncident_ValueState proto_value_state = MapValueState(value_state);
57 if (proto_value_state != TPIncident::UNKNOWN) { 59 if (proto_value_state != TPIncident::UNKNOWN) {
58 scoped_ptr<TPIncident> incident( 60 scoped_ptr<TPIncident> incident(
59 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); 61 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident());
60 incident->set_path(pref_path); 62 incident->set_path(pref_path);
61 if (!value || 63 if (!value ||
62 (!value->GetAsString(incident->mutable_atomic_value()) && 64 (!value->GetAsString(incident->mutable_atomic_value()) &&
63 !base::JSONWriter::Write(value, incident->mutable_atomic_value()))) { 65 !base::JSONWriter::Write(value, incident->mutable_atomic_value()))) {
64 incident->clear_atomic_value(); 66 incident->clear_atomic_value();
65 } 67 }
66 incident->set_value_state(proto_value_state); 68 incident->set_value_state(proto_value_state);
67 add_incident_.Run(make_scoped_ptr( 69 add_incident_.Run(profile_, make_scoped_ptr(new TrackedPreferenceIncident(
68 new TrackedPreferenceIncident(incident.Pass(), is_personal))); 70 incident.Pass(), is_personal)));
69 } 71 }
70 } 72 }
71 73
72 void PreferenceValidationDelegate::OnSplitPreferenceValidation( 74 void PreferenceValidationDelegate::OnSplitPreferenceValidation(
73 const std::string& pref_path, 75 const std::string& pref_path,
74 const base::DictionaryValue* /* dict_value */, 76 const base::DictionaryValue* /* dict_value */,
75 const std::vector<std::string>& invalid_keys, 77 const std::vector<std::string>& invalid_keys,
76 PrefHashStoreTransaction::ValueState value_state, 78 PrefHashStoreTransaction::ValueState value_state,
77 bool is_personal) { 79 bool is_personal) {
78 TPIncident_ValueState proto_value_state = MapValueState(value_state); 80 TPIncident_ValueState proto_value_state = MapValueState(value_state);
79 if (proto_value_state != TPIncident::UNKNOWN) { 81 if (proto_value_state != TPIncident::UNKNOWN) {
80 scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident> 82 scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
81 incident( 83 incident(
82 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); 84 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident());
83 incident->set_path(pref_path); 85 incident->set_path(pref_path);
84 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin()); 86 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin());
85 scan != invalid_keys.end(); 87 scan != invalid_keys.end();
86 ++scan) { 88 ++scan) {
87 incident->add_split_key(*scan); 89 incident->add_split_key(*scan);
88 } 90 }
89 incident->set_value_state(proto_value_state); 91 incident->set_value_state(proto_value_state);
90 add_incident_.Run(make_scoped_ptr( 92 add_incident_.Run(profile_, make_scoped_ptr(new TrackedPreferenceIncident(
91 new TrackedPreferenceIncident(incident.Pass(), is_personal))); 93 incident.Pass(), is_personal)));
92 } 94 }
93 } 95 }
94 96
95 } // namespace safe_browsing 97 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698