| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/browser/policy/configuration_policy_store.h" | 10 #include "chrome/browser/policy/file_based_policy_provider.h" |
| 11 #include "chrome/browser/policy/configuration_policy_provider.h" | |
| 12 #include "chrome/browser/preferences_mac.h" | 11 #include "chrome/browser/preferences_mac.h" |
| 13 | 12 |
| 14 namespace policy { | 13 namespace policy { |
| 15 | 14 |
| 15 // A policy loader implementation that read Mac OS X's managed preferences. |
| 16 class MacPreferencesPolicyLoader : public FileBasedPolicyProvider::Delegate { |
| 17 public: |
| 18 // Takes ownership of |preferences|. |
| 19 MacPreferencesPolicyLoader( |
| 20 MacPreferences* preferences, |
| 21 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); |
| 22 |
| 23 // FileBasedPolicyLoader::Delegate implementation. |
| 24 virtual DictionaryValue* Load(); |
| 25 virtual base::Time GetLastModification(); |
| 26 |
| 27 private: |
| 28 // In order to access the application preferences API, the names and values of |
| 29 // the policies that are recognized must be known to the loader. |
| 30 // Unfortunately, we cannot get the policy list at load time from the |
| 31 // provider, because the loader may outlive the provider, so we store our own |
| 32 // pointer to the list. |
| 33 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list_; |
| 34 |
| 35 scoped_ptr<MacPreferences> preferences_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(MacPreferencesPolicyLoader); |
| 38 }; |
| 39 |
| 16 // An implementation of |ConfigurationPolicyProvider| using the mechanism | 40 // An implementation of |ConfigurationPolicyProvider| using the mechanism |
| 17 // provided by Mac OS X's managed preferences. | 41 // provided by Mac OS X's managed preferences. |
| 18 class ConfigurationPolicyProviderMac : public ConfigurationPolicyProvider { | 42 class ConfigurationPolicyProviderMac |
| 43 : public FileBasedPolicyProvider { |
| 19 public: | 44 public: |
| 20 explicit ConfigurationPolicyProviderMac( | 45 explicit ConfigurationPolicyProviderMac( |
| 21 const StaticPolicyValueMap& policy_map); | 46 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list); |
| 22 // For testing; takes ownership of |preferences|. | 47 // For testing; takes ownership of |preferences|. |
| 23 ConfigurationPolicyProviderMac(const StaticPolicyValueMap& policy_map, | 48 ConfigurationPolicyProviderMac( |
| 24 MacPreferences* preferences); | 49 const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, |
| 25 virtual ~ConfigurationPolicyProviderMac() { } | 50 MacPreferences* preferences); |
| 26 | 51 |
| 27 // ConfigurationPolicyProvider method overrides: | 52 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderMac); |
| 28 virtual bool Provide(ConfigurationPolicyStore* store); | |
| 29 | |
| 30 protected: | |
| 31 scoped_ptr<MacPreferences> preferences_; | |
| 32 }; | 53 }; |
| 33 | 54 |
| 34 } // namespace policy | 55 } // namespace policy |
| 35 | 56 |
| 36 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ | 57 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_MAC_H_ |
| OLD | NEW |