Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4759)

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 174036: Get rid of the extension's "Current Version" file. (Closed)
Patch Set: merge conflicts Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extensions_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_prefs.cc
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 84ee99d91b79a4f6c001de1803f7fc8e91af102e..458394450db7dffdefde16ac39aa1ef015ea1024 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) {
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extensions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698