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