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/extensions/extension_creator.h" | 5 #include "chrome/browser/extensions/extension_creator.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" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 while ((bytes_read = fread(buffer.get(), 1, buffer_size, | 221 while ((bytes_read = fread(buffer.get(), 1, buffer_size, |
222 zip_handle.get())) > 0) { | 222 zip_handle.get())) > 0) { |
223 if (!signature_creator->Update(buffer.get(), bytes_read)) { | 223 if (!signature_creator->Update(buffer.get(), bytes_read)) { |
224 error_message_ = | 224 error_message_ = |
225 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING); | 225 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING); |
226 return false; | 226 return false; |
227 } | 227 } |
228 } | 228 } |
229 zip_handle.Close(); | 229 zip_handle.Close(); |
230 | 230 |
231 signature_creator->Final(signature); | 231 if (!signature_creator->Final(signature)) { |
| 232 error_message_ = |
| 233 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING); |
| 234 return false; |
| 235 } |
| 236 |
232 return true; | 237 return true; |
233 } | 238 } |
234 | 239 |
235 bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, | 240 bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, |
236 crypto::RSAPrivateKey* private_key, | 241 crypto::RSAPrivateKey* private_key, |
237 const std::vector<uint8>& signature, | 242 const std::vector<uint8>& signature, |
238 const base::FilePath& crx_path) { | 243 const base::FilePath& crx_path) { |
239 if (base::PathExists(crx_path)) | 244 if (base::PathExists(crx_path)) |
240 base::DeleteFile(crx_path, false); | 245 base::DeleteFile(crx_path, false); |
241 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); | 246 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 SignZip(zip_path, key_pair.get(), &signature) && | 325 SignZip(zip_path, key_pair.get(), &signature) && |
321 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { | 326 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { |
322 result = true; | 327 result = true; |
323 } | 328 } |
324 | 329 |
325 base::DeleteFile(zip_path, false); | 330 base::DeleteFile(zip_path, false); |
326 return result; | 331 return result; |
327 } | 332 } |
328 | 333 |
329 } // namespace extensions | 334 } // namespace extensions |
OLD | NEW |