OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sandboxed_extension_unpacker.h" | 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // Client takes ownership of temporary directory and extension. | 318 // Client takes ownership of temporary directory and extension. |
319 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, extension_); | 319 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, extension_); |
320 extension_ = NULL; | 320 extension_ = NULL; |
321 } | 321 } |
322 | 322 |
323 DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile( | 323 DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile( |
324 const DictionaryValue& manifest) { | 324 const DictionaryValue& manifest) { |
325 // Add the public key extracted earlier to the parsed manifest and overwrite | 325 // Add the public key extracted earlier to the parsed manifest and overwrite |
326 // the original manifest. We do this to ensure the manifest doesn't contain an | 326 // the original manifest. We do this to ensure the manifest doesn't contain an |
327 // exploitable bug that could be used to compromise the browser. | 327 // exploitable bug that could be used to compromise the browser. |
328 scoped_ptr<DictionaryValue> final_manifest( | 328 scoped_ptr<DictionaryValue> final_manifest(manifest.DeepCopy()); |
329 static_cast<DictionaryValue*>(manifest.DeepCopy())); | |
330 final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_); | 329 final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_); |
331 | 330 |
332 std::string manifest_json; | 331 std::string manifest_json; |
333 JSONStringValueSerializer serializer(&manifest_json); | 332 JSONStringValueSerializer serializer(&manifest_json); |
334 serializer.set_pretty_print(true); | 333 serializer.set_pretty_print(true); |
335 if (!serializer.Serialize(*final_manifest)) { | 334 if (!serializer.Serialize(*final_manifest)) { |
336 // Error serializing manifest.json. | 335 // Error serializing manifest.json. |
337 ReportFailure(l10n_util::GetStringFUTF8( | 336 ReportFailure(l10n_util::GetStringFUTF8( |
338 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 337 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
339 ASCIIToUTF16("ERROR_SERIALIZING_MANIFEST_JSON"))); | 338 ASCIIToUTF16("ERROR_SERIALIZING_MANIFEST_JSON"))); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // Error saving catalog. | 489 // Error saving catalog. |
491 ReportFailure(l10n_util::GetStringFUTF8( | 490 ReportFailure(l10n_util::GetStringFUTF8( |
492 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 491 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
493 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); | 492 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); |
494 return false; | 493 return false; |
495 } | 494 } |
496 } | 495 } |
497 | 496 |
498 return true; | 497 return true; |
499 } | 498 } |
OLD | NEW |