| 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 #include "chrome/browser/preferences_mac.h" | 11 |
| 12 class MacPreferences; |
| 12 | 13 |
| 13 namespace policy { | 14 namespace policy { |
| 14 | 15 |
| 15 // 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. |
| 16 class MacPreferencesPolicyProviderDelegate | 17 class MacPreferencesPolicyProviderDelegate |
| 17 : public FileBasedPolicyProvider::ProviderDelegate { | 18 : public FileBasedPolicyProvider::ProviderDelegate { |
| 18 public: | 19 public: |
| 19 // Takes ownership of |preferences|. | 20 // Takes ownership of |preferences|. |
| 20 MacPreferencesPolicyProviderDelegate( | 21 MacPreferencesPolicyProviderDelegate( |
| 21 MacPreferences* preferences, | 22 MacPreferences* preferences, |
| 22 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); | 23 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); |
| 23 virtual ~MacPreferencesPolicyProviderDelegate(); | 24 virtual ~MacPreferencesPolicyProviderDelegate(); |
| 24 | 25 |
| 25 // FileBasedPolicyLoader::Delegate implementation. | 26 // FileBasedPolicyLoader::Delegate implementation. |
| 26 virtual DictionaryValue* Load(); | 27 virtual DictionaryValue* Load() OVERRIDE; |
| 27 virtual base::Time GetLastModification(); | 28 virtual base::Time GetLastModification() OVERRIDE; |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 // 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 |
| 31 // the policies that are recognized must be known to the loader. | 32 // the policies that are recognized must be known to the loader. |
| 32 // 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 |
| 33 // 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 |
| 34 // pointer to the list. | 35 // pointer to the list. |
| 35 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list_; | 36 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list_; |
| 36 | 37 |
| 37 scoped_ptr<MacPreferences> preferences_; | 38 scoped_ptr<MacPreferences> preferences_; |
| 38 | 39 |
| 39 DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyProviderDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyProviderDelegate); |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 // An implementation of |ConfigurationPolicyProvider| using the mechanism | 43 // An implementation of |ConfigurationPolicyProvider| using the mechanism |
| 43 // provided by Mac OS X's managed preferences. | 44 // provided by Mac OS X's managed preferences. |
| 44 class ConfigurationPolicyProviderMac | 45 class ConfigurationPolicyProviderMac : public FileBasedPolicyProvider { |
| 45 : public FileBasedPolicyProvider { | |
| 46 public: | 46 public: |
| 47 explicit ConfigurationPolicyProviderMac( | 47 explicit ConfigurationPolicyProviderMac( |
| 48 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); | 48 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); |
| 49 // For testing; takes ownership of |preferences|. | 49 // For testing; takes ownership of |preferences|. |
| 50 ConfigurationPolicyProviderMac( | 50 ConfigurationPolicyProviderMac( |
| 51 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, | 51 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, |
| 52 MacPreferences* preferences); | 52 MacPreferences* preferences); |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); | 54 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace policy | 57 } // namespace policy |
| 58 | 58 |
| 59 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ | 59 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ |
| OLD | NEW |