Commit 8862293b authored by asargent@chromium.org's avatar asargent@chromium.org

Fix extension install verification for v1 packaged apps

BUG=334479

Review URL: https://codereview.chromium.org/133273016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245240 0039d316-1c4b-4281-b951-d872f2087c98
parent d57905e9
...@@ -575,8 +575,7 @@ void ExtensionService::VerifyAllExtensions() { ...@@ -575,8 +575,7 @@ void ExtensionService::VerifyAllExtensions() {
i != all_extensions->end(); ++i) { i != all_extensions->end(); ++i) {
const Extension& extension = **i; const Extension& extension = **i;
if (extensions::ManifestURL::UpdatesFromGallery(&extension) && if (InstallVerifier::NeedsVerification(extension))
extension.is_extension())
to_add.insert(extension.id()); to_add.insert(extension.id());
} }
extensions::ExtensionSystem::Get(profile_)->install_verifier()->AddMany( extensions::ExtensionSystem::Get(profile_)->install_verifier()->AddMany(
...@@ -2195,7 +2194,7 @@ void ExtensionService::AddNewOrUpdatedExtension( ...@@ -2195,7 +2194,7 @@ void ExtensionService::AddNewOrUpdatedExtension(
blacklisted_for_malware, blacklisted_for_malware,
page_ordinal); page_ordinal);
delayed_installs_.Remove(extension->id()); delayed_installs_.Remove(extension->id());
if (extensions::ManifestURL::UpdatesFromGallery(extension)) { if (InstallVerifier::NeedsVerification(*extension)) {
extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add( extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add(
extension->id(), InstallVerifier::AddResultCallback()); extension->id(), InstallVerifier::AddResultCallback());
} }
......
...@@ -123,8 +123,22 @@ void LogInitResultHistogram(InitResult result) { ...@@ -123,8 +123,22 @@ void LogInitResultHistogram(InitResult result) {
result, INIT_RESULT_MAX); result, INIT_RESULT_MAX);
} }
bool FromStore(const Extension& extension) {
bool updates_from_store = ManifestURL::UpdatesFromGallery(&extension);
return extension.from_webstore() || updates_from_store;
}
bool CanUseExtensionApis(const Extension& extension) {
return extension.is_extension() || extension.is_legacy_packaged_app();
}
} // namespace } // namespace
// static
bool InstallVerifier::NeedsVerification(const Extension& extension) {
return FromStore(extension) && CanUseExtensionApis(extension);
}
void InstallVerifier::Init() { void InstallVerifier::Init() {
const base::DictionaryValue* pref = prefs_->GetInstallSignature(); const base::DictionaryValue* pref = prefs_->GetInstallSignature();
if (pref) { if (pref) {
...@@ -228,11 +242,6 @@ std::string InstallVerifier::GetDebugPolicyProviderName() const { ...@@ -228,11 +242,6 @@ std::string InstallVerifier::GetDebugPolicyProviderName() const {
return std::string("InstallVerifier"); return std::string("InstallVerifier");
} }
static bool FromStore(const Extension* extension) {
bool updates_from_store = ManifestURL::UpdatesFromGallery(extension);
return extension->from_webstore() || updates_from_store;
}
namespace { namespace {
enum MustRemainDisabledOutcome { enum MustRemainDisabledOutcome {
...@@ -262,7 +271,8 @@ void MustRemainDisabledHistogram(MustRemainDisabledOutcome outcome) { ...@@ -262,7 +271,8 @@ void MustRemainDisabledHistogram(MustRemainDisabledOutcome outcome) {
bool InstallVerifier::MustRemainDisabled(const Extension* extension, bool InstallVerifier::MustRemainDisabled(const Extension* extension,
Extension::DisableReason* reason, Extension::DisableReason* reason,
base::string16* error) const { base::string16* error) const {
if (!extension->is_extension()) { CHECK(extension);
if (!CanUseExtensionApis(*extension)) {
MustRemainDisabledHistogram(NOT_EXTENSION); MustRemainDisabledHistogram(NOT_EXTENSION);
return false; return false;
} }
...@@ -280,7 +290,7 @@ bool InstallVerifier::MustRemainDisabled(const Extension* extension, ...@@ -280,7 +290,7 @@ bool InstallVerifier::MustRemainDisabled(const Extension* extension,
if (ContainsKey(InstallSigner::GetForcedNotFromWebstore(), extension->id())) { if (ContainsKey(InstallSigner::GetForcedNotFromWebstore(), extension->id())) {
verified = false; verified = false;
outcome = FORCED_NOT_VERIFIED; outcome = FORCED_NOT_VERIFIED;
} else if (!FromStore(extension)) { } else if (!FromStore(*extension)) {
verified = false; verified = false;
outcome = NOT_FROM_STORE; outcome = NOT_FROM_STORE;
} else if (signature_.get() == NULL) { } else if (signature_.get() == NULL) {
......
...@@ -41,6 +41,9 @@ class InstallVerifier : public ManagementPolicy::Provider { ...@@ -41,6 +41,9 @@ class InstallVerifier : public ManagementPolicy::Provider {
net::URLRequestContextGetter* context_getter); net::URLRequestContextGetter* context_getter);
virtual ~InstallVerifier(); virtual ~InstallVerifier();
// Returns whether |extension| is of a type that needs verification.
static bool NeedsVerification(const Extension& extension);
// Initializes this object for use, including reading preferences and // Initializes this object for use, including reading preferences and
// validating the stored signature. // validating the stored signature.
void Init(); void Init();
......
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