policy_check.cc 997 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "extensions/browser/policy_check.h"
  5. #include "content/public/browser/browser_context.h"
  6. #include "extensions/browser/extension_system.h"
  7. #include "extensions/browser/management_policy.h"
  8. namespace extensions {
  9. PolicyCheck::PolicyCheck(content::BrowserContext* context,
  10. scoped_refptr<const Extension> extension)
  11. : PreloadCheck(extension), context_(context) {}
  12. PolicyCheck::~PolicyCheck() {}
  13. void PolicyCheck::Start(ResultCallback callback) {
  14. Errors errors;
  15. if (!ExtensionSystem::Get(context_)->management_policy()->UserMayInstall(
  16. extension(), &error_)) {
  17. DCHECK(!error_.empty());
  18. errors.insert(Error::kDisallowedByPolicy);
  19. }
  20. std::move(callback).Run(errors);
  21. }
  22. std::u16string PolicyCheck::GetErrorMessage() const {
  23. return error_;
  24. }
  25. } // namespace extensions