Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: chrome/browser/extensions/install_verifier.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 void InstallVerifier::Init() { 228 void InstallVerifier::Init() {
229 TRACE_EVENT0("browser,startup", "extensions::InstallVerifier::Init"); 229 TRACE_EVENT0("browser,startup", "extensions::InstallVerifier::Init");
230 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ExperimentStatus", 230 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ExperimentStatus",
231 GetExperimentStatus(), VERIFY_STATUS_MAX); 231 GetExperimentStatus(), VERIFY_STATUS_MAX);
232 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ActualStatus", 232 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ActualStatus",
233 GetStatus(), VERIFY_STATUS_MAX); 233 GetStatus(), VERIFY_STATUS_MAX);
234 234
235 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); 235 const base::DictionaryValue* pref = prefs_->GetInstallSignature();
236 if (pref) { 236 if (pref) {
237 scoped_ptr<InstallSignature> signature_from_prefs = 237 std::unique_ptr<InstallSignature> signature_from_prefs =
238 InstallSignature::FromValue(*pref); 238 InstallSignature::FromValue(*pref);
239 if (!signature_from_prefs.get()) { 239 if (!signature_from_prefs.get()) {
240 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); 240 LogInitResultHistogram(INIT_UNPARSEABLE_PREF);
241 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { 241 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) {
242 LogInitResultHistogram(INIT_INVALID_SIGNATURE); 242 LogInitResultHistogram(INIT_INVALID_SIGNATURE);
243 DVLOG(1) << "Init - ignoring invalid signature"; 243 DVLOG(1) << "Init - ignoring invalid signature";
244 } else { 244 } else {
245 signature_ = std::move(signature_from_prefs); 245 signature_ = std::move(signature_from_prefs);
246 LogInitResultHistogram(INIT_VALID_SIGNATURE); 246 LogInitResultHistogram(INIT_VALID_SIGNATURE);
247 UMA_HISTOGRAM_COUNTS_100("ExtensionInstallVerifier.InitSignatureCount", 247 UMA_HISTOGRAM_COUNTS_100("ExtensionInstallVerifier.InitSignatureCount",
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 445 }
446 446
447 InstallVerifier::PendingOperation::PendingOperation(OperationType type) 447 InstallVerifier::PendingOperation::PendingOperation(OperationType type)
448 : type(type) {} 448 : type(type) {}
449 449
450 InstallVerifier::PendingOperation::~PendingOperation() { 450 InstallVerifier::PendingOperation::~PendingOperation() {
451 } 451 }
452 452
453 ExtensionIdSet InstallVerifier::GetExtensionsToVerify() const { 453 ExtensionIdSet InstallVerifier::GetExtensionsToVerify() const {
454 ExtensionIdSet result; 454 ExtensionIdSet result;
455 scoped_ptr<ExtensionSet> extensions = 455 std::unique_ptr<ExtensionSet> extensions =
456 ExtensionRegistry::Get(context_)->GenerateInstalledExtensionsSet(); 456 ExtensionRegistry::Get(context_)->GenerateInstalledExtensionsSet();
457 for (ExtensionSet::const_iterator iter = extensions->begin(); 457 for (ExtensionSet::const_iterator iter = extensions->begin();
458 iter != extensions->end(); 458 iter != extensions->end();
459 ++iter) { 459 ++iter) {
460 if (NeedsVerification(*iter->get())) 460 if (NeedsVerification(*iter->get()))
461 result.insert((*iter)->id()); 461 result.insert((*iter)->id());
462 } 462 }
463 return result; 463 return result;
464 } 464 }
465 465
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (!signature_.get() || signature_->ids.empty()) { 586 if (!signature_.get() || signature_->ids.empty()) {
587 DVLOG(1) << "SaveToPrefs - saving NULL"; 587 DVLOG(1) << "SaveToPrefs - saving NULL";
588 prefs_->SetInstallSignature(NULL); 588 prefs_->SetInstallSignature(NULL);
589 } else { 589 } else {
590 base::DictionaryValue pref; 590 base::DictionaryValue pref;
591 signature_->ToValue(&pref); 591 signature_->ToValue(&pref);
592 if (VLOG_IS_ON(1)) { 592 if (VLOG_IS_ON(1)) {
593 DVLOG(1) << "SaveToPrefs - saving"; 593 DVLOG(1) << "SaveToPrefs - saving";
594 594
595 DCHECK(InstallSigner::VerifySignature(*signature_.get())); 595 DCHECK(InstallSigner::VerifySignature(*signature_.get()));
596 scoped_ptr<InstallSignature> rehydrated = 596 std::unique_ptr<InstallSignature> rehydrated =
597 InstallSignature::FromValue(pref); 597 InstallSignature::FromValue(pref);
598 DCHECK(InstallSigner::VerifySignature(*rehydrated.get())); 598 DCHECK(InstallSigner::VerifySignature(*rehydrated.get()));
599 } 599 }
600 prefs_->SetInstallSignature(&pref); 600 prefs_->SetInstallSignature(&pref);
601 } 601 }
602 } 602 }
603 603
604 namespace { 604 namespace {
605 605
606 enum CallbackResult { 606 enum CallbackResult {
607 CALLBACK_NO_SIGNATURE = 0, 607 CALLBACK_NO_SIGNATURE = 0,
608 CALLBACK_INVALID_SIGNATURE, 608 CALLBACK_INVALID_SIGNATURE,
609 CALLBACK_VALID_SIGNATURE, 609 CALLBACK_VALID_SIGNATURE,
610 610
611 // This is used in histograms - do not remove or reorder entries above! Also 611 // This is used in histograms - do not remove or reorder entries above! Also
612 // the "MAX" item below should always be the last element. 612 // the "MAX" item below should always be the last element.
613 613
614 CALLBACK_RESULT_MAX 614 CALLBACK_RESULT_MAX
615 }; 615 };
616 616
617 void GetSignatureResultHistogram(CallbackResult result) { 617 void GetSignatureResultHistogram(CallbackResult result) {
618 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.GetSignatureResult", 618 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.GetSignatureResult",
619 result, CALLBACK_RESULT_MAX); 619 result, CALLBACK_RESULT_MAX);
620 } 620 }
621 621
622 } // namespace 622 } // namespace
623 623
624 void InstallVerifier::SignatureCallback( 624 void InstallVerifier::SignatureCallback(
625 scoped_ptr<InstallSignature> signature) { 625 std::unique_ptr<InstallSignature> signature) {
626
627 linked_ptr<PendingOperation> operation = operation_queue_.front(); 626 linked_ptr<PendingOperation> operation = operation_queue_.front();
628 operation_queue_.pop(); 627 operation_queue_.pop();
629 628
630 bool success = false; 629 bool success = false;
631 if (!signature.get()) { 630 if (!signature.get()) {
632 GetSignatureResultHistogram(CALLBACK_NO_SIGNATURE); 631 GetSignatureResultHistogram(CALLBACK_NO_SIGNATURE);
633 } else if (!InstallSigner::VerifySignature(*signature)) { 632 } else if (!InstallSigner::VerifySignature(*signature)) {
634 GetSignatureResultHistogram(CALLBACK_INVALID_SIGNATURE); 633 GetSignatureResultHistogram(CALLBACK_INVALID_SIGNATURE);
635 } else { 634 } else {
636 GetSignatureResultHistogram(CALLBACK_VALID_SIGNATURE); 635 GetSignatureResultHistogram(CALLBACK_VALID_SIGNATURE);
(...skipping 30 matching lines...) Expand all
667 ScopedInstallVerifierBypassForTest::~ScopedInstallVerifierBypassForTest() { 666 ScopedInstallVerifierBypassForTest::~ScopedInstallVerifierBypassForTest() {
668 g_bypass_for_test = old_value_; 667 g_bypass_for_test = old_value_;
669 } 668 }
670 669
671 // static 670 // static
672 bool ScopedInstallVerifierBypassForTest::ShouldBypass() { 671 bool ScopedInstallVerifierBypassForTest::ShouldBypass() {
673 return g_bypass_for_test; 672 return g_bypass_for_test;
674 } 673 }
675 674
676 } // namespace extensions 675 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/install_verifier.h ('k') | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698