| 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 COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class PolicyMap; | 26 class PolicyMap; |
| 27 class Schema; | 27 class Schema; |
| 28 | 28 |
| 29 // A policy loader that loads policies from the Mac preferences system, and | 29 // A policy loader that loads policies from the Mac preferences system, and |
| 30 // watches the managed preferences files for updates. | 30 // watches the managed preferences files for updates. |
| 31 class POLICY_EXPORT PolicyLoaderMac : public AsyncPolicyLoader { | 31 class POLICY_EXPORT PolicyLoaderMac : public AsyncPolicyLoader { |
| 32 public: | 32 public: |
| 33 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, | 33 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 34 const base::FilePath& managed_policy_path, | 34 const base::FilePath& managed_policy_path, |
| 35 MacPreferences* preferences); | 35 MacPreferences* preferences); |
| 36 |
| 37 // |application_id| will be passed into Mac's Preference Utilities API |
| 38 // instead of the default value of kCFPreferencesCurrentApplication. |
| 39 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 40 const base::FilePath& managed_policy_path, |
| 41 MacPreferences* preferences, |
| 42 CFStringRef application_id); |
| 43 |
| 36 ~PolicyLoaderMac() override; | 44 ~PolicyLoaderMac() override; |
| 37 | 45 |
| 38 // AsyncPolicyLoader implementation. | 46 // AsyncPolicyLoader implementation. |
| 39 void InitOnBackgroundThread() override; | 47 void InitOnBackgroundThread() override; |
| 40 scoped_ptr<PolicyBundle> Load() override; | 48 scoped_ptr<PolicyBundle> Load() override; |
| 41 base::Time LastModificationTime() override; | 49 base::Time LastModificationTime() override; |
| 42 | 50 |
| 51 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 52 // Gets the path to the preferences (.plist) file associated with the given |
| 53 // |bundle_id|. |
| 54 static base::FilePath GetManagedPolicyPath(CFStringRef bundle_id); |
| 55 #endif |
| 56 |
| 43 private: | 57 private: |
| 44 // Callback for the FilePathWatcher. | 58 // Callback for the FilePathWatcher. |
| 45 void OnFileUpdated(const base::FilePath& path, bool error); | 59 void OnFileUpdated(const base::FilePath& path, bool error); |
| 46 | 60 |
| 47 // Loads policies for the components described in the current schema_map() | 61 // Loads policies for the components described in the current schema_map() |
| 48 // which belong to the domain |domain_name|, and stores them in the |bundle|. | 62 // which belong to the domain |domain_name|, and stores them in the |bundle|. |
| 49 void LoadPolicyForDomain( | 63 void LoadPolicyForDomain( |
| 50 PolicyDomain domain, | 64 PolicyDomain domain, |
| 51 const std::string& domain_name, | 65 const std::string& domain_name, |
| 52 PolicyBundle* bundle); | 66 PolicyBundle* bundle); |
| 53 | 67 |
| 54 // Loads the policies described in |schema| from the bundle identified by | 68 // Loads the policies described in |schema| from the bundle identified by |
| 55 // |bundle_id_string|, and stores them in |policy|. | 69 // |bundle_id_string|, and stores them in |policy|. |
| 56 void LoadPolicyForComponent(const std::string& bundle_id_string, | 70 void LoadPolicyForComponent(const std::string& bundle_id_string, |
| 57 const Schema& schema, | 71 const Schema& schema, |
| 58 PolicyMap* policy); | 72 PolicyMap* policy); |
| 59 | 73 |
| 60 scoped_ptr<MacPreferences> preferences_; | 74 scoped_ptr<MacPreferences> preferences_; |
| 61 | 75 |
| 62 // Path to the managed preferences file for the current user, if it could | 76 // Path to the managed preferences file for the current user, if it could |
| 63 // be found. Updates of this file trigger a policy reload. | 77 // be found. Updates of this file trigger a policy reload. |
| 64 base::FilePath managed_policy_path_; | 78 base::FilePath managed_policy_path_; |
| 65 | 79 |
| 66 // Watches for events on the |managed_policy_path_|. | 80 // Watches for events on the |managed_policy_path_|. |
| 67 base::FilePathWatcher watcher_; | 81 base::FilePathWatcher watcher_; |
| 68 | 82 |
| 83 // Application ID to pass into Mac's Preference Utilities API. |
| 84 CFStringRef application_id_; |
| 85 |
| 69 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); | 86 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); |
| 70 }; | 87 }; |
| 71 | 88 |
| 72 } // namespace policy | 89 } // namespace policy |
| 73 | 90 |
| 74 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ | 91 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ |
| OLD | NEW |