diff options
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_prefs.cc | 16 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 21 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.h | 6 |
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); |