| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 signature_creator->Final(signature); | 231 signature_creator->Final(signature); |
| 232 return true; | 232 return true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, | 235 bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, |
| 236 crypto::RSAPrivateKey* private_key, | 236 crypto::RSAPrivateKey* private_key, |
| 237 const std::vector<uint8>& signature, | 237 const std::vector<uint8>& signature, |
| 238 const base::FilePath& crx_path) { | 238 const base::FilePath& crx_path) { |
| 239 if (file_util::PathExists(crx_path)) | 239 if (file_util::PathExists(crx_path)) |
| 240 file_util::Delete(crx_path, false); | 240 base::Delete(crx_path, false); |
| 241 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); | 241 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); |
| 242 if (!crx_handle.get()) { | 242 if (!crx_handle.get()) { |
| 243 error_message_ = l10n_util::GetStringUTF8(IDS_EXTENSION_SHARING_VIOLATION); | 243 error_message_ = l10n_util::GetStringUTF8(IDS_EXTENSION_SHARING_VIOLATION); |
| 244 return false; | 244 return false; |
| 245 } | 245 } |
| 246 | 246 |
| 247 std::vector<uint8> public_key; | 247 std::vector<uint8> public_key; |
| 248 CHECK(private_key->ExportPublicKey(&public_key)); | 248 CHECK(private_key->ExportPublicKey(&public_key)); |
| 249 | 249 |
| 250 CrxFile::Error error; | 250 CrxFile::Error error; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // Zip up the extension. | 315 // Zip up the extension. |
| 316 base::FilePath zip_path; | 316 base::FilePath zip_path; |
| 317 std::vector<uint8> signature; | 317 std::vector<uint8> signature; |
| 318 bool result = false; | 318 bool result = false; |
| 319 if (CreateZip(extension_dir, temp_dir.path(), &zip_path) && | 319 if (CreateZip(extension_dir, temp_dir.path(), &zip_path) && |
| 320 SignZip(zip_path, key_pair.get(), &signature) && | 320 SignZip(zip_path, key_pair.get(), &signature) && |
| 321 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { | 321 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { |
| 322 result = true; | 322 result = true; |
| 323 } | 323 } |
| 324 | 324 |
| 325 file_util::Delete(zip_path, false); | 325 base::Delete(zip_path, false); |
| 326 return result; | 326 return result; |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace extensions | 329 } // namespace extensions |
| OLD | NEW |