diff options
author | mek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-15 18:03:41 +0000 |
---|---|---|
committer | mek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-15 18:03:41 +0000 |
commit | cf4b57e4e50a16c27aa7114fa432adf1f44ddba3 (patch) | |
tree | ddd8e8a867b2f8487492ea3ef2887394a5ffce62 | |
parent | 4c3695724890e0de2cf361fe7264ebc8c6a97a11 (diff) | |
download | chromium_src-cf4b57e4e50a16c27aa7114fa432adf1f44ddba3.zip chromium_src-cf4b57e4e50a16c27aa7114fa432adf1f44ddba3.tar.gz chromium_src-cf4b57e4e50a16c27aa7114fa432adf1f44ddba3.tar.bz2 |
Merge 217486 "Recover from a situation where the copy of the man..."
> Recover from a situation where the copy of the manifest file in the Preferences file got corrupted because of bug 272524.
>
> BUG=272547
>
> Review URL: https://chromiumcodereview.appspot.com/23136005
TBR=kerz
Review URL: https://codereview.chromium.org/22895011
git-svn-id: svn://svn.chromium.org/chrome/branches/1547/src@217817 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/installed_loader.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/extensions/installed_loader.cc b/chrome/browser/extensions/installed_loader.cc index 72a147f..db5929e 100644 --- a/chrome/browser/extensions/installed_loader.cc +++ b/chrome/browser/extensions/installed_loader.cc @@ -50,6 +50,7 @@ enum ManifestReloadReason { NOT_NEEDED = 0, // Reload not needed. UNPACKED_DIR, // Unpacked directory. NEEDS_RELOCALIZATION, // The locale has changed since we read this extension. + CORRUPT_PREFERENCES, // The manifest in the preferences is corrupt. NUM_MANIFEST_RELOAD_REASONS }; @@ -61,6 +62,21 @@ enum BackgroundPageType { EVENT_PAGE = 2, }; +bool IsManifestCorrupt(const DictionaryValue* manifest) { + if (!manifest) return false; + + // Because of bug #272524 sometimes manifests got mangled in the preferences + // file, one particularly bad case resulting in having both a background page + // and background scripts values. In those situations we want to reload the + // manifest from the extension to fix this. + const Value* background_page; + const Value* background_scripts; + return manifest->Get(extension_manifest_keys::kBackgroundPage, + &background_page) && + manifest->Get(extension_manifest_keys::kBackgroundScripts, + &background_scripts); +} + ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) { // Always reload manifests of unpacked extensions, because they can change // on disk independent of the manifest in our prefs. @@ -72,6 +88,10 @@ ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) { info.extension_manifest.get())) return NEEDS_RELOCALIZATION; + // Reload if the copy of the manifest in the preferences is corrupt. + if (IsManifestCorrupt(info.extension_manifest.get())) + return CORRUPT_PREFERENCES; + return NOT_NEEDED; } |