| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_POLICY_LOADER_MAC_H_ | 5 #ifndef CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_ |
| 6 #define CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_ | 6 #define CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include <CoreFoundation/CoreFoundation.h> | 10 #include <CoreFoundation/CoreFoundation.h> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_path_watcher.h" | 13 #include "base/files/file_path_watcher.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "chrome/browser/policy/async_policy_loader.h" | 15 #include "chrome/browser/policy/async_policy_loader.h" |
| 16 #include "components/policy/core/common/policy_namespace.h" | 16 #include "components/policy/core/common/policy_namespace.h" |
| 17 | 17 |
| 18 class MacPreferences; | 18 class MacPreferences; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class SequencedTaskRunner; | 21 class SequencedTaskRunner; |
| 22 class Value; | 22 class Value; |
| 23 } // namespace base | 23 } // namespace base |
| 24 | 24 |
| 25 namespace policy { | 25 namespace policy { |
| 26 | 26 |
| 27 class PolicyBundle; | 27 class PolicyBundle; |
| 28 class PolicyMap; | 28 class PolicyMap; |
| 29 class Schema; | 29 class Schema; |
| 30 struct PolicyDefinitionList; | |
| 31 | 30 |
| 32 // A policy loader that loads policies from the Mac preferences system, and | 31 // A policy loader that loads policies from the Mac preferences system, and |
| 33 // watches the managed preferences files for updates. | 32 // watches the managed preferences files for updates. |
| 34 class PolicyLoaderMac : public AsyncPolicyLoader { | 33 class PolicyLoaderMac : public AsyncPolicyLoader { |
| 35 public: | 34 public: |
| 36 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, | 35 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 37 const PolicyDefinitionList* policy_list, | |
| 38 const base::FilePath& managed_policy_path, | 36 const base::FilePath& managed_policy_path, |
| 39 MacPreferences* preferences); | 37 MacPreferences* preferences); |
| 40 virtual ~PolicyLoaderMac(); | 38 virtual ~PolicyLoaderMac(); |
| 41 | 39 |
| 42 // AsyncPolicyLoader implementation. | 40 // AsyncPolicyLoader implementation. |
| 43 virtual void InitOnBackgroundThread() OVERRIDE; | 41 virtual void InitOnBackgroundThread() OVERRIDE; |
| 44 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 42 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; |
| 45 virtual base::Time LastModificationTime() OVERRIDE; | 43 virtual base::Time LastModificationTime() OVERRIDE; |
| 46 | 44 |
| 47 // Converts a CFPropertyListRef to the equivalent base::Value. CFDictionary | 45 // Converts a CFPropertyListRef to the equivalent base::Value. CFDictionary |
| (...skipping 12 matching lines...) Expand all Loading... |
| 60 PolicyDomain domain, | 58 PolicyDomain domain, |
| 61 const std::string& domain_name, | 59 const std::string& domain_name, |
| 62 PolicyBundle* bundle); | 60 PolicyBundle* bundle); |
| 63 | 61 |
| 64 // Loads the policies described in |schema| from the bundle identified by | 62 // Loads the policies described in |schema| from the bundle identified by |
| 65 // |bundle_id_string|, and stores them in |policy|. | 63 // |bundle_id_string|, and stores them in |policy|. |
| 66 void LoadPolicyForComponent(const std::string& bundle_id_string, | 64 void LoadPolicyForComponent(const std::string& bundle_id_string, |
| 67 const Schema& schema, | 65 const Schema& schema, |
| 68 PolicyMap* policy); | 66 PolicyMap* policy); |
| 69 | 67 |
| 70 // List of recognized policies. | |
| 71 const PolicyDefinitionList* policy_list_; | |
| 72 | |
| 73 scoped_ptr<MacPreferences> preferences_; | 68 scoped_ptr<MacPreferences> preferences_; |
| 74 | 69 |
| 75 // Path to the managed preferences file for the current user, if it could | 70 // Path to the managed preferences file for the current user, if it could |
| 76 // be found. Updates of this file trigger a policy reload. | 71 // be found. Updates of this file trigger a policy reload. |
| 77 base::FilePath managed_policy_path_; | 72 base::FilePath managed_policy_path_; |
| 78 | 73 |
| 79 // Watches for events on the |managed_policy_path_|. | 74 // Watches for events on the |managed_policy_path_|. |
| 80 base::FilePathWatcher watcher_; | 75 base::FilePathWatcher watcher_; |
| 81 | 76 |
| 82 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); | 77 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); |
| 83 }; | 78 }; |
| 84 | 79 |
| 85 } // namespace policy | 80 } // namespace policy |
| 86 | 81 |
| 87 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_ | 82 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_ |
| OLD | NEW |