diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 18:54:58 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 18:54:58 +0000 |
commit | 9118e93ad88c2809973d1b2f97299cfe1601f20c (patch) | |
tree | 1a74f9c7570f53c4c6e3619f35111f2e8e4bc6fd /chrome/browser/extensions/sandboxed_extension_unpacker.cc | |
parent | d603cd3c0923238c5f8fbd755a04df7e3923a2f4 (diff) | |
download | chromium_src-9118e93ad88c2809973d1b2f97299cfe1601f20c.zip chromium_src-9118e93ad88c2809973d1b2f97299cfe1601f20c.tar.gz chromium_src-9118e93ad88c2809973d1b2f97299cfe1601f20c.tar.bz2 |
Part 2 of immutable Extension refactor.
I made Extension a refcounted object, and privitized the existing
con/destructor and InitFromValue. The only way to get an Extension is to call
a factory method.
In the next CL, I plan to make the factory method return a const Extension,
to guarantee that no one can modify the Extension object after creation.
Note: There was a tricky part of this CL because of the difference in
semantics between scoped_ptr and scoped_refptr. I had to be careful not to use
ptr.release(), since that would result in leaks (an un-Released AddRef).
BUG=56558
TEST=no functional change
Review URL: http://codereview.chromium.org/3982001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/sandboxed_extension_unpacker.cc')
-rw-r--r-- | chrome/browser/extensions/sandboxed_extension_unpacker.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc index fc8aea8..ea5ec64 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc @@ -140,18 +140,20 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( // extension was unpacked to. We use this until the extension is finally // installed. For example, the install UI shows images from inside the // extension. - extension_.reset(new Extension(extension_root_)); // Localize manifest now, so confirm UI gets correct extension name. std::string error; - if (!extension_l10n_util::LocalizeExtension(extension_.get(), + if (!extension_l10n_util::LocalizeExtension(extension_root_, final_manifest.get(), &error)) { ReportFailure(error); return; } - if (!extension_->InitFromValue(*final_manifest, true, &error)) { + extension_ = Extension::Create( + extension_root_, Extension::INTERNAL, *final_manifest, true, &error); + + if (!extension_.get()) { ReportFailure(std::string("Manifest is invalid: ") + error); return; } @@ -270,8 +272,8 @@ void SandboxedExtensionUnpacker::ReportFailure(const std::string& error) { void SandboxedExtensionUnpacker::ReportSuccess() { // Client takes ownership of temporary directory and extension. - client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, - extension_.release()); + client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, extension_); + extension_ = NULL; } DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile( |