configuration_policy_provider_mac.h revision ddb351dbec246cf1fab5ec20d2d5520909041de1
1// Copyright (c) 2011 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#ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ 6#define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ 7#pragma once 8 9#include "base/memory/scoped_ptr.h" 10#include "chrome/browser/policy/configuration_policy_store_interface.h" 11#include "chrome/browser/policy/file_based_policy_provider.h" 12#include "chrome/browser/preferences_mac.h" 13 14namespace policy { 15 16// A provider delegate implementation that reads Mac OS X's managed preferences. 17class MacPreferencesPolicyProviderDelegate 18 : public FileBasedPolicyProvider::ProviderDelegate { 19 public: 20 // Takes ownership of |preferences|. 21 MacPreferencesPolicyProviderDelegate( 22 MacPreferences* preferences, 23 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); 24 virtual ~MacPreferencesPolicyProviderDelegate(); 25 26 // FileBasedPolicyLoader::Delegate implementation. 27 virtual DictionaryValue* Load(); 28 virtual base::Time GetLastModification(); 29 30 private: 31 // In order to access the application preferences API, the names and values of 32 // the policies that are recognized must be known to the loader. 33 // Unfortunately, we cannot get the policy list at load time from the 34 // provider, because the loader may outlive the provider, so we store our own 35 // pointer to the list. 36 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list_; 37 38 scoped_ptr<MacPreferences> preferences_; 39 40 DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyProviderDelegate); 41}; 42 43// An implementation of |ConfigurationPolicyProvider| using the mechanism 44// provided by Mac OS X's managed preferences. 45class ConfigurationPolicyProviderMac 46 : public FileBasedPolicyProvider { 47 public: 48 explicit ConfigurationPolicyProviderMac( 49 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); 50 // For testing; takes ownership of |preferences|. 51 ConfigurationPolicyProviderMac( 52 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, 53 MacPreferences* preferences); 54 55 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); 56}; 57 58} // namespace policy 59 60#endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ 61