| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/memory/scoped_handle.h" | 14 #include "base/memory/scoped_handle.h" |
| 14 #include "base/scoped_temp_dir.h" | |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "chrome/browser/extensions/crx_file.h" | 16 #include "chrome/browser/extensions/crx_file.h" |
| 17 #include "chrome/browser/extensions/extension_creator_filter.h" | 17 #include "chrome/browser/extensions/extension_creator_filter.h" |
| 18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/extensions/extension_file_util.h" | 19 #include "chrome/common/extensions/extension_file_util.h" |
| 20 #include "chrome/common/zip.h" | 20 #include "chrome/common/zip.h" |
| 21 #include "crypto/rsa_private_key.h" | 21 #include "crypto/rsa_private_key.h" |
| 22 #include "crypto/signature_creator.h" | 22 #include "crypto/signature_creator.h" |
| 23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 key_pair.reset(GenerateKey(output_private_key_path)); | 301 key_pair.reset(GenerateKey(output_private_key_path)); |
| 302 if (!key_pair.get()) | 302 if (!key_pair.get()) |
| 303 return false; | 303 return false; |
| 304 | 304 |
| 305 // Perform some extra validation by loading the extension. | 305 // Perform some extra validation by loading the extension. |
| 306 // TODO(aa): Can this go before creating the key pair? This would mean not | 306 // TODO(aa): Can this go before creating the key pair? This would mean not |
| 307 // passing ID into LoadExtension which seems OK. | 307 // passing ID into LoadExtension which seems OK. |
| 308 if (!ValidateManifest(extension_dir, key_pair.get(), run_flags)) | 308 if (!ValidateManifest(extension_dir, key_pair.get(), run_flags)) |
| 309 return false; | 309 return false; |
| 310 | 310 |
| 311 ScopedTempDir temp_dir; | 311 base::ScopedTempDir temp_dir; |
| 312 if (!temp_dir.CreateUniqueTempDir()) | 312 if (!temp_dir.CreateUniqueTempDir()) |
| 313 return false; | 313 return false; |
| 314 | 314 |
| 315 // Zip up the extension. | 315 // Zip up the extension. |
| 316 FilePath zip_path; | 316 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 file_util::Delete(zip_path, false); |
| 326 return result; | 326 return result; |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace extensions | 329 } // namespace extensions |
| OLD | NEW |