summaryrefslogtreecommitdiff
path: root/chromium/extensions/browser/policy_check.cc
blob: 5be0020f9c126015c3f5abcb136dc43d2b773873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/policy_check.h"

#include "content/public/browser/browser_context.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/management_policy.h"

namespace extensions {

PolicyCheck::PolicyCheck(content::BrowserContext* context,
                         scoped_refptr<const Extension> extension)
    : PreloadCheck(extension), context_(context) {}

PolicyCheck::~PolicyCheck() {}

void PolicyCheck::Start(ResultCallback callback) {
  Errors errors;
  if (!ExtensionSystem::Get(context_)->management_policy()->UserMayInstall(
          extension(), &error_)) {
    DCHECK(!error_.empty());
    errors.insert(DISALLOWED_BY_POLICY);
  }
  std::move(callback).Run(errors);
}

std::u16string PolicyCheck::GetErrorMessage() const {
  return error_;
}

}  // namespace extensions