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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (browser_action && !browser_action->default_icon.empty()) | 322 if (browser_action && !browser_action->default_icon.empty()) |
323 AddPathsFromIconSet(browser_action->default_icon, &image_paths); | 323 AddPathsFromIconSet(browser_action->default_icon, &image_paths); |
324 | 324 |
325 return image_paths; | 325 return image_paths; |
326 } | 326 } |
327 | 327 |
328 void GarbageCollectExtensions( | 328 void GarbageCollectExtensions( |
329 const base::FilePath& install_directory, | 329 const base::FilePath& install_directory, |
330 const std::multimap<std::string, base::FilePath>& extension_paths) { | 330 const std::multimap<std::string, base::FilePath>& extension_paths) { |
331 // Nothing to clean up if it doesn't exist. | 331 // Nothing to clean up if it doesn't exist. |
332 if (!file_util::DirectoryExists(install_directory)) | 332 if (!base::DirectoryExists(install_directory)) |
333 return; | 333 return; |
334 | 334 |
335 DVLOG(1) << "Garbage collecting extensions..."; | 335 DVLOG(1) << "Garbage collecting extensions..."; |
336 base::FileEnumerator enumerator(install_directory, | 336 base::FileEnumerator enumerator(install_directory, |
337 false, // Not recursive. | 337 false, // Not recursive. |
338 base::FileEnumerator::DIRECTORIES); | 338 base::FileEnumerator::DIRECTORIES); |
339 base::FilePath extension_path; | 339 base::FilePath extension_path; |
340 for (extension_path = enumerator.Next(); !extension_path.value().empty(); | 340 for (extension_path = enumerator.Next(); !extension_path.value().empty(); |
341 extension_path = enumerator.Next()) { | 341 extension_path = enumerator.Next()) { |
342 std::string extension_id; | 342 std::string extension_id; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // Temp directory has never been used before, or in a rare error case. | 542 // Temp directory has never been used before, or in a rare error case. |
543 // Developers are not likely to see these situations often, so do an | 543 // Developers are not likely to see these situations often, so do an |
544 // explicit thread check. | 544 // explicit thread check. |
545 base::ThreadRestrictions::AssertIOAllowed(); | 545 base::ThreadRestrictions::AssertIOAllowed(); |
546 | 546 |
547 // Create the temp directory as a sub-directory of the Extensions directory. | 547 // Create the temp directory as a sub-directory of the Extensions directory. |
548 // This guarantees it is on the same file system as the extension's eventual | 548 // This guarantees it is on the same file system as the extension's eventual |
549 // install target. | 549 // install target. |
550 base::FilePath temp_path = extensions_dir.Append(kTempDirectoryName); | 550 base::FilePath temp_path = extensions_dir.Append(kTempDirectoryName); |
551 if (base::PathExists(temp_path)) { | 551 if (base::PathExists(temp_path)) { |
552 if (!file_util::DirectoryExists(temp_path)) { | 552 if (!base::DirectoryExists(temp_path)) { |
553 DLOG(WARNING) << "Not a directory: " << temp_path.value(); | 553 DLOG(WARNING) << "Not a directory: " << temp_path.value(); |
554 return base::FilePath(); | 554 return base::FilePath(); |
555 } | 555 } |
556 if (!file_util::PathIsWritable(temp_path)) { | 556 if (!base::PathIsWritable(temp_path)) { |
557 DLOG(WARNING) << "Can't write to path: " << temp_path.value(); | 557 DLOG(WARNING) << "Can't write to path: " << temp_path.value(); |
558 return base::FilePath(); | 558 return base::FilePath(); |
559 } | 559 } |
560 // This is a directory we can write to. | 560 // This is a directory we can write to. |
561 return temp_path; | 561 return temp_path; |
562 } | 562 } |
563 | 563 |
564 // Directory doesn't exist, so create it. | 564 // Directory doesn't exist, so create it. |
565 if (!file_util::CreateDirectory(temp_path)) { | 565 if (!file_util::CreateDirectory(temp_path)) { |
566 DLOG(WARNING) << "Couldn't create directory: " << temp_path.value(); | 566 DLOG(WARNING) << "Couldn't create directory: " << temp_path.value(); |
567 return base::FilePath(); | 567 return base::FilePath(); |
568 } | 568 } |
569 return temp_path; | 569 return temp_path; |
570 } | 570 } |
571 | 571 |
572 void DeleteFile(const base::FilePath& path, bool recursive) { | 572 void DeleteFile(const base::FilePath& path, bool recursive) { |
573 base::Delete(path, recursive); | 573 base::Delete(path, recursive); |
574 } | 574 } |
575 | 575 |
576 } // namespace extension_file_util | 576 } // namespace extension_file_util |
OLD | NEW |