1 // Copyright 2012 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 "chrome/browser/extensions/standard_management_policy_provider.h" 6 7 #include "base/prefs/pref_service.h" 8 #include "chrome/browser/extensions/blacklist.h" 9 #include "chrome/browser/extensions/extension_prefs.h" 10 #include "chrome/common/pref_names.h" 11 #include "extensions/browser/admin_policy.h" 12 #include "extensions/common/extension.h" 13 14 namespace extensions { 15 16 StandardManagementPolicyProvider::StandardManagementPolicyProvider( 17 ExtensionPrefs* prefs) 18 : prefs_(prefs) { 19 } 20 21 StandardManagementPolicyProvider::~StandardManagementPolicyProvider() { 22 } 23 24 std::string 25 StandardManagementPolicyProvider::GetDebugPolicyProviderName() const { 26 #ifdef NDEBUG 27 NOTREACHED(); 28 return std::string(); 29 #else 30 return "admin policy black/white/forcelist, via the ExtensionPrefs"; 31 #endif 32 } 33 34 bool StandardManagementPolicyProvider::UserMayLoad( 35 const Extension* extension, 36 base::string16* error) const { 37 PrefService* pref_service = prefs_->pref_service(); 38 39 const base::ListValue* blacklist = 40 pref_service->GetList(prefs::kExtensionInstallDenyList); 41 const base::ListValue* whitelist = 42 pref_service->GetList(prefs::kExtensionInstallAllowList); 43 const base::DictionaryValue* forcelist = 44 pref_service->GetDictionary(prefs::kExtensionInstallForceList); 45 const base::ListValue* allowed_types = NULL; 46 if (pref_service->HasPrefPath(prefs::kExtensionAllowedTypes)) 47 allowed_types = pref_service->GetList(prefs::kExtensionAllowedTypes); 48 49 return admin_policy::UserMayLoad( 50 blacklist, whitelist, forcelist, allowed_types, extension, error); 51 } 52 53 bool StandardManagementPolicyProvider::UserMayModifySettings( 54 const Extension* extension, 55 base::string16* error) const { 56 return admin_policy::UserMayModifySettings(extension, error); 57 } 58 59 bool StandardManagementPolicyProvider::MustRemainEnabled( 60 const Extension* extension, 61 base::string16* error) const { 62 return admin_policy::MustRemainEnabled(extension, error); 63 } 64 65 } // namespace extensions 66