Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: chrome/browser/component_updater/component_unpacker.cc

Issue 10683003: Moved CrxInstaller and CrxInstallerError into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest-er master Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/scoped_handle.h" 12 #include "base/memory/scoped_handle.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "chrome/browser/component_updater/component_updater_service.h" 15 #include "chrome/browser/component_updater/component_updater_service.h"
16 #include "chrome/browser/extensions/crx_file.h" 16 #include "chrome/browser/extensions/crx_file.h"
17 #include "chrome/common/extensions/extension_constants.h" 17 #include "chrome/common/extensions/extension_constants.h"
18 #include "chrome/common/zip.h" 18 #include "chrome/common/zip.h"
19 #include "crypto/secure_hash.h" 19 #include "crypto/secure_hash.h"
20 #include "crypto/signature_verifier.h" 20 #include "crypto/signature_verifier.h"
21 21
22 using crypto::SecureHash; 22 using crypto::SecureHash;
23 23
24 namespace { 24 namespace {
25 // This class makes sure that the CRX digital signature is valid 25 // This class makes sure that the CRX digital signature is valid
26 // and well formed. 26 // and well formed.
27 class CRXValidator { 27 class CRXValidator {
28 public: 28 public:
29 explicit CRXValidator(FILE* crx_file) : valid_(false) { 29 explicit CRXValidator(FILE* crx_file) : valid_(false) {
30 CrxFile::Header header; 30 extensions::CrxFile::Header header;
31 size_t len = fread(&header, 1, sizeof(header), crx_file); 31 size_t len = fread(&header, 1, sizeof(header), crx_file);
32 if (len < sizeof(header)) 32 if (len < sizeof(header))
33 return; 33 return;
34 34
35 CrxFile::Error error; 35 extensions::CrxFile::Error error;
36 scoped_ptr<CrxFile> crx(CrxFile::Parse(header, &error)); 36 scoped_ptr<extensions::CrxFile> crx(
37 extensions::CrxFile::Parse(header, &error));
37 if (!crx.get()) 38 if (!crx.get())
38 return; 39 return;
39 40
40 std::vector<uint8> key(header.key_size); 41 std::vector<uint8> key(header.key_size);
41 len = fread(&key[0], sizeof(uint8), header.key_size, crx_file); 42 len = fread(&key[0], sizeof(uint8), header.key_size, crx_file);
42 if (len < header.key_size) 43 if (len < header.key_size)
43 return; 44 return;
44 45
45 std::vector<uint8> signature(header.signature_size); 46 std::vector<uint8> signature(header.signature_size);
46 len = fread(&signature[0], sizeof(uint8), header.signature_size, crx_file); 47 len = fread(&signature[0], sizeof(uint8), header.signature_size, crx_file);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 164 }
164 // Installation successful. The directory is not our concern now. 165 // Installation successful. The directory is not our concern now.
165 unpack_path_.clear(); 166 unpack_path_.clear();
166 } 167 }
167 168
168 ComponentUnpacker::~ComponentUnpacker() { 169 ComponentUnpacker::~ComponentUnpacker() {
169 if (!unpack_path_.empty()) { 170 if (!unpack_path_.empty()) {
170 file_util::Delete(unpack_path_, true); 171 file_util::Delete(unpack_path_, true);
171 } 172 }
172 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager_util.cc ('k') | chrome/browser/download/chrome_download_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698