| 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" |
| 11 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_handle.h" | 13 #include "base/memory/scoped_handle.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/component_updater/component_patcher.h" | 17 #include "chrome/browser/component_updater/component_patcher.h" |
| 18 #include "chrome/browser/component_updater/component_updater_service.h" | 18 #include "chrome/browser/component_updater/component_updater_service.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "crypto/secure_hash.h" | 20 #include "crypto/secure_hash.h" |
| 21 #include "crypto/signature_verifier.h" | 21 #include "crypto/signature_verifier.h" |
| 22 #include "extensions/common/crx_file.h" | 22 #include "extensions/common/crx_file.h" |
| 23 #include "third_party/zlib/google/zip.h" | 23 #include "third_party/zlib/google/zip.h" |
| 24 | 24 |
| 25 using crypto::SecureHash; | 25 using crypto::SecureHash; |
| 26 | 26 |
| 27 namespace component_updater { |
| 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 // This class makes sure that the CRX digital signature is valid | 31 // This class makes sure that the CRX digital signature is valid |
| 30 // and well formed. | 32 // and well formed. |
| 31 class CRXValidator { | 33 class CRXValidator { |
| 32 public: | 34 public: |
| 33 explicit CRXValidator(FILE* crx_file) : valid_(false), delta_(false) { | 35 explicit CRXValidator(FILE* crx_file) : valid_(false), delta_(false) { |
| 34 extensions::CrxFile::Header header; | 36 extensions::CrxFile::Header header; |
| 35 size_t len = fread(&header, 1, sizeof(header), crx_file); | 37 size_t len = fread(&header, 1, sizeof(header), crx_file); |
| 36 if (len < sizeof(header)) | 38 if (len < sizeof(header)) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return; | 203 return; |
| 202 } | 204 } |
| 203 // Installation successful. The directory is not our concern now. | 205 // Installation successful. The directory is not our concern now. |
| 204 unpack_path_.clear(); | 206 unpack_path_.clear(); |
| 205 } | 207 } |
| 206 | 208 |
| 207 ComponentUnpacker::~ComponentUnpacker() { | 209 ComponentUnpacker::~ComponentUnpacker() { |
| 208 if (!unpack_path_.empty()) | 210 if (!unpack_path_.empty()) |
| 209 base::DeleteFile(unpack_path_, true); | 211 base::DeleteFile(unpack_path_, true); |
| 210 } | 212 } |
| 213 |
| 214 } // namespace component_updater |
| 215 |
| OLD | NEW |