| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/sandboxed_unpacker.h" | 5 #include "chrome/browser/extensions/sandboxed_unpacker.h" | 
| 6 | 6 | 
| 7 #include <set> | 7 #include <set> | 
| 8 | 8 | 
| 9 #include "base/base64.h" | 9 #include "base/base64.h" | 
| 10 #include "base/bind.h" | 10 #include "base/bind.h" | 
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 138   bool normalized = | 138   bool normalized = | 
| 139       file_util::NormalizeFilePath(temp_file, &normalized_temp_file); | 139       file_util::NormalizeFilePath(temp_file, &normalized_temp_file); | 
| 140   if (!normalized) { | 140   if (!normalized) { | 
| 141     // If |temp_file| contains a link, the sandbox will block al file system | 141     // If |temp_file| contains a link, the sandbox will block al file system | 
| 142     // operations, and the install will fail. | 142     // operations, and the install will fail. | 
| 143     LOG(ERROR) << temp_dir->value() << " seem to be on remote drive."; | 143     LOG(ERROR) << temp_dir->value() << " seem to be on remote drive."; | 
| 144   } else { | 144   } else { | 
| 145     *temp_dir = normalized_temp_file.DirName(); | 145     *temp_dir = normalized_temp_file.DirName(); | 
| 146   } | 146   } | 
| 147   // Clean up the temp file. | 147   // Clean up the temp file. | 
| 148   base::Delete(temp_file, false); | 148   base::DeleteFile(temp_file, false); | 
| 149 | 149 | 
| 150   return normalized; | 150   return normalized; | 
| 151 } | 151 } | 
| 152 | 152 | 
| 153 // This function tries to find a location for unpacking the extension archive | 153 // This function tries to find a location for unpacking the extension archive | 
| 154 // that is writable and does not lie on a shared drive so that the sandboxed | 154 // that is writable and does not lie on a shared drive so that the sandboxed | 
| 155 // unpacking process can write there. If no such location exists we can not | 155 // unpacking process can write there. If no such location exists we can not | 
| 156 // proceed and should fail. | 156 // proceed and should fail. | 
| 157 // The result will be written to |temp_dir|. The function will write to this | 157 // The result will be written to |temp_dir|. The function will write to this | 
| 158 // parameter even if it returns false. | 158 // parameter even if it returns false. | 
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 672     base::FilePath path = *it; | 672     base::FilePath path = *it; | 
| 673     if (path.IsAbsolute() || path.ReferencesParent()) { | 673     if (path.IsAbsolute() || path.ReferencesParent()) { | 
| 674       // Invalid path for browser image. | 674       // Invalid path for browser image. | 
| 675       ReportFailure( | 675       ReportFailure( | 
| 676           INVALID_PATH_FOR_BROWSER_IMAGE, | 676           INVALID_PATH_FOR_BROWSER_IMAGE, | 
| 677           l10n_util::GetStringFUTF16( | 677           l10n_util::GetStringFUTF16( | 
| 678               IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 678               IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 
| 679               ASCIIToUTF16("INVALID_PATH_FOR_BROWSER_IMAGE"))); | 679               ASCIIToUTF16("INVALID_PATH_FOR_BROWSER_IMAGE"))); | 
| 680       return false; | 680       return false; | 
| 681     } | 681     } | 
| 682     if (!base::Delete(extension_root_.Append(path), false)) { | 682     if (!base::DeleteFile(extension_root_.Append(path), false)) { | 
| 683       // Error removing old image file. | 683       // Error removing old image file. | 
| 684       ReportFailure( | 684       ReportFailure( | 
| 685           ERROR_REMOVING_OLD_IMAGE_FILE, | 685           ERROR_REMOVING_OLD_IMAGE_FILE, | 
| 686           l10n_util::GetStringFUTF16( | 686           l10n_util::GetStringFUTF16( | 
| 687               IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 687               IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 
| 688               ASCIIToUTF16("ERROR_REMOVING_OLD_IMAGE_FILE"))); | 688               ASCIIToUTF16("ERROR_REMOVING_OLD_IMAGE_FILE"))); | 
| 689       return false; | 689       return false; | 
| 690     } | 690     } | 
| 691   } | 691   } | 
| 692 | 692 | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 827 | 827 | 
| 828 void SandboxedUnpacker::Cleanup() { | 828 void SandboxedUnpacker::Cleanup() { | 
| 829   DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 829   DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 
| 830   if (!temp_dir_.Delete()) { | 830   if (!temp_dir_.Delete()) { | 
| 831     LOG(WARNING) << "Can not delete temp directory at " | 831     LOG(WARNING) << "Can not delete temp directory at " | 
| 832                  << temp_dir_.path().value(); | 832                  << temp_dir_.path().value(); | 
| 833   } | 833   } | 
| 834 } | 834 } | 
| 835 | 835 | 
| 836 }  // namespace extensions | 836 }  // namespace extensions | 
| OLD | NEW | 
|---|