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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.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/binary_integrity_analy zer_win.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer_win.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_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h" 17 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h"
17 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" 18 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
18 #include "chrome/common/chrome_version.h" 19 #include "chrome/common/chrome_version.h"
19 #include "chrome/common/safe_browsing/binary_feature_extractor.h" 20 #include "chrome/common/safe_browsing/binary_feature_extractor.h"
20 #include "chrome/common/safe_browsing/csd.pb.h" 21 #include "chrome/common/safe_browsing/csd.pb.h"
21 22
22 namespace safe_browsing { 23 namespace safe_browsing {
23 24
24 std::vector<base::FilePath> GetCriticalBinariesPath() { 25 std::vector<base::FilePath> GetCriticalBinariesPath() {
(...skipping 21 matching lines...) Expand all
46 47
47 base::FilePath version_dir( 48 base::FilePath version_dir(
48 chrome_exe_dir.AppendASCII(CHROME_VERSION_STRING)); 49 chrome_exe_dir.AppendASCII(CHROME_VERSION_STRING));
49 for (size_t i = 0; i < arraysize(kVersionedFiles); ++i) { 50 for (size_t i = 0; i < arraysize(kVersionedFiles); ++i) {
50 critical_binaries.push_back(version_dir.Append(kVersionedFiles[i])); 51 critical_binaries.push_back(version_dir.Append(kVersionedFiles[i]));
51 } 52 }
52 53
53 return critical_binaries; 54 return critical_binaries;
54 } 55 }
55 56
56 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) { 57 void VerifyBinaryIntegrity(
58 std::unique_ptr<IncidentReceiver> incident_receiver) {
57 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor( 59 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor(
58 new BinaryFeatureExtractor()); 60 new BinaryFeatureExtractor());
59 61
60 std::vector<base::FilePath> critical_binaries = GetCriticalBinariesPath(); 62 std::vector<base::FilePath> critical_binaries = GetCriticalBinariesPath();
61 for (size_t i = 0; i < critical_binaries.size(); ++i) { 63 for (size_t i = 0; i < critical_binaries.size(); ++i) {
62 base::FilePath binary_path(critical_binaries[i]); 64 base::FilePath binary_path(critical_binaries[i]);
63 if (!base::PathExists(binary_path)) 65 if (!base::PathExists(binary_path))
64 continue; 66 continue;
65 67
66 scoped_ptr<ClientDownloadRequest_SignatureInfo> signature_info( 68 std::unique_ptr<ClientDownloadRequest_SignatureInfo> signature_info(
67 new ClientDownloadRequest_SignatureInfo()); 69 new ClientDownloadRequest_SignatureInfo());
68 70
69 base::TimeTicks time_before = base::TimeTicks::Now(); 71 base::TimeTicks time_before = base::TimeTicks::Now();
70 binary_feature_extractor->CheckSignature(binary_path, signature_info.get()); 72 binary_feature_extractor->CheckSignature(binary_path, signature_info.get());
71 RecordSignatureVerificationTime(i, base::TimeTicks::Now() - time_before); 73 RecordSignatureVerificationTime(i, base::TimeTicks::Now() - time_before);
72 74
73 // Only create a report if the signature is untrusted. 75 // Only create a report if the signature is untrusted.
74 if (!signature_info->trusted()) { 76 if (!signature_info->trusted()) {
75 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident> 77 std::unique_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>
76 incident( 78 incident(
77 new ClientIncidentReport_IncidentData_BinaryIntegrityIncident()); 79 new ClientIncidentReport_IncidentData_BinaryIntegrityIncident());
78 80
79 incident->set_file_basename(binary_path.BaseName().AsUTF8Unsafe()); 81 incident->set_file_basename(binary_path.BaseName().AsUTF8Unsafe());
80 incident->set_allocated_signature(signature_info.release()); 82 incident->set_allocated_signature(signature_info.release());
81 83
82 // Send the report. 84 // Send the report.
83 incident_receiver->AddIncidentForProcess( 85 incident_receiver->AddIncidentForProcess(
84 make_scoped_ptr(new BinaryIntegrityIncident(std::move(incident)))); 86 base::WrapUnique(new BinaryIntegrityIncident(std::move(incident))));
85 } else { 87 } else {
86 // The binary is integral, remove previous report so that next incidents 88 // The binary is integral, remove previous report so that next incidents
87 // for the binary will be reported. 89 // for the binary will be reported.
88 ClearBinaryIntegrityForFile(incident_receiver.get(), 90 ClearBinaryIntegrityForFile(incident_receiver.get(),
89 binary_path.BaseName().AsUTF8Unsafe()); 91 binary_path.BaseName().AsUTF8Unsafe());
90 } 92 }
91 } 93 }
92 } 94 }
93 95
94 } // namespace safe_browsing 96 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698