summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_prefs.cc
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-20 18:58:19 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-20 18:58:19 +0000
commitb6ab96da13cdfe15f38fbebcd22e0a1db5a50381 (patch)
tree99e4977793b780210f6aceca8ae544612065a33a /chrome/browser/extensions/extension_prefs.cc
parent49c97336d0262072c413ca802c4818a419e3b620 (diff)
downloadchromium_src-b6ab96da13cdfe15f38fbebcd22e0a1db5a50381.zip
chromium_src-b6ab96da13cdfe15f38fbebcd22e0a1db5a50381.tar.gz
chromium_src-b6ab96da13cdfe15f38fbebcd22e0a1db5a50381.tar.bz2
Get rid of the extension's "Current Version" file.
The entire manifest.json value is now stored in the prefs file. This will allow for quick extension checks on startup. BUG=18293 TEST=Make sure installing/upgrading/uninstalling extensions works as expected. Review URL: http://codereview.chromium.org/174036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_prefs.cc')
-rw-r--r--chrome/browser/extensions/extension_prefs.cc44
1 files changed, 41 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 84ee99d..4583944 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -24,6 +24,12 @@ const wchar_t kPrefState[] = L"state";
// The path to the current version's manifest file.
const wchar_t kPrefPath[] = L"path";
+// The dictionary containing the extension's manifest.
+const wchar_t kPrefManifest[] = L"manifest";
+
+// The version number.
+const wchar_t kPrefVersion[] = L"manifest.version";
+
// Indicates if an extension is blacklisted:
const wchar_t kPrefBlacklist[] = L"blacklist";
@@ -43,6 +49,7 @@ InstalledExtensions::~InstalledExtensions() {
void InstalledExtensions::VisitInstalledExtensions(
InstalledExtensions::Callback *callback) {
+ scoped_ptr<InstalledExtensions::Callback> cleanup(callback);
DictionaryValue::key_iterator extension_id = extension_data_->begin_keys();
for (; extension_id != extension_data_->end_keys(); ++extension_id) {
DictionaryValue* ext;
@@ -74,9 +81,16 @@ void InstalledExtensions::VisitInstalledExtensions(
NOTREACHED();
continue;
}
+ DictionaryValue* manifest = NULL;
+ if (!ext->GetDictionary(kPrefManifest, &manifest)) {
+ LOG(WARNING) << "Missing manifest for extension " << *extension_id;
+ // Just a warning for now.
+ }
+
Extension::Location location =
static_cast<Extension::Location>(location_value);
- callback->Run(WideToASCII(*extension_id), FilePath(path), location);
+ callback->Run(manifest, WideToASCII(*extension_id), FilePath(path),
+ location);
}
}
@@ -300,13 +314,18 @@ void ExtensionPrefs::SetShelfToolstripOrder(const URLList& urls) {
void ExtensionPrefs::OnExtensionInstalled(Extension* extension) {
const std::string& id = extension->id();
- UpdateExtensionPref(id, kPrefState,
- Value::CreateIntegerValue(Extension::ENABLED));
+ // Make sure we don't enable a disabled extension.
+ if (GetExtensionState(extension->id()) != Extension::DISABLED) {
+ UpdateExtensionPref(id, kPrefState,
+ Value::CreateIntegerValue(Extension::ENABLED));
+ }
UpdateExtensionPref(id, kPrefLocation,
Value::CreateIntegerValue(extension->location()));
FilePath::StringType path = MakePathRelative(install_directory_,
extension->path(), NULL);
UpdateExtensionPref(id, kPrefPath, Value::CreateStringValue(path));
+ UpdateExtensionPref(id, kPrefManifest,
+ extension->manifest_value()->DeepCopy());
prefs_->SavePersistentPrefs();
}
@@ -351,6 +370,25 @@ void ExtensionPrefs::SetExtensionState(Extension* extension,
prefs_->SavePersistentPrefs();
}
+std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
+ DictionaryValue* extension = GetExtensionPref(extension_id);
+ if (!extension)
+ return std::string();
+
+ std::string version;
+ if (!extension->GetString(kPrefVersion, &version)) {
+ LOG(ERROR) << "Bad or missing pref 'version' for extension '"
+ << extension_id << "'";
+ }
+
+ return version;
+}
+
+void ExtensionPrefs::MigrateToPrefs(Extension* extension) {
+ UpdateExtensionPref(extension->id(), kPrefManifest,
+ extension->manifest_value()->DeepCopy());
+}
+
bool ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id,
const std::wstring& key,
Value* data_value) {