Commit 74cafd39 authored by elijahtaylor's avatar elijahtaylor Committed by Commit bot

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}
parent 3e08a170
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <set> #include <set>
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
...@@ -37,6 +36,7 @@ ...@@ -37,6 +36,7 @@
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_set.h" #include "extensions/common/extension_set.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
using base::RandDouble; using base::RandDouble;
using base::RandInt; using base::RandInt;
...@@ -119,15 +119,29 @@ void DetermineForcedUpdatesOnBlockingPool( ...@@ -119,15 +119,29 @@ void DetermineForcedUpdatesOnBlockingPool(
extensions::kPlatformSpecificFolder); extensions::kPlatformSpecificFolder);
if (base::PathExists(platform_specific_path)) { if (base::PathExists(platform_specific_path)) {
bool force = true; bool force = true;
base::FileEnumerator all_archs(platform_specific_path, const base::ListValue* platforms;
false, if (extension->manifest()->GetList(extensions::manifest_keys::kPlatforms,
base::FileEnumerator::DIRECTORIES); &platforms)) {
base::FilePath arch; for (size_t i = 0; i < platforms->GetSize(); ++i) {
while (!(arch = all_archs.Next()).empty()) { const base::DictionaryValue* p;
std::string arch_name = arch.BaseName().AsUTF8Unsafe(); if (platforms->GetDictionary(i, &p)) {
std::replace(arch_name.begin(), arch_name.end(), '_', '-'); std::string nacl_arch;
if (arch_name == OmahaQueryParams::GetNaclArch()) if (p->GetString(extensions::manifest_keys::kNaClArch,
force = false; &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) if (force)
......
...@@ -83,6 +83,7 @@ const char kMinimumVersion[] = "minimum_version"; ...@@ -83,6 +83,7 @@ const char kMinimumVersion[] = "minimum_version";
const char kMIMETypes[] = "mime_types"; const char kMIMETypes[] = "mime_types";
const char kMimeTypesHandler[] = "mime_types_handler"; const char kMimeTypesHandler[] = "mime_types_handler";
const char kName[] = "name"; const char kName[] = "name";
const char kNaClArch[] = "nacl_arch";
const char kNaClModules[] = "nacl_modules"; const char kNaClModules[] = "nacl_modules";
const char kNaClModulesMIMEType[] = "mime_type"; const char kNaClModulesMIMEType[] = "mime_type";
const char kNaClModulesPath[] = "path"; const char kNaClModulesPath[] = "path";
...@@ -114,6 +115,7 @@ const char kPlatformAppBackground[] = "app.background"; ...@@ -114,6 +115,7 @@ const char kPlatformAppBackground[] = "app.background";
const char kPlatformAppBackgroundPage[] = "app.background.page"; const char kPlatformAppBackgroundPage[] = "app.background.page";
const char kPlatformAppBackgroundScripts[] = "app.background.scripts"; const char kPlatformAppBackgroundScripts[] = "app.background.scripts";
const char kPlatformAppContentSecurityPolicy[] = "app.content_security_policy"; const char kPlatformAppContentSecurityPolicy[] = "app.content_security_policy";
const char kPlatforms[] = "platforms";
const char kPlugins[] = "plugins"; const char kPlugins[] = "plugins";
const char kPluginsPath[] = "path"; const char kPluginsPath[] = "path";
const char kPluginsPublic[] = "public"; const char kPluginsPublic[] = "public";
...@@ -139,6 +141,7 @@ const char kSpellcheckDictionaryLanguage[] = "dictionary_language"; ...@@ -139,6 +141,7 @@ const char kSpellcheckDictionaryLanguage[] = "dictionary_language";
const char kSpellcheckDictionaryLocale[] = "dictionary_locale"; const char kSpellcheckDictionaryLocale[] = "dictionary_locale";
const char kSpellcheckDictionaryPath[] = "dictionary_path"; const char kSpellcheckDictionaryPath[] = "dictionary_path";
const char kStorageManagedSchema[] = "storage.managed_schema"; const char kStorageManagedSchema[] = "storage.managed_schema";
const char kSubPackagePath[] = "sub_package_path";
const char kSuggestedKey[] = "suggested_key"; const char kSuggestedKey[] = "suggested_key";
const char kSynthesizeBrowserAction[] = "_synthesize_browser_action"; const char kSynthesizeBrowserAction[] = "_synthesize_browser_action";
const char kSystemIndicator[] = "system_indicator"; const char kSystemIndicator[] = "system_indicator";
......
...@@ -91,6 +91,7 @@ extern const char kMIMETypes[]; ...@@ -91,6 +91,7 @@ extern const char kMIMETypes[];
extern const char kMimeTypesHandler[]; extern const char kMimeTypesHandler[];
extern const char kMinimumChromeVersion[]; extern const char kMinimumChromeVersion[];
extern const char kMinimumVersion[]; extern const char kMinimumVersion[];
extern const char kNaClArch[];
extern const char kNaClModules[]; extern const char kNaClModules[];
extern const char kNaClModulesMIMEType[]; extern const char kNaClModulesMIMEType[];
extern const char kNaClModulesPath[]; extern const char kNaClModulesPath[];
...@@ -122,6 +123,7 @@ extern const char kPlatformAppBackground[]; ...@@ -122,6 +123,7 @@ extern const char kPlatformAppBackground[];
extern const char kPlatformAppBackgroundPage[]; extern const char kPlatformAppBackgroundPage[];
extern const char kPlatformAppBackgroundScripts[]; extern const char kPlatformAppBackgroundScripts[];
extern const char kPlatformAppContentSecurityPolicy[]; extern const char kPlatformAppContentSecurityPolicy[];
extern const char kPlatforms[];
extern const char kPlugins[]; extern const char kPlugins[];
extern const char kPluginsPath[]; extern const char kPluginsPath[];
extern const char kPluginsPublic[]; extern const char kPluginsPublic[];
...@@ -146,6 +148,7 @@ extern const char kSpellcheckDictionaryLanguage[]; ...@@ -146,6 +148,7 @@ extern const char kSpellcheckDictionaryLanguage[];
extern const char kSpellcheckDictionaryLocale[]; extern const char kSpellcheckDictionaryLocale[];
extern const char kSpellcheckDictionaryPath[]; extern const char kSpellcheckDictionaryPath[];
extern const char kStorageManagedSchema[]; extern const char kStorageManagedSchema[];
extern const char kSubPackagePath[];
extern const char kSuggestedKey[]; extern const char kSuggestedKey[];
extern const char kSynthesizeBrowserAction[]; extern const char kSynthesizeBrowserAction[];
extern const char kSystemIndicator[]; extern const char kSystemIndicator[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment