summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/standard_management_policy_provider.cc
blob: 31c56c9a857dc19843621be1e725f70ee395ec0c (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2012 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 "chrome/browser/extensions/standard_management_policy_provider.h"

#include "base/prefs/pref_service.h"
#include "chrome/browser/extensions/admin_policy.h"
#include "chrome/browser/extensions/blacklist.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/pref_names.h"

namespace extensions {

StandardManagementPolicyProvider::StandardManagementPolicyProvider(
    ExtensionPrefs* prefs)
    : prefs_(prefs) {
}

StandardManagementPolicyProvider::~StandardManagementPolicyProvider() {
}

std::string
    StandardManagementPolicyProvider::GetDebugPolicyProviderName() const {
#ifdef NDEBUG
  NOTREACHED();
  return std::string();
#else
  return "admin policy black/white/forcelist, via the ExtensionPrefs";
#endif
}

bool StandardManagementPolicyProvider::UserMayLoad(
    const Extension* extension,
    string16* error) const {
  PrefService* pref_service = prefs_->pref_service();

  const base::ListValue* blacklist =
      pref_service->GetList(prefs::kExtensionInstallDenyList);
  const base::ListValue* whitelist =
      pref_service->GetList(prefs::kExtensionInstallAllowList);
  const base::DictionaryValue* forcelist =
      pref_service->GetDictionary(prefs::kExtensionInstallForceList);
  const base::ListValue* allowed_types = NULL;
  if (pref_service->HasPrefPath(prefs::kExtensionAllowedTypes))
    allowed_types = pref_service->GetList(prefs::kExtensionAllowedTypes);

  return admin_policy::UserMayLoad(
      blacklist, whitelist, forcelist, allowed_types, extension, error);
}

bool StandardManagementPolicyProvider::UserMayModifySettings(
    const Extension* extension,
    string16* error) const {
  return admin_policy::UserMayModifySettings(extension, error);
}

bool StandardManagementPolicyProvider::MustRemainEnabled(
    const Extension* extension,
    string16* error) const {
  return admin_policy::MustRemainEnabled(extension, error);
}

}  // namespace extensions