OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 return true; | 185 return true; |
186 } | 186 } |
187 | 187 |
188 bool ExtensionCreator::WriteCRX(const FilePath& zip_path, | 188 bool ExtensionCreator::WriteCRX(const FilePath& zip_path, |
189 crypto::RSAPrivateKey* private_key, | 189 crypto::RSAPrivateKey* private_key, |
190 const std::vector<uint8>& signature, | 190 const std::vector<uint8>& signature, |
191 const FilePath& crx_path) { | 191 const FilePath& crx_path) { |
192 if (file_util::PathExists(crx_path)) | 192 if (file_util::PathExists(crx_path)) |
193 file_util::Delete(crx_path, false); | 193 file_util::Delete(crx_path, false); |
194 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); | 194 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); |
| 195 if (!crx_handle.get()) { |
| 196 error_message_ = l10n_util::GetStringUTF8(IDS_EXTENSION_SHARING_VIOLATION); |
| 197 return false; |
| 198 } |
195 | 199 |
196 std::vector<uint8> public_key; | 200 std::vector<uint8> public_key; |
197 if (!private_key->ExportPublicKey(&public_key)) { | 201 if (!private_key->ExportPublicKey(&public_key)) { |
198 error_message_ = | 202 error_message_ = |
199 l10n_util::GetStringUTF8(IDS_EXTENSION_PUBLIC_KEY_FAILED_TO_EXPORT); | 203 l10n_util::GetStringUTF8(IDS_EXTENSION_PUBLIC_KEY_FAILED_TO_EXPORT); |
200 return false; | 204 return false; |
201 } | 205 } |
202 | 206 |
203 SandboxedExtensionUnpacker::ExtensionHeader header; | 207 SandboxedExtensionUnpacker::ExtensionHeader header; |
204 memcpy(&header.magic, SandboxedExtensionUnpacker::kExtensionHeaderMagic, | 208 memcpy(&header.magic, SandboxedExtensionUnpacker::kExtensionHeaderMagic, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 bool result = false; | 268 bool result = false; |
265 if (CreateZip(extension_dir, temp_dir.path(), &zip_path) && | 269 if (CreateZip(extension_dir, temp_dir.path(), &zip_path) && |
266 SignZip(zip_path, key_pair.get(), &signature) && | 270 SignZip(zip_path, key_pair.get(), &signature) && |
267 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { | 271 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { |
268 result = true; | 272 result = true; |
269 } | 273 } |
270 | 274 |
271 file_util::Delete(zip_path, false); | 275 file_util::Delete(zip_path, false); |
272 return result; | 276 return result; |
273 } | 277 } |
OLD | NEW |