summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 18:12:44 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 18:12:44 +0000
commit2111b1acfc64a286e1761d9e9b6c3c55d95ca952 (patch)
treed765c1fc205324a53dc76ef2fe7296444e24183b /chrome/browser/extensions
parentedce9ad5b2daa7ebba90caaabd1e48e0dd1bc90b (diff)
downloadchromium_src-2111b1acfc64a286e1761d9e9b6c3c55d95ca952.zip
chromium_src-2111b1acfc64a286e1761d9e9b6c3c55d95ca952.tar.gz
chromium_src-2111b1acfc64a286e1761d9e9b6c3c55d95ca952.tar.bz2
Fix a bug with persistent unpacked extensions where we would not pick up
manifest changes on browser restart. BUG=24850 Review URL: http://codereview.chromium.org/789007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41448 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_prefs.cc16
-rw-r--r--chrome/browser/extensions/extensions_service.cc21
-rw-r--r--chrome/browser/extensions/extensions_service.h6
3 files changed, 28 insertions, 15 deletions
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 10c5056..d4879ac 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -373,8 +373,12 @@ void ExtensionPrefs::OnExtensionInstalled(Extension* extension) {
FilePath::StringType path = MakePathRelative(install_directory_,
extension->path(), NULL);
UpdateExtensionPref(id, kPrefPath, Value::CreateStringValue(path));
- UpdateExtensionPref(id, kPrefManifest,
- extension->manifest_value()->DeepCopy());
+ // We store prefs about LOAD extensions, but don't cache their manifest
+ // since it may change on disk.
+ if (extension->location() != Extension::LOAD) {
+ UpdateExtensionPref(id, kPrefManifest,
+ extension->manifest_value()->DeepCopy());
+ }
prefs_->SavePersistentPrefs();
}
@@ -441,9 +445,11 @@ std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
}
void ExtensionPrefs::UpdateManifest(Extension* extension) {
- UpdateExtensionPref(extension->id(), kPrefManifest,
- extension->manifest_value()->DeepCopy());
- prefs_->ScheduleSavePersistentPrefs();
+ if (extension->location() != Extension::LOAD) {
+ UpdateExtensionPref(extension->id(), kPrefManifest,
+ extension->manifest_value()->DeepCopy());
+ prefs_->ScheduleSavePersistentPrefs();
+ }
}
FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) {
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 92a9dcd..fc2dadf 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -83,6 +83,16 @@ class InstalledExtensionSet {
std::map<std::string, std::string> versions_;
};
+static bool ShouldReloadExtensionManifest(const ExtensionInfo& info) {
+ // Always reload LOAD extension manifests, because they can change on disk
+ // independent of the manifest in our prefs.
+ if (info.extension_location == Extension::LOAD)
+ return true;
+
+ // Otherwise, reload the manifest it needs to be relocalized.
+ return extension_l10n_util::ShouldRelocalizeManifest(info);
+}
+
} // namespace
// ExtensionsService.
@@ -356,11 +366,11 @@ void ExtensionsService::LoadAllExtensions() {
// If any extensions need localization, we bounce them all to the file thread
// for re-reading and localization.
for (size_t i = 0; i < info->size(); ++i) {
- if (extension_l10n_util::ShouldRelocalizeManifest(*info->at(i))) {
+ if (ShouldReloadExtensionManifest(*info->at(i))) {
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE, NewRunnableMethod(
backend_.get(),
- &ExtensionsServiceBackend::ReloadExtensionManifestsForLocaleChanged,
+ &ExtensionsServiceBackend::ReloadExtensionManifests,
info.release(), // Callee takes ownership of the memory.
start_time,
scoped_refptr<ExtensionsService>(this)));
@@ -1121,7 +1131,7 @@ void ExtensionsServiceBackend::OnExternalExtensionFound(
version->GetString(), path, location));
}
-void ExtensionsServiceBackend::ReloadExtensionManifestsForLocaleChanged(
+void ExtensionsServiceBackend::ReloadExtensionManifests(
ExtensionPrefs::ExtensionsInfo* extensions_to_reload,
base::TimeTicks start_time,
scoped_refptr<ExtensionsService> frontend) {
@@ -1129,10 +1139,7 @@ void ExtensionsServiceBackend::ReloadExtensionManifestsForLocaleChanged(
for (size_t i = 0; i < extensions_to_reload->size(); ++i) {
ExtensionInfo* info = extensions_to_reload->at(i).get();
- if (!info->extension_manifest.get())
- continue;
-
- if (!extension_l10n_util::ShouldRelocalizeManifest(*info))
+ if (!ShouldReloadExtensionManifest(*info))
continue;
// We need to reload original manifest in order to localize properly.
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 3ab9d34..e9e8128 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -407,9 +407,9 @@ class ExtensionsServiceBackend
const FilePath& path,
Extension::Location location);
- // When Chrome locale changes we need to re-localize manifest files for
- // extensions that are actually localized.
- void ReloadExtensionManifestsForLocaleChanged(
+ // Reloads the given extensions from their manifests on disk (instead of what
+ // we have cached in the prefs).
+ void ReloadExtensionManifests(
ExtensionPrefs::ExtensionsInfo* extensions_to_reload,
base::TimeTicks start_time,
scoped_refptr<ExtensionsService> frontend);