1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// Use of this source code is governed by a BSD-style license that can be 3bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// found in the LICENSE file. 4bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 5bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ 6bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ 7bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#pragma once 8bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 9ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h" 10513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch#include "chrome/browser/policy/configuration_policy_store_interface.h" 11513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch#include "chrome/browser/policy/file_based_policy_provider.h" 12bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "chrome/browser/preferences_mac.h" 13bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 14bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsennamespace policy { 15bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 1621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen// A provider delegate implementation that reads Mac OS X's managed preferences. 1721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenclass MacPreferencesPolicyProviderDelegate 1821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen : public FileBasedPolicyProvider::ProviderDelegate { 19513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch public: 20513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // Takes ownership of |preferences|. 2121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen MacPreferencesPolicyProviderDelegate( 22513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch MacPreferences* preferences, 23513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); 24dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen virtual ~MacPreferencesPolicyProviderDelegate(); 25513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 26513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // FileBasedPolicyLoader::Delegate implementation. 27513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch virtual DictionaryValue* Load(); 28513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch virtual base::Time GetLastModification(); 29513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 30513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch private: 31513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // In order to access the application preferences API, the names and values of 32513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // the policies that are recognized must be known to the loader. 33513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // Unfortunately, we cannot get the policy list at load time from the 34513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // provider, because the loader may outlive the provider, so we store our own 35513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // pointer to the list. 36513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list_; 37513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 38513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch scoped_ptr<MacPreferences> preferences_; 39513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 4021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyProviderDelegate); 41513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch}; 42513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 43bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// An implementation of |ConfigurationPolicyProvider| using the mechanism 44bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// provided by Mac OS X's managed preferences. 45513209b27ff55e2841eac0e4120199c23acce758Ben Murdochclass ConfigurationPolicyProviderMac 46513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch : public FileBasedPolicyProvider { 47bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen public: 48bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen explicit ConfigurationPolicyProviderMac( 49513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); 50bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // For testing; takes ownership of |preferences|. 51513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch ConfigurationPolicyProviderMac( 52513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, 53513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch MacPreferences* preferences); 54bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 55513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); 56bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen}; 57bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 58bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen} // namespace policy 59bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 60bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ 61