summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/test_extension_prefs.cc
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 22:32:07 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 22:32:07 +0000
commit0f9f337262c383b94dce482aba0fac7e5778c852 (patch)
tree9359ce10553fadfb4583601da2b7fe58dba7edce /chrome/browser/extensions/test_extension_prefs.cc
parentcc3d6f596df5fa5fa6258b69e947c8977ade7dc7 (diff)
downloadchromium_src-0f9f337262c383b94dce482aba0fac7e5778c852.zip
chromium_src-0f9f337262c383b94dce482aba0fac7e5778c852.tar.gz
chromium_src-0f9f337262c383b94dce482aba0fac7e5778c852.tar.bz2
Unrevert r63919: "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 Original Review URL: http://codereview.chromium.org/3982001 TBR=aa Review URL: http://codereview.chromium.org/4186002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/test_extension_prefs.cc')
-rw-r--r--chrome/browser/extensions/test_extension_prefs.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index a32f847..2cbb2d1 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -45,22 +45,25 @@ void TestExtensionPrefs::RecreateExtensionPrefs() {
prefs_.reset(new ExtensionPrefs(pref_service_.get(), temp_dir_.path()));
}
-Extension* TestExtensionPrefs::AddExtension(std::string name) {
+scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) {
DictionaryValue dictionary;
dictionary.SetString(extension_manifest_keys::kName, name);
dictionary.SetString(extension_manifest_keys::kVersion, "0.1");
return AddExtensionWithManifest(dictionary, Extension::INTERNAL);
}
-Extension* TestExtensionPrefs::AddExtensionWithManifest(
+scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifest(
const DictionaryValue& manifest, Extension::Location location) {
std::string name;
EXPECT_TRUE(manifest.GetString(extension_manifest_keys::kName, &name));
FilePath path = extensions_dir_.AppendASCII(name);
- Extension* extension = new Extension(path);
std::string errors;
- extension->set_location(location);
- EXPECT_TRUE(extension->InitFromValue(manifest, false, &errors));
+ scoped_refptr<Extension> extension = Extension::Create(
+ path, location, manifest, false, &errors);
+ EXPECT_TRUE(extension);
+ if (!extension)
+ return NULL;
+
EXPECT_TRUE(Extension::IdIsValid(extension->id()));
const bool kInitialIncognitoEnabled = false;
prefs_->OnExtensionInstalled(extension, Extension::ENABLED,
@@ -69,6 +72,6 @@ Extension* TestExtensionPrefs::AddExtensionWithManifest(
}
std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) {
- scoped_ptr<Extension> extension(AddExtension(name));
+ scoped_refptr<Extension> extension(AddExtension(name));
return extension->id();
}