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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 ComponentPatcher* patcher, | 115 ComponentPatcher* patcher, |
116 ComponentInstaller* installer) | 116 ComponentInstaller* installer) |
117 : error_(kNone), | 117 : error_(kNone), |
118 extended_error_(0) { | 118 extended_error_(0) { |
119 if (pk_hash.empty() || path.empty()) { | 119 if (pk_hash.empty() || path.empty()) { |
120 error_ = kInvalidParams; | 120 error_ = kInvalidParams; |
121 return; | 121 return; |
122 } | 122 } |
123 // First, validate the CRX header and signature. As of today | 123 // First, validate the CRX header and signature. As of today |
124 // this is SHA1 with RSA 1024. | 124 // this is SHA1 with RSA 1024. |
125 ScopedStdioHandle file(base::OpenFile(path, "rb")); | 125 ScopedStdioHandle file(file_util::OpenFile(path, "rb")); |
126 if (!file.get()) { | 126 if (!file.get()) { |
127 error_ = kInvalidFile; | 127 error_ = kInvalidFile; |
128 return; | 128 return; |
129 } | 129 } |
130 CRXValidator validator(file.get()); | 130 CRXValidator validator(file.get()); |
131 if (!validator.valid()) { | 131 if (!validator.valid()) { |
132 error_ = kInvalidFile; | 132 error_ = kInvalidFile; |
133 return; | 133 return; |
134 } | 134 } |
135 file.Close(); | 135 file.Close(); |
(...skipping 65 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 |