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 "extensions/browser/sandboxed_unpacker.h" | 5 #include "extensions/browser/sandboxed_unpacker.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 ReportFailure(UNZIP_FAILED, | 424 ReportFailure(UNZIP_FAILED, |
425 l10n_util::GetStringUTF16(IDS_EXTENSION_PACKAGE_UNZIP_ERROR)); | 425 l10n_util::GetStringUTF16(IDS_EXTENSION_PACKAGE_UNZIP_ERROR)); |
426 } | 426 } |
427 | 427 |
428 void SandboxedUnpacker::OnUnpackExtensionSucceeded( | 428 void SandboxedUnpacker::OnUnpackExtensionSucceeded( |
429 const base::DictionaryValue& manifest) { | 429 const base::DictionaryValue& manifest) { |
430 CHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 430 CHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); |
431 got_response_ = true; | 431 got_response_ = true; |
432 utility_wrapper_ = nullptr; | 432 utility_wrapper_ = nullptr; |
433 | 433 |
434 scoped_ptr<base::DictionaryValue> final_manifest( | 434 std::unique_ptr<base::DictionaryValue> final_manifest( |
435 RewriteManifestFile(manifest)); | 435 RewriteManifestFile(manifest)); |
436 if (!final_manifest) | 436 if (!final_manifest) |
437 return; | 437 return; |
438 | 438 |
439 // Create an extension object that refers to the temporary location the | 439 // Create an extension object that refers to the temporary location the |
440 // extension was unpacked to. We use this until the extension is finally | 440 // extension was unpacked to. We use this until the extension is finally |
441 // installed. For example, the install UI shows images from inside the | 441 // installed. For example, the install UI shows images from inside the |
442 // extension. | 442 // extension. |
443 | 443 |
444 // Localize manifest now, so confirm UI gets correct extension name. | 444 // Localize manifest now, so confirm UI gets correct extension name. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 &original_manifest, extension_.get(), install_icon); | 676 &original_manifest, extension_.get(), install_icon); |
677 extension_ = NULL; | 677 extension_ = NULL; |
678 } | 678 } |
679 | 679 |
680 base::DictionaryValue* SandboxedUnpacker::RewriteManifestFile( | 680 base::DictionaryValue* SandboxedUnpacker::RewriteManifestFile( |
681 const base::DictionaryValue& manifest) { | 681 const base::DictionaryValue& manifest) { |
682 // Add the public key extracted earlier to the parsed manifest and overwrite | 682 // Add the public key extracted earlier to the parsed manifest and overwrite |
683 // the original manifest. We do this to ensure the manifest doesn't contain an | 683 // the original manifest. We do this to ensure the manifest doesn't contain an |
684 // exploitable bug that could be used to compromise the browser. | 684 // exploitable bug that could be used to compromise the browser. |
685 DCHECK(!public_key_.empty()); | 685 DCHECK(!public_key_.empty()); |
686 scoped_ptr<base::DictionaryValue> final_manifest(manifest.DeepCopy()); | 686 std::unique_ptr<base::DictionaryValue> final_manifest(manifest.DeepCopy()); |
687 final_manifest->SetString(manifest_keys::kPublicKey, public_key_); | 687 final_manifest->SetString(manifest_keys::kPublicKey, public_key_); |
688 | 688 |
689 std::string manifest_json; | 689 std::string manifest_json; |
690 JSONStringValueSerializer serializer(&manifest_json); | 690 JSONStringValueSerializer serializer(&manifest_json); |
691 serializer.set_pretty_print(true); | 691 serializer.set_pretty_print(true); |
692 if (!serializer.Serialize(*final_manifest)) { | 692 if (!serializer.Serialize(*final_manifest)) { |
693 // Error serializing manifest.json. | 693 // Error serializing manifest.json. |
694 ReportFailure(ERROR_SERIALIZING_MANIFEST_JSON, | 694 ReportFailure(ERROR_SERIALIZING_MANIFEST_JSON, |
695 l10n_util::GetStringFUTF16( | 695 l10n_util::GetStringFUTF16( |
696 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 696 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 SandboxedUnpacker::UtilityHostWrapper::~UtilityHostWrapper() { | 926 SandboxedUnpacker::UtilityHostWrapper::~UtilityHostWrapper() { |
927 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 927 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
928 if (utility_host_) { | 928 if (utility_host_) { |
929 utility_host_->EndBatchMode(); | 929 utility_host_->EndBatchMode(); |
930 utility_host_.reset(); | 930 utility_host_.reset(); |
931 } | 931 } |
932 } | 932 } |
933 | 933 |
934 } // namespace extensions | 934 } // namespace extensions |
OLD | NEW |