OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/state_store.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/state_store.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (profile_) { | 86 if (profile_) { |
87 profile_ = nullptr; | 87 profile_ = nullptr; |
88 profile_manager_.DeleteTestingProfile(kProfileName_); | 88 profile_manager_.DeleteTestingProfile(kProfileName_); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 // Removes the safebrowsing.incidents_sent preference from the profile's pref | 92 // Removes the safebrowsing.incidents_sent preference from the profile's pref |
93 // store. | 93 // store. |
94 void TrimPref() { | 94 void TrimPref() { |
95 ASSERT_EQ(nullptr, profile_); | 95 ASSERT_EQ(nullptr, profile_); |
96 scoped_ptr<base::Value> prefs(JSONFileValueDeserializer(GetPrefsPath()) | 96 std::unique_ptr<base::Value> prefs(JSONFileValueDeserializer(GetPrefsPath()) |
97 .Deserialize(nullptr, nullptr)); | 97 .Deserialize(nullptr, nullptr)); |
98 ASSERT_NE(nullptr, prefs.get()); | 98 ASSERT_NE(nullptr, prefs.get()); |
99 base::DictionaryValue* dict = nullptr; | 99 base::DictionaryValue* dict = nullptr; |
100 ASSERT_TRUE(prefs->GetAsDictionary(&dict)); | 100 ASSERT_TRUE(prefs->GetAsDictionary(&dict)); |
101 ASSERT_TRUE(dict->Remove(prefs::kSafeBrowsingIncidentsSent, nullptr)); | 101 ASSERT_TRUE(dict->Remove(prefs::kSafeBrowsingIncidentsSent, nullptr)); |
102 ASSERT_TRUE(JSONFileValueSerializer(GetPrefsPath()).Serialize(*dict)); | 102 ASSERT_TRUE(JSONFileValueSerializer(GetPrefsPath()).Serialize(*dict)); |
103 } | 103 } |
104 | 104 |
105 void CreateProfile() { | 105 void CreateProfile() { |
106 ASSERT_EQ(nullptr, profile_); | 106 ASSERT_EQ(nullptr, profile_); |
107 // Create the testing profile with a file-backed user pref store. | 107 // Create the testing profile with a file-backed user pref store. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Verify that the state survived. | 270 // Verify that the state survived. |
271 ASSERT_TRUE(state_store.HasBeenReported(data.type, data.key, data.digest)); | 271 ASSERT_TRUE(state_store.HasBeenReported(data.type, data.key, data.digest)); |
272 #else | 272 #else |
273 // Verify that the state did not survive. | 273 // Verify that the state did not survive. |
274 ASSERT_FALSE(state_store.HasBeenReported(data.type, data.key, data.digest)); | 274 ASSERT_FALSE(state_store.HasBeenReported(data.type, data.key, data.digest)); |
275 #endif | 275 #endif |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 } // namespace safe_browsing | 279 } // namespace safe_browsing |
OLD | NEW |