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

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

Issue 147983011: Revert 247790 "Change default mode of extension install verifica..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 12 matching lines...) Expand all
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
38 }; 33 };
39 34
40 #if defined(GOOGLE_CHROME_BUILD) 35 #if defined(GOOGLE_CHROME_BUILD)
41 const char kExperimentName[] = "ExtensionInstallVerification"; 36 const char kExperimentName[] = "ExtensionInstallVerification";
42 #endif // defined(GOOGLE_CHROME_BUILD) 37 #endif // defined(GOOGLE_CHROME_BUILD)
43 38
44 VerifyStatus GetExperimentStatus() { 39 VerifyStatus GetExperimentStatus() {
45 #if defined(GOOGLE_CHROME_BUILD) 40 #if defined(GOOGLE_CHROME_BUILD)
46 const std::string group = base::FieldTrialList::FindFullName( 41 const std::string group = base::FieldTrialList::FindFullName(
47 kExperimentName); 42 kExperimentName);
48 43
49 std::string forced_trials = CommandLine::ForCurrentProcess()-> 44 std::string forced_trials = CommandLine::ForCurrentProcess()->
50 GetSwitchValueASCII(switches::kForceFieldTrials); 45 GetSwitchValueASCII(switches::kForceFieldTrials);
51 if (forced_trials.find(kExperimentName) != std::string::npos) { 46 if (forced_trials.find(kExperimentName) != std::string::npos) {
52 // We don't want to allow turning off enforcement by forcing the field 47 // We don't want to allow turning off enforcement by forcing the field
53 // trial group to something other than enforcement. 48 // trial group to something other than enforcement.
54 return ENFORCE; 49 return ENFORCE;
55 } 50 }
56 51
57 VerifyStatus default_status = NONE; 52 VerifyStatus default_status = BOOTSTRAP;
58 53
59 if (group == "Enforce") 54 if (group == "Enforce")
60 return ENFORCE; 55 return ENFORCE;
61 else if (group == "Bootstrap") 56 else if (group == "Bootstrap")
62 return BOOTSTRAP; 57 return BOOTSTRAP;
63 else if (group == "None" || group == "Control") 58 else if (group == "None" || group == "Control")
64 return NONE; 59 return NONE;
65 else 60 else
66 return default_status; 61 return default_status;
67 #endif // defined(GOOGLE_CHROME_BUILD) 62 #endif // defined(GOOGLE_CHROME_BUILD)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 134 }
140 135
141 } // namespace 136 } // namespace
142 137
143 // static 138 // static
144 bool InstallVerifier::NeedsVerification(const Extension& extension) { 139 bool InstallVerifier::NeedsVerification(const Extension& extension) {
145 return FromStore(extension) && CanUseExtensionApis(extension); 140 return FromStore(extension) && CanUseExtensionApis(extension);
146 } 141 }
147 142
148 void InstallVerifier::Init() { 143 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
154 const base::DictionaryValue* pref = prefs_->GetInstallSignature(); 144 const base::DictionaryValue* pref = prefs_->GetInstallSignature();
155 if (pref) { 145 if (pref) {
156 scoped_ptr<InstallSignature> signature_from_prefs = 146 scoped_ptr<InstallSignature> signature_from_prefs =
157 InstallSignature::FromValue(*pref); 147 InstallSignature::FromValue(*pref);
158 if (!signature_from_prefs.get()) { 148 if (!signature_from_prefs.get()) {
159 LogInitResultHistogram(INIT_UNPARSEABLE_PREF); 149 LogInitResultHistogram(INIT_UNPARSEABLE_PREF);
160 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) { 150 } else if (!InstallSigner::VerifySignature(*signature_from_prefs.get())) {
161 LogInitResultHistogram(INIT_INVALID_SIGNATURE); 151 LogInitResultHistogram(INIT_INVALID_SIGNATURE);
162 DVLOG(1) << "Init - ignoring invalid signature"; 152 DVLOG(1) << "Init - ignoring invalid signature";
163 } else { 153 } else {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (!operation->callback.is_null()) 476 if (!operation->callback.is_null())
487 operation->callback.Run(success); 477 operation->callback.Run(success);
488 } 478 }
489 479
490 if (!operation_queue_.empty()) 480 if (!operation_queue_.empty())
491 BeginFetch(); 481 BeginFetch();
492 } 482 }
493 483
494 484
495 } // namespace extensions 485 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698