michaelpg | c0145e6 | 2017-03-18 03:00:15 | [diff] [blame] | 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 | |
| 5 | #include "extensions/browser/policy_check.h" |
| 6 | |
| 7 | #include "content/public/browser/browser_context.h" |
| 8 | #include "extensions/browser/extension_system.h" |
| 9 | #include "extensions/browser/management_policy.h" |
| 10 | |
| 11 | namespace extensions { |
| 12 | |
| 13 | PolicyCheck::PolicyCheck(content::BrowserContext* context, |
| 14 | scoped_refptr<const Extension> extension) |
| 15 | : PreloadCheck(extension), context_(context) {} |
| 16 | |
| 17 | PolicyCheck::~PolicyCheck() {} |
| 18 | |
| 19 | void PolicyCheck::Start(ResultCallback callback) { |
| 20 | Errors errors; |
Devlin Cronin | ae9baf56 | 2018-11-15 22:10:04 | [diff] [blame] | 21 | if (!ExtensionSystem::Get(context_)->management_policy()->UserMayInstall( |
michaelpg | c0145e6 | 2017-03-18 03:00:15 | [diff] [blame] | 22 | extension(), &error_)) { |
| 23 | DCHECK(!error_.empty()); |
| 24 | errors.insert(DISALLOWED_BY_POLICY); |
| 25 | } |
| 26 | std::move(callback).Run(errors); |
| 27 | } |
| 28 | |
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame^] | 29 | std::u16string PolicyCheck::GetErrorMessage() const { |
michaelpg | c0145e6 | 2017-03-18 03:00:15 | [diff] [blame] | 30 | return error_; |
| 31 | } |
| 32 | |
| 33 | } // namespace extensions |