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 | 10 |
10 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); | 229 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); |
229 if (pref) { | 230 if (pref) { |
230 scoped_ptr<InstallSignature> signature_from_prefs = | 231 scoped_ptr<InstallSignature> signature_from_prefs = |
231 InstallSignature::FromValue(*pref); | 232 InstallSignature::FromValue(*pref); |
232 if (!signature_from_prefs.get()) { | 233 if (!signature_from_prefs.get()) { |
233 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); | 234 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); |
234 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { | 235 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { |
235 LogInitResultHistogram(INIT_INVALID_SIGNATURE); | 236 LogInitResultHistogram(INIT_INVALID_SIGNATURE); |
236 DVLOG(1) << "Init - ignoring invalid signature"; | 237 DVLOG(1) << "Init - ignoring invalid signature"; |
237 } else { | 238 } else { |
238 signature_ = signature_from_prefs.Pass(); | 239 signature_ = std::move(signature_from_prefs); |
239 LogInitResultHistogram(INIT_VALID_SIGNATURE); | 240 LogInitResultHistogram(INIT_VALID_SIGNATURE); |
240 UMA_HISTOGRAM_COUNTS_100("ExtensionInstallVerifier.InitSignatureCount", | 241 UMA_HISTOGRAM_COUNTS_100("ExtensionInstallVerifier.InitSignatureCount", |
241 signature_->ids.size()); | 242 signature_->ids.size()); |
242 GarbageCollect(); | 243 GarbageCollect(); |
243 } | 244 } |
244 } else { | 245 } else { |
245 LogInitResultHistogram(INIT_NO_PREF); | 246 LogInitResultHistogram(INIT_NO_PREF); |
246 } | 247 } |
247 | 248 |
248 ExtensionSystem::Get(context_)->ready().Post( | 249 ExtensionSystem::Get(context_)->ready().Post( |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 GetSignatureResultHistogram(CALLBACK_VALID_SIGNATURE); | 630 GetSignatureResultHistogram(CALLBACK_VALID_SIGNATURE); |
630 success = true; | 631 success = true; |
631 } | 632 } |
632 | 633 |
633 if (!success) { | 634 if (!success) { |
634 OnVerificationComplete(false, operation->type); | 635 OnVerificationComplete(false, operation->type); |
635 | 636 |
636 // TODO(asargent) - if this was something like a network error, we need to | 637 // TODO(asargent) - if this was something like a network error, we need to |
637 // do retries with exponential back off. | 638 // do retries with exponential back off. |
638 } else { | 639 } else { |
639 signature_ = signature.Pass(); | 640 signature_ = std::move(signature); |
640 SaveToPrefs(); | 641 SaveToPrefs(); |
641 | 642 |
642 if (!provisional_.empty()) { | 643 if (!provisional_.empty()) { |
643 // Update |provisional_| to remove ids that were successfully signed. | 644 // Update |provisional_| to remove ids that were successfully signed. |
644 provisional_ = base::STLSetDifference<ExtensionIdSet>( | 645 provisional_ = base::STLSetDifference<ExtensionIdSet>( |
645 provisional_, signature_->ids); | 646 provisional_, signature_->ids); |
646 } | 647 } |
647 | 648 |
648 OnVerificationComplete(success, operation->type); | 649 OnVerificationComplete(success, operation->type); |
649 } | 650 } |
650 | 651 |
651 if (!operation_queue_.empty()) | 652 if (!operation_queue_.empty()) |
652 BeginFetch(); | 653 BeginFetch(); |
653 } | 654 } |
654 | 655 |
655 } // namespace extensions | 656 } // namespace extensions |
OLD | NEW |