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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "chrome/browser/extensions/extension_prefs.h" | 16 #include "chrome/browser/extensions/extension_prefs.h" |
17 #include "chrome/browser/extensions/install_signer.h" | 17 #include "chrome/browser/extensions/install_signer.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/manifest_url_handler.h" | 19 #include "chrome/common/extensions/manifest_url_handler.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "extensions/browser/pref_names.h" |
22 #include "extensions/common/manifest.h" | 23 #include "extensions/common/manifest.h" |
23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 enum VerifyStatus { | 29 enum VerifyStatus { |
29 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. |
30 BOOTSTRAP, // Request install signatures, but do not enforce them. | 31 BOOTSTRAP, // Request install signatures, but do not enforce them. |
31 ENFORCE, // Request install signatures, and enforce them. | 32 ENFORCE, // Request install signatures, and enforce them. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 if (found != leftovers.end()) | 333 if (found != leftovers.end()) |
333 leftovers.erase(found); | 334 leftovers.erase(found); |
334 } | 335 } |
335 if (!leftovers.empty()) { | 336 if (!leftovers.empty()) { |
336 RemoveMany(leftovers); | 337 RemoveMany(leftovers); |
337 } | 338 } |
338 } | 339 } |
339 | 340 |
340 bool InstallVerifier::AllowedByEnterprisePolicy(const std::string& id) const { | 341 bool InstallVerifier::AllowedByEnterprisePolicy(const std::string& id) const { |
341 PrefService* pref_service = prefs_->pref_service(); | 342 PrefService* pref_service = prefs_->pref_service(); |
342 if (pref_service->IsManagedPreference(prefs::kExtensionInstallAllowList)) { | 343 if (pref_service->IsManagedPreference(pref_names::kInstallAllowList)) { |
343 const base::ListValue* whitelist = | 344 const base::ListValue* whitelist = |
344 pref_service->GetList(prefs::kExtensionInstallAllowList); | 345 pref_service->GetList(pref_names::kInstallAllowList); |
345 base::StringValue id_value(id); | 346 base::StringValue id_value(id); |
346 if (whitelist && whitelist->Find(id_value) != whitelist->end()) | 347 if (whitelist && whitelist->Find(id_value) != whitelist->end()) |
347 return true; | 348 return true; |
348 } | 349 } |
349 if (pref_service->IsManagedPreference(prefs::kExtensionInstallForceList)) { | 350 if (pref_service->IsManagedPreference(pref_names::kInstallForceList)) { |
350 const base::DictionaryValue* forcelist = | 351 const base::DictionaryValue* forcelist = |
351 pref_service->GetDictionary(prefs::kExtensionInstallForceList); | 352 pref_service->GetDictionary(pref_names::kInstallForceList); |
352 if (forcelist && forcelist->HasKey(id)) | 353 if (forcelist && forcelist->HasKey(id)) |
353 return true; | 354 return true; |
354 } | 355 } |
355 return false; | 356 return false; |
356 } | 357 } |
357 | 358 |
358 bool InstallVerifier::IsVerified(const std::string& id) const { | 359 bool InstallVerifier::IsVerified(const std::string& id) const { |
359 return ((signature_.get() && ContainsKey(signature_->ids, id)) || | 360 return ((signature_.get() && ContainsKey(signature_->ids, id)) || |
360 ContainsKey(provisional_, id)); | 361 ContainsKey(provisional_, id)); |
361 } | 362 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 if (!operation->callback.is_null()) | 466 if (!operation->callback.is_null()) |
466 operation->callback.Run(success); | 467 operation->callback.Run(success); |
467 } | 468 } |
468 | 469 |
469 if (!operation_queue_.empty()) | 470 if (!operation_queue_.empty()) |
470 BeginFetch(); | 471 BeginFetch(); |
471 } | 472 } |
472 | 473 |
473 | 474 |
474 } // namespace extensions | 475 } // namespace extensions |
OLD | NEW |