OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 std::vector<base::FilePath> result; | 204 std::vector<base::FilePath> result; |
205 // Pattern matching only works at the root level, so filter manually. | 205 // Pattern matching only works at the root level, so filter manually. |
206 base::FileEnumerator traversal(extension_dir, /*recursive=*/true, | 206 base::FileEnumerator traversal(extension_dir, /*recursive=*/true, |
207 base::FileEnumerator::FILES); | 207 base::FileEnumerator::FILES); |
208 for (base::FilePath current = traversal.Next(); !current.empty(); | 208 for (base::FilePath current = traversal.Next(); !current.empty(); |
209 current = traversal.Next()) { | 209 current = traversal.Next()) { |
210 if (!current.MatchesExtension(extensions::kExtensionKeyFileExtension)) | 210 if (!current.MatchesExtension(extensions::kExtensionKeyFileExtension)) |
211 continue; | 211 continue; |
212 | 212 |
213 std::string key_contents; | 213 std::string key_contents; |
214 if (!file_util::ReadFileToString(current, &key_contents)) { | 214 if (!base::ReadFileToString(current, &key_contents)) { |
215 // If we can't read the file, assume it's not a private key. | 215 // If we can't read the file, assume it's not a private key. |
216 continue; | 216 continue; |
217 } | 217 } |
218 std::string key_bytes; | 218 std::string key_bytes; |
219 if (!Extension::ParsePEMKeyBytes(key_contents, &key_bytes)) { | 219 if (!Extension::ParsePEMKeyBytes(key_contents, &key_bytes)) { |
220 // If we can't parse the key, assume it's ok too. | 220 // If we can't parse the key, assume it's ok too. |
221 continue; | 221 continue; |
222 } | 222 } |
223 | 223 |
224 result.push_back(current); | 224 result.push_back(current); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 return base::FilePath(); | 566 return base::FilePath(); |
567 } | 567 } |
568 return temp_path; | 568 return temp_path; |
569 } | 569 } |
570 | 570 |
571 void DeleteFile(const base::FilePath& path, bool recursive) { | 571 void DeleteFile(const base::FilePath& path, bool recursive) { |
572 base::DeleteFile(path, recursive); | 572 base::DeleteFile(path, recursive); |
573 } | 573 } |
574 | 574 |
575 } // namespace extension_file_util | 575 } // namespace extension_file_util |
OLD | NEW |