diff options
author | Elijah Taylor <elijahtaylor@chromium.org> | 2014-09-26 10:56:15 -0700 |
---|---|---|
committer | Elijah Taylor <elijahtaylor@chromium.org> | 2014-09-26 17:56:44 +0000 |
commit | 51533547c9450ea9aabc3f0e7ada54e5af2a7343 (patch) | |
tree | 19c49dcf164ad9a7819674d94e850104368e5a1c | |
parent | 05ff2b5aa91e7464fb06b3ceccabd81b84431277 (diff) | |
download | chromium_src-51533547c9450ea9aabc3f0e7ada54e5af2a7343.zip chromium_src-51533547c9450ea9aabc3f0e7ada54e5af2a7343.tar.gz chromium_src-51533547c9450ea9aabc3f0e7ada54e5af2a7343.tar.bz2 |
Check multi-crx path for force update based on manifest entries
The previous CL (https://codereview.chromium.org/540673002) was not fully
correct. It used a path based on <nacl_arch>, but the path can be arbitrary
based on entries in the extension's manifest.
If the extension used non-nacl_arch paths, it would continually download and
install the same copy of the extension, eventually filling up the user's disk if
left long enough without restarting Chrome.
BUG=414156
Review URL: https://codereview.chromium.org/596193002
Cr-Commit-Position: refs/heads/master@{#296514}
(cherry picked from commit 74cafd39701dd9b66ea219a2a4ef0c9d88d76eec)
Review URL: https://codereview.chromium.org/605303002
Cr-Commit-Position: refs/branch-heads/2125@{#499}
Cr-Branched-From: b68026d94bda36dd106a3d91a098719f952a9477-refs/heads/master@{#290040}
-rw-r--r-- | chrome/browser/extensions/updater/extension_updater.cc | 34 | ||||
-rw-r--r-- | extensions/common/manifest_constants.cc | 3 | ||||
-rw-r--r-- | extensions/common/manifest_constants.h | 3 |
3 files changed, 30 insertions, 10 deletions
diff --git a/chrome/browser/extensions/updater/extension_updater.cc b/chrome/browser/extensions/updater/extension_updater.cc index 3cd89a2..6c84ac0 100644 --- a/chrome/browser/extensions/updater/extension_updater.cc +++ b/chrome/browser/extensions/updater/extension_updater.cc @@ -8,7 +8,6 @@ #include <set> #include "base/bind.h" -#include "base/files/file_enumerator.h" #include "base/files/file_util.h" #include "base/logging.h" #include "base/metrics/histogram.h" @@ -37,6 +36,7 @@ #include "extensions/common/extension.h" #include "extensions/common/extension_set.h" #include "extensions/common/manifest.h" +#include "extensions/common/manifest_constants.h" using base::RandDouble; using base::RandInt; @@ -119,15 +119,29 @@ void DetermineForcedUpdatesOnBlockingPool( extensions::kPlatformSpecificFolder); if (base::PathExists(platform_specific_path)) { bool force = true; - base::FileEnumerator all_archs(platform_specific_path, - false, - base::FileEnumerator::DIRECTORIES); - base::FilePath arch; - while (!(arch = all_archs.Next()).empty()) { - std::string arch_name = arch.BaseName().AsUTF8Unsafe(); - std::replace(arch_name.begin(), arch_name.end(), '_', '-'); - if (arch_name == OmahaQueryParams::GetNaclArch()) - force = false; + const base::ListValue* platforms; + if (extension->manifest()->GetList(extensions::manifest_keys::kPlatforms, + &platforms)) { + for (size_t i = 0; i < platforms->GetSize(); ++i) { + const base::DictionaryValue* p; + if (platforms->GetDictionary(i, &p)) { + std::string nacl_arch; + if (p->GetString(extensions::manifest_keys::kNaClArch, + &nacl_arch) && + nacl_arch == OmahaQueryParams::GetNaclArch()) { + std::string subpath; + if (p->GetString(extensions::manifest_keys::kSubPackagePath, + &subpath)) { + // _platform_specific is part of the sub_package_path entry. + base::FilePath platform_specific_subpath = + extension->path().AppendASCII(subpath); + if (base::PathExists(platform_specific_subpath)) { + force = false; + } + } + } + } + } } if (force) diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index fbf3229..5f1644b 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc @@ -83,6 +83,7 @@ const char kMinimumVersion[] = "minimum_version"; const char kMIMETypes[] = "mime_types"; const char kMimeTypesHandler[] = "mime_types_handler"; const char kName[] = "name"; +const char kNaClArch[] = "nacl_arch"; const char kNaClModules[] = "nacl_modules"; const char kNaClModulesMIMEType[] = "mime_type"; const char kNaClModulesPath[] = "path"; @@ -115,6 +116,7 @@ const char kPlatformAppBackgroundScripts[] = "app.background.scripts"; const char kPlatformAppContentSecurityPolicy[] = "app.content_security_policy"; const char kPlatformAppServiceWorker[] = "app.service_worker"; const char kPlatformAppServiceWorkerScript[] = "app.service_worker.script"; +const char kPlatforms[] = "platforms"; const char kPlugins[] = "plugins"; const char kPluginsPath[] = "path"; const char kPluginsPublic[] = "public"; @@ -140,6 +142,7 @@ const char kSpellcheckDictionaryLanguage[] = "dictionary_language"; const char kSpellcheckDictionaryLocale[] = "dictionary_locale"; const char kSpellcheckDictionaryPath[] = "dictionary_path"; const char kStorageManagedSchema[] = "storage.managed_schema"; +const char kSubPackagePath[] = "sub_package_path"; const char kSuggestedKey[] = "suggested_key"; const char kSynthesizeBrowserAction[] = "_synthesize_browser_action"; const char kSystemIndicator[] = "system_indicator"; diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index f9246cb..b60ae15 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h @@ -91,6 +91,7 @@ extern const char kMIMETypes[]; extern const char kMimeTypesHandler[]; extern const char kMinimumChromeVersion[]; extern const char kMinimumVersion[]; +extern const char kNaClArch[]; extern const char kNaClModules[]; extern const char kNaClModulesMIMEType[]; extern const char kNaClModulesPath[]; @@ -123,6 +124,7 @@ extern const char kPlatformAppBackgroundScripts[]; extern const char kPlatformAppContentSecurityPolicy[]; extern const char kPlatformAppServiceWorker[]; extern const char kPlatformAppServiceWorkerScript[]; +extern const char kPlatforms[]; extern const char kPlugins[]; extern const char kPluginsPath[]; extern const char kPluginsPublic[]; @@ -147,6 +149,7 @@ extern const char kSpellcheckDictionaryLanguage[]; extern const char kSpellcheckDictionaryLocale[]; extern const char kSpellcheckDictionaryPath[]; extern const char kStorageManagedSchema[]; +extern const char kSubPackagePath[]; extern const char kSuggestedKey[]; extern const char kSynthesizeBrowserAction[]; extern const char kSystemIndicator[]; |