| 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/component_updater/component_unpacker.h" | 5 #include "chrome/browser/component_updater/component_unpacker.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // trust this CRX. | 139 // trust this CRX. |
| 140 uint8 hash[32]; | 140 uint8 hash[32]; |
| 141 scoped_ptr<SecureHash> sha256(SecureHash::Create(SecureHash::SHA256)); | 141 scoped_ptr<SecureHash> sha256(SecureHash::Create(SecureHash::SHA256)); |
| 142 sha256->Update(&(validator.public_key()[0]), validator.public_key().size()); | 142 sha256->Update(&(validator.public_key()[0]), validator.public_key().size()); |
| 143 sha256->Finish(hash, arraysize(hash)); | 143 sha256->Finish(hash, arraysize(hash)); |
| 144 | 144 |
| 145 if (!std::equal(pk_hash.begin(), pk_hash.end(), hash)) { | 145 if (!std::equal(pk_hash.begin(), pk_hash.end(), hash)) { |
| 146 error_ = kInvalidId; | 146 error_ = kInvalidId; |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), | 149 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), |
| 150 &unpack_path_)) { | 150 &unpack_path_)) { |
| 151 error_ = kUnzipPathError; | 151 error_ = kUnzipPathError; |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 if (validator.delta()) { // Package is a diff package. | 154 if (validator.delta()) { // Package is a diff package. |
| 155 // We want a different temp directory for the delta files; we'll put the | 155 // We want a different temp directory for the delta files; we'll put the |
| 156 // patch output into unpack_path_. | 156 // patch output into unpack_path_. |
| 157 base::FilePath unpack_diff_path; | 157 base::FilePath unpack_diff_path; |
| 158 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), | 158 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), |
| 159 &unpack_diff_path)) { | 159 &unpack_diff_path)) { |
| 160 error_ = kUnzipPathError; | 160 error_ = kUnzipPathError; |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 if (!zip::Unzip(path, unpack_diff_path)) { | 163 if (!zip::Unzip(path, unpack_diff_path)) { |
| 164 error_ = kUnzipFailed; | 164 error_ = kUnzipFailed; |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 ComponentUnpacker::Error result = DifferentialUpdatePatch(unpack_diff_path, | 167 ComponentUnpacker::Error result = DifferentialUpdatePatch(unpack_diff_path, |
| 168 unpack_path_, | 168 unpack_path_, |
| 169 patcher, | 169 patcher, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 // Installation successful. The directory is not our concern now. | 203 // Installation successful. The directory is not our concern now. |
| 204 unpack_path_.clear(); | 204 unpack_path_.clear(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 ComponentUnpacker::~ComponentUnpacker() { | 207 ComponentUnpacker::~ComponentUnpacker() { |
| 208 if (!unpack_path_.empty()) | 208 if (!unpack_path_.empty()) |
| 209 base::DeleteFile(unpack_path_, true); | 209 base::DeleteFile(unpack_path_, true); |
| 210 } | 210 } |
| OLD | NEW |