| 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/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
| 14 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/component_updater/component_patcher.h" | 20 #include "chrome/browser/component_updater/component_patcher.h" |
| 21 #include "chrome/browser/component_updater/component_patcher_operation.h" |
| 21 #include "chrome/browser/component_updater/component_updater_service.h" | 22 #include "chrome/browser/component_updater/component_updater_service.h" |
| 22 #include "crypto/secure_hash.h" | 23 #include "crypto/secure_hash.h" |
| 23 #include "crypto/signature_verifier.h" | 24 #include "crypto/signature_verifier.h" |
| 24 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
| 25 #include "extensions/common/crx_file.h" | 26 #include "extensions/common/crx_file.h" |
| 26 #include "third_party/zlib/google/zip.h" | 27 #include "third_party/zlib/google/zip.h" |
| 27 | 28 |
| 28 using crypto::SecureHash; | 29 using crypto::SecureHash; |
| 29 | 30 |
| 30 namespace component_updater { | 31 namespace component_updater { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 std::vector<uint8> public_key_; | 95 std::vector<uint8> public_key_; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 } // namespace | 98 } // namespace |
| 98 | 99 |
| 99 ComponentUnpacker::ComponentUnpacker( | 100 ComponentUnpacker::ComponentUnpacker( |
| 100 const std::vector<uint8>& pk_hash, | 101 const std::vector<uint8>& pk_hash, |
| 101 const base::FilePath& path, | 102 const base::FilePath& path, |
| 102 const std::string& fingerprint, | 103 const std::string& fingerprint, |
| 103 ComponentInstaller* installer, | 104 ComponentInstaller* installer, |
| 104 bool in_process, | 105 DeltaUpdateOpFactory* delta_update_op_factory, |
| 105 scoped_refptr<base::SequencedTaskRunner> task_runner) | 106 scoped_refptr<base::SequencedTaskRunner> task_runner) |
| 106 : pk_hash_(pk_hash), | 107 : pk_hash_(pk_hash), |
| 107 path_(path), | 108 path_(path), |
| 108 is_delta_(false), | 109 is_delta_(false), |
| 109 fingerprint_(fingerprint), | 110 fingerprint_(fingerprint), |
| 110 installer_(installer), | 111 installer_(installer), |
| 111 in_process_(in_process), | 112 delta_update_op_factory_(delta_update_op_factory), |
| 112 error_(kNone), | 113 error_(kNone), |
| 113 extended_error_(0), | 114 extended_error_(0), |
| 114 task_runner_(task_runner) { | 115 task_runner_(task_runner) { |
| 115 } | 116 } |
| 116 | 117 |
| 117 // TODO(cpu): add a specific attribute check to a component json that the | 118 // TODO(cpu): add a specific attribute check to a component json that the |
| 118 // extension unpacker will reject, so that a component cannot be installed | 119 // extension unpacker will reject, so that a component cannot be installed |
| 119 // as an extension. | 120 // as an extension. |
| 120 scoped_ptr<base::DictionaryValue> ReadManifest( | 121 scoped_ptr<base::DictionaryValue> ReadManifest( |
| 121 const base::FilePath& unpack_path) { | 122 const base::FilePath& unpack_path) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (is_delta_) { // Package is a diff package. | 205 if (is_delta_) { // Package is a diff package. |
| 205 // Use a different temp directory for the patch output files. | 206 // Use a different temp directory for the patch output files. |
| 206 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), | 207 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), |
| 207 &unpack_path_)) { | 208 &unpack_path_)) { |
| 208 error_ = kUnzipPathError; | 209 error_ = kUnzipPathError; |
| 209 return false; | 210 return false; |
| 210 } | 211 } |
| 211 patcher_ = new ComponentPatcher(unpack_diff_path_, | 212 patcher_ = new ComponentPatcher(unpack_diff_path_, |
| 212 unpack_path_, | 213 unpack_path_, |
| 213 installer_, | 214 installer_, |
| 214 in_process_, | 215 delta_update_op_factory_.release(), |
| 215 task_runner_); | 216 task_runner_); |
| 216 task_runner_->PostTask( | 217 task_runner_->PostTask( |
| 217 FROM_HERE, | 218 FROM_HERE, |
| 218 base::Bind(&ComponentPatcher::Start, | 219 base::Bind(&ComponentPatcher::Start, |
| 219 patcher_, | 220 patcher_, |
| 220 base::Bind(&ComponentUnpacker::EndPatching, | 221 base::Bind(&ComponentUnpacker::EndPatching, |
| 221 scoped_refptr<ComponentUnpacker>(this)))); | 222 scoped_refptr<ComponentUnpacker>(this)))); |
| 222 } else { | 223 } else { |
| 223 task_runner_->PostTask(FROM_HERE, | 224 task_runner_->PostTask(FROM_HERE, |
| 224 base::Bind(&ComponentUnpacker::EndPatching, | 225 base::Bind(&ComponentUnpacker::EndPatching, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 base::DeleteFile(unpack_diff_path_, true); | 275 base::DeleteFile(unpack_diff_path_, true); |
| 275 if (!unpack_path_.empty()) | 276 if (!unpack_path_.empty()) |
| 276 base::DeleteFile(unpack_path_, true); | 277 base::DeleteFile(unpack_path_, true); |
| 277 callback_.Run(error_, extended_error_); | 278 callback_.Run(error_, extended_error_); |
| 278 } | 279 } |
| 279 | 280 |
| 280 ComponentUnpacker::~ComponentUnpacker() { | 281 ComponentUnpacker::~ComponentUnpacker() { |
| 281 } | 282 } |
| 282 | 283 |
| 283 } // namespace component_updater | 284 } // namespace component_updater |
| OLD | NEW |