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 |
11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/extensions/extension_management.h" | 19 #include "chrome/browser/extensions/extension_management.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/install_signer.h" | 21 #include "chrome/browser/extensions/install_signer.h" |
22 #include "chrome/browser/extensions/install_verifier_factory.h" | 22 #include "chrome/browser/extensions/install_verifier_factory.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
26 #include "content/public/browser/browser_context.h" | 26 #include "content/public/browser/browser_context.h" |
27 #include "content/public/browser/storage_partition.h" | |
28 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
29 #include "extensions/browser/extension_prefs.h" | 28 #include "extensions/browser/extension_prefs.h" |
30 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
31 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
32 #include "extensions/browser/pref_names.h" | 31 #include "extensions/browser/pref_names.h" |
33 #include "extensions/common/extension_set.h" | 32 #include "extensions/common/extension_set.h" |
34 #include "extensions/common/manifest.h" | 33 #include "extensions/common/manifest.h" |
35 #include "extensions/common/manifest_url_handlers.h" | 34 #include "extensions/common/manifest_url_handlers.h" |
36 #include "extensions/common/one_shot_event.h" | 35 #include "extensions/common/one_shot_event.h" |
37 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 if (operation.type == InstallVerifier::REMOVE) { | 567 if (operation.type == InstallVerifier::REMOVE) { |
569 for (ExtensionIdSet::const_iterator i = operation.ids.begin(); | 568 for (ExtensionIdSet::const_iterator i = operation.ids.begin(); |
570 i != operation.ids.end(); ++i) { | 569 i != operation.ids.end(); ++i) { |
571 if (ContainsKey(ids_to_sign, *i)) | 570 if (ContainsKey(ids_to_sign, *i)) |
572 ids_to_sign.erase(*i); | 571 ids_to_sign.erase(*i); |
573 } | 572 } |
574 } else { // All other operation types are some form of "ADD". | 573 } else { // All other operation types are some form of "ADD". |
575 ids_to_sign.insert(operation.ids.begin(), operation.ids.end()); | 574 ids_to_sign.insert(operation.ids.begin(), operation.ids.end()); |
576 } | 575 } |
577 | 576 |
578 signer_.reset(new InstallSigner( | 577 signer_.reset(new InstallSigner(context_->GetRequestContext(), ids_to_sign)); |
579 content::BrowserContext::GetDefaultStoragePartition(context_)-> | |
580 GetURLRequestContext(), | |
581 ids_to_sign)); | |
582 signer_->GetSignature(base::Bind(&InstallVerifier::SignatureCallback, | 578 signer_->GetSignature(base::Bind(&InstallVerifier::SignatureCallback, |
583 weak_factory_.GetWeakPtr())); | 579 weak_factory_.GetWeakPtr())); |
584 } | 580 } |
585 | 581 |
586 void InstallVerifier::SaveToPrefs() { | 582 void InstallVerifier::SaveToPrefs() { |
587 if (signature_.get()) | 583 if (signature_.get()) |
588 DCHECK(InstallSigner::VerifySignature(*signature_)); | 584 DCHECK(InstallSigner::VerifySignature(*signature_)); |
589 | 585 |
590 if (!signature_.get() || signature_->ids.empty()) { | 586 if (!signature_.get() || signature_->ids.empty()) { |
591 DVLOG(1) << "SaveToPrefs - saving NULL"; | 587 DVLOG(1) << "SaveToPrefs - saving NULL"; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 ScopedInstallVerifierBypassForTest::~ScopedInstallVerifierBypassForTest() { | 666 ScopedInstallVerifierBypassForTest::~ScopedInstallVerifierBypassForTest() { |
671 g_bypass_for_test = old_value_; | 667 g_bypass_for_test = old_value_; |
672 } | 668 } |
673 | 669 |
674 // static | 670 // static |
675 bool ScopedInstallVerifierBypassForTest::ShouldBypass() { | 671 bool ScopedInstallVerifierBypassForTest::ShouldBypass() { |
676 return g_bypass_for_test; | 672 return g_bypass_for_test; |
677 } | 673 } |
678 | 674 |
679 } // namespace extensions | 675 } // namespace extensions |
OLD | NEW |