| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ |
| 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/policy/file_based_policy_provider.h" | 10 #include "chrome/browser/policy/file_based_policy_provider.h" |
| 11 | 11 |
| 12 class MacPreferences; | 12 class MacPreferences; |
| 13 | 13 |
| 14 namespace policy { | 14 namespace policy { |
| 15 | 15 |
| 16 // A provider delegate implementation that reads Mac OS X's managed preferences. | 16 // A provider delegate implementation that reads Mac OS X's managed preferences. |
| 17 class MacPreferencesPolicyProviderDelegate | 17 class MacPreferencesPolicyProviderDelegate |
| 18 : public FileBasedPolicyProvider::ProviderDelegate { | 18 : public FileBasedPolicyProvider::ProviderDelegate { |
| 19 public: | 19 public: |
| 20 // Takes ownership of |preferences|. | 20 // Takes ownership of |preferences|. |
| 21 MacPreferencesPolicyProviderDelegate( | 21 MacPreferencesPolicyProviderDelegate( |
| 22 MacPreferences* preferences, | 22 MacPreferences* preferences, |
| 23 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); | 23 const PolicyDefinitionList* policy_list); |
| 24 virtual ~MacPreferencesPolicyProviderDelegate(); | 24 virtual ~MacPreferencesPolicyProviderDelegate(); |
| 25 | 25 |
| 26 // FileBasedPolicyLoader::Delegate implementation. | 26 // FileBasedPolicyLoader::Delegate implementation. |
| 27 virtual DictionaryValue* Load() OVERRIDE; | 27 virtual DictionaryValue* Load() OVERRIDE; |
| 28 virtual base::Time GetLastModification() OVERRIDE; | 28 virtual base::Time GetLastModification() OVERRIDE; |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 // In order to access the application preferences API, the names and values of | 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. | 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 | 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 | 34 // provider, because the loader may outlive the provider, so we store our own |
| 35 // pointer to the list. | 35 // pointer to the list. |
| 36 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list_; | 36 const PolicyDefinitionList* policy_list_; |
| 37 | 37 |
| 38 scoped_ptr<MacPreferences> preferences_; | 38 scoped_ptr<MacPreferences> preferences_; |
| 39 | 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyProviderDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyProviderDelegate); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // An implementation of |ConfigurationPolicyProvider| using the mechanism | 43 // An implementation of |ConfigurationPolicyProvider| using the mechanism |
| 44 // provided by Mac OS X's managed preferences. | 44 // provided by Mac OS X's managed preferences. |
| 45 class ConfigurationPolicyProviderMac : public FileBasedPolicyProvider { | 45 class ConfigurationPolicyProviderMac : public FileBasedPolicyProvider { |
| 46 public: | 46 public: |
| 47 explicit ConfigurationPolicyProviderMac( | 47 explicit ConfigurationPolicyProviderMac( |
| 48 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); | 48 const PolicyDefinitionList* policy_list); |
| 49 // For testing; takes ownership of |preferences|. | 49 // For testing; takes ownership of |preferences|. |
| 50 ConfigurationPolicyProviderMac( | 50 ConfigurationPolicyProviderMac(const PolicyDefinitionList* policy_list, |
| 51 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, | 51 MacPreferences* preferences); |
| 52 MacPreferences* preferences); | |
| 53 | 52 |
| 54 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); | 53 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 } // namespace policy | 56 } // namespace policy |
| 58 | 57 |
| 59 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ | 58 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ |
| OLD | NEW |