summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-15 18:03:41 +0000
committermek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-15 18:03:41 +0000
commitcf4b57e4e50a16c27aa7114fa432adf1f44ddba3 (patch)
treeddd8e8a867b2f8487492ea3ef2887394a5ffce62
parent4c3695724890e0de2cf361fe7264ebc8c6a97a11 (diff)
downloadchromium_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.cc20
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;
}