| 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 29 matching lines...) Expand all Loading... |
| 40 // instead of the default value of kCFPreferencesCurrentApplication. | 40 // instead of the default value of kCFPreferencesCurrentApplication. |
| 41 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, | 41 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 42 const base::FilePath& managed_policy_path, | 42 const base::FilePath& managed_policy_path, |
| 43 MacPreferences* preferences, | 43 MacPreferences* preferences, |
| 44 CFStringRef application_id); | 44 CFStringRef application_id); |
| 45 | 45 |
| 46 ~PolicyLoaderMac() override; | 46 ~PolicyLoaderMac() override; |
| 47 | 47 |
| 48 // AsyncPolicyLoader implementation. | 48 // AsyncPolicyLoader implementation. |
| 49 void InitOnBackgroundThread() override; | 49 void InitOnBackgroundThread() override; |
| 50 scoped_ptr<PolicyBundle> Load() override; | 50 std::unique_ptr<PolicyBundle> Load() override; |
| 51 base::Time LastModificationTime() override; | 51 base::Time LastModificationTime() override; |
| 52 | 52 |
| 53 #if defined(OS_MACOSX) && !defined(OS_IOS) | 53 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 54 // Gets the path to the preferences (.plist) file associated with the given | 54 // Gets the path to the preferences (.plist) file associated with the given |
| 55 // |bundle_id|. The file at the returned path might not exist (yet). | 55 // |bundle_id|. The file at the returned path might not exist (yet). |
| 56 // Returns an empty path upon failure. | 56 // Returns an empty path upon failure. |
| 57 static base::FilePath GetManagedPolicyPath(CFStringRef bundle_id); | 57 static base::FilePath GetManagedPolicyPath(CFStringRef bundle_id); |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 // Callback for the FilePathWatcher. | 61 // Callback for the FilePathWatcher. |
| 62 void OnFileUpdated(const base::FilePath& path, bool error); | 62 void OnFileUpdated(const base::FilePath& path, bool error); |
| 63 | 63 |
| 64 // Loads policies for the components described in the current schema_map() | 64 // Loads policies for the components described in the current schema_map() |
| 65 // which belong to the domain |domain_name|, and stores them in the |bundle|. | 65 // which belong to the domain |domain_name|, and stores them in the |bundle|. |
| 66 void LoadPolicyForDomain( | 66 void LoadPolicyForDomain( |
| 67 PolicyDomain domain, | 67 PolicyDomain domain, |
| 68 const std::string& domain_name, | 68 const std::string& domain_name, |
| 69 PolicyBundle* bundle); | 69 PolicyBundle* bundle); |
| 70 | 70 |
| 71 // Loads the policies described in |schema| from the bundle identified by | 71 // Loads the policies described in |schema| from the bundle identified by |
| 72 // |bundle_id_string|, and stores them in |policy|. | 72 // |bundle_id_string|, and stores them in |policy|. |
| 73 void LoadPolicyForComponent(const std::string& bundle_id_string, | 73 void LoadPolicyForComponent(const std::string& bundle_id_string, |
| 74 const Schema& schema, | 74 const Schema& schema, |
| 75 PolicyMap* policy); | 75 PolicyMap* policy); |
| 76 | 76 |
| 77 scoped_ptr<MacPreferences> preferences_; | 77 std::unique_ptr<MacPreferences> preferences_; |
| 78 | 78 |
| 79 // Path to the managed preferences file for the current user, if it could | 79 // Path to the managed preferences file for the current user, if it could |
| 80 // be found. Updates of this file trigger a policy reload. | 80 // be found. Updates of this file trigger a policy reload. |
| 81 base::FilePath managed_policy_path_; | 81 base::FilePath managed_policy_path_; |
| 82 | 82 |
| 83 // Watches for events on the |managed_policy_path_|. | 83 // Watches for events on the |managed_policy_path_|. |
| 84 base::FilePathWatcher watcher_; | 84 base::FilePathWatcher watcher_; |
| 85 | 85 |
| 86 // Application ID to pass into Mac's Preference Utilities API. | 86 // Application ID to pass into Mac's Preference Utilities API. |
| 87 CFStringRef application_id_; | 87 CFStringRef application_id_; |
| 88 | 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); | 89 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 } // namespace policy | 92 } // namespace policy |
| 93 | 93 |
| 94 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ | 94 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_ |
| OLD | NEW |