| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "extensions/common/manifest.h" | 23 #include "extensions/common/manifest.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 enum VerifyStatus { | 29 enum VerifyStatus { |
| 30 NONE = 0, // Do not request install signatures, and do not enforce them. | 30 NONE = 0, // Do not request install signatures, and do not enforce them. |
| 31 BOOTSTRAP, // Request install signatures, but do not enforce them. | 31 BOOTSTRAP, // Request install signatures, but do not enforce them. |
| 32 ENFORCE, // Request install signatures, and enforce them. | 32 ENFORCE, // Request install signatures, and enforce them. |
| 33 |
| 34 // This is used in histograms - do not remove or reorder entries above! Also |
| 35 // the "MAX" item below should always be the last element. |
| 36 |
| 37 VERIFY_STATUS_MAX |
| 33 }; | 38 }; |
| 34 | 39 |
| 35 #if defined(GOOGLE_CHROME_BUILD) | 40 #if defined(GOOGLE_CHROME_BUILD) |
| 36 const char kExperimentName[] = "ExtensionInstallVerification"; | 41 const char kExperimentName[] = "ExtensionInstallVerification"; |
| 37 #endif // defined(GOOGLE_CHROME_BUILD) | 42 #endif // defined(GOOGLE_CHROME_BUILD) |
| 38 | 43 |
| 39 VerifyStatus GetExperimentStatus() { | 44 VerifyStatus GetExperimentStatus() { |
| 40 #if defined(GOOGLE_CHROME_BUILD) | 45 #if defined(GOOGLE_CHROME_BUILD) |
| 41 const std::string group = base::FieldTrialList::FindFullName( | 46 const std::string group = base::FieldTrialList::FindFullName( |
| 42 kExperimentName); | 47 kExperimentName); |
| 43 | 48 |
| 44 std::string forced_trials = CommandLine::ForCurrentProcess()-> | 49 std::string forced_trials = CommandLine::ForCurrentProcess()-> |
| 45 GetSwitchValueASCII(switches::kForceFieldTrials); | 50 GetSwitchValueASCII(switches::kForceFieldTrials); |
| 46 if (forced_trials.find(kExperimentName) != std::string::npos) { | 51 if (forced_trials.find(kExperimentName) != std::string::npos) { |
| 47 // We don't want to allow turning off enforcement by forcing the field | 52 // We don't want to allow turning off enforcement by forcing the field |
| 48 // trial group to something other than enforcement. | 53 // trial group to something other than enforcement. |
| 49 return ENFORCE; | 54 return ENFORCE; |
| 50 } | 55 } |
| 51 | 56 |
| 52 VerifyStatus default_status = BOOTSTRAP; | 57 VerifyStatus default_status = NONE; |
| 53 | 58 |
| 54 if (group == "Enforce") | 59 if (group == "Enforce") |
| 55 return ENFORCE; | 60 return ENFORCE; |
| 56 else if (group == "Bootstrap") | 61 else if (group == "Bootstrap") |
| 57 return BOOTSTRAP; | 62 return BOOTSTRAP; |
| 58 else if (group == "None" || group == "Control") | 63 else if (group == "None" || group == "Control") |
| 59 return NONE; | 64 return NONE; |
| 60 else | 65 else |
| 61 return default_status; | 66 return default_status; |
| 62 #endif // defined(GOOGLE_CHROME_BUILD) | 67 #endif // defined(GOOGLE_CHROME_BUILD) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 139 } |
| 135 | 140 |
| 136 } // namespace | 141 } // namespace |
| 137 | 142 |
| 138 // static | 143 // static |
| 139 bool InstallVerifier::NeedsVerification(const Extension& extension) { | 144 bool InstallVerifier::NeedsVerification(const Extension& extension) { |
| 140 return FromStore(extension) && CanUseExtensionApis(extension); | 145 return FromStore(extension) && CanUseExtensionApis(extension); |
| 141 } | 146 } |
| 142 | 147 |
| 143 void InstallVerifier::Init() { | 148 void InstallVerifier::Init() { |
| 149 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ExperimentStatus", |
| 150 GetExperimentStatus(), VERIFY_STATUS_MAX); |
| 151 UMA_HISTOGRAM_ENUMERATION("ExtensionInstallVerifier.ActualStatus", |
| 152 GetStatus(), VERIFY_STATUS_MAX); |
| 153 |
| 144 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); | 154 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); |
| 145 if (pref) { | 155 if (pref) { |
| 146 scoped_ptr<InstallSignature> signature_from_prefs = | 156 scoped_ptr<InstallSignature> signature_from_prefs = |
| 147 InstallSignature::FromValue(*pref); | 157 InstallSignature::FromValue(*pref); |
| 148 if (!signature_from_prefs.get()) { | 158 if (!signature_from_prefs.get()) { |
| 149 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); | 159 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); |
| 150 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { | 160 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { |
| 151 LogInitResultHistogram(INIT_INVALID_SIGNATURE); | 161 LogInitResultHistogram(INIT_INVALID_SIGNATURE); |
| 152 DVLOG(1) << "Init - ignoring invalid signature"; | 162 DVLOG(1) << "Init - ignoring invalid signature"; |
| 153 } else { | 163 } else { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 if (!operation->callback.is_null()) | 486 if (!operation->callback.is_null()) |
| 477 operation->callback.Run(success); | 487 operation->callback.Run(success); |
| 478 } | 488 } |
| 479 | 489 |
| 480 if (!operation_queue_.empty()) | 490 if (!operation_queue_.empty()) |
| 481 BeginFetch(); | 491 BeginFetch(); |
| 482 } | 492 } |
| 483 | 493 |
| 484 | 494 |
| 485 } // namespace extensions | 495 } // namespace extensions |
| OLD | NEW |