| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/install_verifier.h" | 5 #include "chrome/browser/extensions/install_verifier.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 GetExperimentStatus(), VERIFY_STATUS_MAX); | 232 GetExperimentStatus(), VERIFY_STATUS_MAX); |
| 233 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ActualStatus", | 233 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ActualStatus", |
| 234 GetStatus(), VERIFY_STATUS_MAX); | 234 GetStatus(), VERIFY_STATUS_MAX); |
| 235 | 235 |
| 236 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); | 236 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); |
| 237 if (pref) { | 237 if (pref) { |
| 238 std::unique_ptr<InstallSignature> signature_from_prefs = | 238 std::unique_ptr<InstallSignature> signature_from_prefs = |
| 239 InstallSignature::FromValue(*pref); | 239 InstallSignature::FromValue(*pref); |
| 240 if (!signature_from_prefs.get()) { | 240 if (!signature_from_prefs.get()) { |
| 241 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); | 241 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); |
| 242 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { | 242 } else if (!InstallSigner::VerifySignature(*signature_from_prefs)) { |
| 243 LogInitResultHistogram(INIT_INVALID_SIGNATURE); | 243 LogInitResultHistogram(INIT_INVALID_SIGNATURE); |
| 244 DVLOG(1) << "Init - ignoring invalid signature"; | 244 DVLOG(1) << "Init - ignoring invalid signature"; |
| 245 } else { | 245 } else { |
| 246 signature_ = std::move(signature_from_prefs); | 246 signature_ = std::move(signature_from_prefs); |
| 247 LogInitResultHistogram(INIT_VALID_SIGNATURE); | 247 LogInitResultHistogram(INIT_VALID_SIGNATURE); |
| 248 UMA_HISTOGRAM_COUNTS_100("ExtensionInstallVerifier.InitSignatureCount", | 248 UMA_HISTOGRAM_COUNTS_100("ExtensionInstallVerifier.InitSignatureCount", |
| 249 signature_->ids.size()); | 249 signature_->ids.size()); |
| 250 GarbageCollect(); | 250 GarbageCollect(); |
| 251 } | 251 } |
| 252 } else { | 252 } else { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 InstallVerifier::PendingOperation::~PendingOperation() { | 451 InstallVerifier::PendingOperation::~PendingOperation() { |
| 452 } | 452 } |
| 453 | 453 |
| 454 ExtensionIdSet InstallVerifier::GetExtensionsToVerify() const { | 454 ExtensionIdSet InstallVerifier::GetExtensionsToVerify() const { |
| 455 ExtensionIdSet result; | 455 ExtensionIdSet result; |
| 456 std::unique_ptr<ExtensionSet> extensions = | 456 std::unique_ptr<ExtensionSet> extensions = |
| 457 ExtensionRegistry::Get(context_)->GenerateInstalledExtensionsSet(); | 457 ExtensionRegistry::Get(context_)->GenerateInstalledExtensionsSet(); |
| 458 for (ExtensionSet::const_iterator iter = extensions->begin(); | 458 for (ExtensionSet::const_iterator iter = extensions->begin(); |
| 459 iter != extensions->end(); | 459 iter != extensions->end(); |
| 460 ++iter) { | 460 ++iter) { |
| 461 if (NeedsVerification(*iter->get())) | 461 if (NeedsVerification(**iter)) |
| 462 result.insert((*iter)->id()); | 462 result.insert((*iter)->id()); |
| 463 } | 463 } |
| 464 return result; | 464 return result; |
| 465 } | 465 } |
| 466 | 466 |
| 467 void InstallVerifier::MaybeBootstrapSelf() { | 467 void InstallVerifier::MaybeBootstrapSelf() { |
| 468 bool needs_bootstrap = false; | 468 bool needs_bootstrap = false; |
| 469 | 469 |
| 470 ExtensionIdSet extension_ids = GetExtensionsToVerify(); | 470 ExtensionIdSet extension_ids = GetExtensionsToVerify(); |
| 471 if (signature_.get() == NULL && ShouldFetchSignature()) { | 471 if (signature_.get() == NULL && ShouldFetchSignature()) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 if (!signature_.get() || signature_->ids.empty()) { | 590 if (!signature_.get() || signature_->ids.empty()) { |
| 591 DVLOG(1) << "SaveToPrefs - saving NULL"; | 591 DVLOG(1) << "SaveToPrefs - saving NULL"; |
| 592 prefs_->SetInstallSignature(NULL); | 592 prefs_->SetInstallSignature(NULL); |
| 593 } else { | 593 } else { |
| 594 base::DictionaryValue pref; | 594 base::DictionaryValue pref; |
| 595 signature_->ToValue(&pref); | 595 signature_->ToValue(&pref); |
| 596 if (VLOG_IS_ON(1)) { | 596 if (VLOG_IS_ON(1)) { |
| 597 DVLOG(1) << "SaveToPrefs - saving"; | 597 DVLOG(1) << "SaveToPrefs - saving"; |
| 598 | 598 |
| 599 DCHECK(InstallSigner::VerifySignature(*signature_.get())); | 599 DCHECK(InstallSigner::VerifySignature(*signature_)); |
| 600 std::unique_ptr<InstallSignature> rehydrated = | 600 std::unique_ptr<InstallSignature> rehydrated = |
| 601 InstallSignature::FromValue(pref); | 601 InstallSignature::FromValue(pref); |
| 602 DCHECK(InstallSigner::VerifySignature(*rehydrated.get())); | 602 DCHECK(InstallSigner::VerifySignature(*rehydrated)); |
| 603 } | 603 } |
| 604 prefs_->SetInstallSignature(&pref); | 604 prefs_->SetInstallSignature(&pref); |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 | 607 |
| 608 namespace { | 608 namespace { |
| 609 | 609 |
| 610 enum CallbackResult { | 610 enum CallbackResult { |
| 611 CALLBACK_NO_SIGNATURE = 0, | 611 CALLBACK_NO_SIGNATURE = 0, |
| 612 CALLBACK_INVALID_SIGNATURE, | 612 CALLBACK_INVALID_SIGNATURE, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 ScopedInstallVerifierBypassForTest::~ScopedInstallVerifierBypassForTest() { | 670 ScopedInstallVerifierBypassForTest::~ScopedInstallVerifierBypassForTest() { |
| 671 g_bypass_for_test = old_value_; | 671 g_bypass_for_test = old_value_; |
| 672 } | 672 } |
| 673 | 673 |
| 674 // static | 674 // static |
| 675 bool ScopedInstallVerifierBypassForTest::ShouldBypass() { | 675 bool ScopedInstallVerifierBypassForTest::ShouldBypass() { |
| 676 return g_bypass_for_test; | 676 return g_bypass_for_test; |
| 677 } | 677 } |
| 678 | 678 |
| 679 } // namespace extensions | 679 } // namespace extensions |
| OLD | NEW |