| 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_management.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/install_signer.h" | 18 #include "chrome/browser/extensions/install_signer.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/manifest_url_handler.h" | 20 #include "chrome/common/extensions/manifest_url_handler.h" |
| 20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 22 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 24 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
| 25 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 InstallVerifier::PendingOperation* operation = | 316 InstallVerifier::PendingOperation* operation = |
| 316 new InstallVerifier::PendingOperation(InstallVerifier::REMOVE); | 317 new InstallVerifier::PendingOperation(InstallVerifier::REMOVE); |
| 317 operation->ids = ids; | 318 operation->ids = ids; |
| 318 | 319 |
| 319 operation_queue_.push(linked_ptr<PendingOperation>(operation)); | 320 operation_queue_.push(linked_ptr<PendingOperation>(operation)); |
| 320 if (operation_queue_.size() == 1) | 321 if (operation_queue_.size() == 1) |
| 321 BeginFetch(); | 322 BeginFetch(); |
| 322 } | 323 } |
| 323 | 324 |
| 324 bool InstallVerifier::AllowedByEnterprisePolicy(const std::string& id) const { | 325 bool InstallVerifier::AllowedByEnterprisePolicy(const std::string& id) const { |
| 325 PrefService* pref_service = prefs_->pref_service(); | 326 return ExtensionManagementFactory::GetForBrowserContext(context_) |
| 326 if (pref_service->IsManagedPreference(pref_names::kInstallAllowList)) { | 327 ->IsInstallationAllowed(id); |
| 327 const base::ListValue* whitelist = | |
| 328 pref_service->GetList(pref_names::kInstallAllowList); | |
| 329 base::StringValue id_value(id); | |
| 330 if (whitelist && whitelist->Find(id_value) != whitelist->end()) | |
| 331 return true; | |
| 332 } | |
| 333 if (pref_service->IsManagedPreference(pref_names::kInstallForceList)) { | |
| 334 const base::DictionaryValue* forcelist = | |
| 335 pref_service->GetDictionary(pref_names::kInstallForceList); | |
| 336 if (forcelist && forcelist->HasKey(id)) | |
| 337 return true; | |
| 338 } | |
| 339 return false; | |
| 340 } | 328 } |
| 341 | 329 |
| 342 std::string InstallVerifier::GetDebugPolicyProviderName() const { | 330 std::string InstallVerifier::GetDebugPolicyProviderName() const { |
| 343 return std::string("InstallVerifier"); | 331 return std::string("InstallVerifier"); |
| 344 } | 332 } |
| 345 | 333 |
| 346 namespace { | 334 namespace { |
| 347 | 335 |
| 348 enum MustRemainDisabledOutcome { | 336 enum MustRemainDisabledOutcome { |
| 349 VERIFIED = 0, | 337 VERIFIED = 0, |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } | 630 } |
| 643 | 631 |
| 644 OnVerificationComplete(success, operation->type); | 632 OnVerificationComplete(success, operation->type); |
| 645 } | 633 } |
| 646 | 634 |
| 647 if (!operation_queue_.empty()) | 635 if (!operation_queue_.empty()) |
| 648 BeginFetch(); | 636 BeginFetch(); |
| 649 } | 637 } |
| 650 | 638 |
| 651 } // namespace extensions | 639 } // namespace extensions |
| OLD | NEW |