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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_mac.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 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/binary_integrity_analy zer_mac.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/mac/bundle_locations.h" 12 #include "base/mac/bundle_locations.h"
13 #include "base/memory/ptr_util.h"
13 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h" 14 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h"
14 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" 15 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
15 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h" 16 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h"
16 #include "chrome/common/safe_browsing/csd.pb.h" 17 #include "chrome/common/safe_browsing/csd.pb.h"
17 18
18 #define DEVELOPER_ID_APPLICATION_OID "field.1.2.840.113635.100.6.1.13" 19 #define DEVELOPER_ID_APPLICATION_OID "field.1.2.840.113635.100.6.1.13"
19 #define DEVELOPER_ID_INTERMEDIATE_OID "field.1.2.840.113635.100.6.2.6" 20 #define DEVELOPER_ID_INTERMEDIATE_OID "field.1.2.840.113635.100.6.2.6"
20 21
21 namespace safe_browsing { 22 namespace safe_browsing {
22 23
23 namespace { 24 namespace {
24 25
25 void VerifyBinaryIntegrityHelper(IncidentReceiver* incident_receiver, 26 void VerifyBinaryIntegrityHelper(IncidentReceiver* incident_receiver,
26 const base::FilePath& path, 27 const base::FilePath& path,
27 const std::string& requirement) { 28 const std::string& requirement) {
28 MacSignatureEvaluator evaluator(path, requirement); 29 MacSignatureEvaluator evaluator(path, requirement);
29 if (!evaluator.Initialize()) { 30 if (!evaluator.Initialize()) {
30 LOG(ERROR) << "Could not initialize mac signature evaluator"; 31 LOG(ERROR) << "Could not initialize mac signature evaluator";
31 return; 32 return;
32 } 33 }
33 34
34 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident> 35 std::unique_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>
35 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident()); 36 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident());
36 if (!evaluator.PerformEvaluation(incident.get())) { 37 if (!evaluator.PerformEvaluation(incident.get())) {
37 incident_receiver->AddIncidentForProcess( 38 incident_receiver->AddIncidentForProcess(
38 make_scoped_ptr(new BinaryIntegrityIncident(std::move(incident)))); 39 base::WrapUnique(new BinaryIntegrityIncident(std::move(incident))));
39 } else { 40 } else {
40 // Clear past incidents involving this bundle if the signature is 41 // Clear past incidents involving this bundle if the signature is
41 // now valid. 42 // now valid.
42 ClearBinaryIntegrityForFile(incident_receiver, path.BaseName().value()); 43 ClearBinaryIntegrityForFile(incident_receiver, path.BaseName().value());
43 } 44 }
44 } 45 }
45 46
46 } // namespace 47 } // namespace
47 48
48 std::vector<PathAndRequirement> GetCriticalPathsAndRequirements() { 49 std::vector<PathAndRequirement> GetCriticalPathsAndRequirements() {
(...skipping 13 matching lines...) Expand all
62 // TODO(kerrnel): eventually add Adobe Flash Player to this list. 63 // TODO(kerrnel): eventually add Adobe Flash Player to this list.
63 return critical_binaries; 64 return critical_binaries;
64 } 65 }
65 66
66 void VerifyBinaryIntegrityForTesting(IncidentReceiver* incident_receiver, 67 void VerifyBinaryIntegrityForTesting(IncidentReceiver* incident_receiver,
67 const base::FilePath& path, 68 const base::FilePath& path,
68 const std::string& requirement) { 69 const std::string& requirement) {
69 VerifyBinaryIntegrityHelper(incident_receiver, path, requirement); 70 VerifyBinaryIntegrityHelper(incident_receiver, path, requirement);
70 } 71 }
71 72
72 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) { 73 void VerifyBinaryIntegrity(
74 std::unique_ptr<IncidentReceiver> incident_receiver) {
73 size_t i = 0; 75 size_t i = 0;
74 for (const auto& p : GetCriticalPathsAndRequirements()) { 76 for (const auto& p : GetCriticalPathsAndRequirements()) {
75 base::TimeTicks time_before = base::TimeTicks::Now(); 77 base::TimeTicks time_before = base::TimeTicks::Now();
76 VerifyBinaryIntegrityHelper(incident_receiver.get(), p.path, p.requirement); 78 VerifyBinaryIntegrityHelper(incident_receiver.get(), p.path, p.requirement);
77 RecordSignatureVerificationTime(i++, base::TimeTicks::Now() - time_before); 79 RecordSignatureVerificationTime(i++, base::TimeTicks::Now() - time_before);
78 } 80 }
79 } 81 }
80 82
81 } // namespace 83 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698