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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_
10 #include "base/files/file_path.h"
11 #include "base/files/file_path_watcher.h"
12 #include "base/memory/ref_counted.h"
13 #include "components/policy/core/common/async_policy_loader.h"
14 #include "components/policy/core/common/policy_namespace.h"
15 #include "components/policy/policy_export.h"
20 class SequencedTaskRunner
;
29 // A policy loader that loads policies from the Mac preferences system, and
30 // watches the managed preferences files for updates.
31 class POLICY_EXPORT PolicyLoaderMac
: public AsyncPolicyLoader
{
33 PolicyLoaderMac(scoped_refptr
<base::SequencedTaskRunner
> task_runner
,
34 const base::FilePath
& managed_policy_path
,
35 MacPreferences
* preferences
);
36 virtual ~PolicyLoaderMac();
38 // AsyncPolicyLoader implementation.
39 virtual void InitOnBackgroundThread() OVERRIDE
;
40 virtual scoped_ptr
<PolicyBundle
> Load() OVERRIDE
;
41 virtual base::Time
LastModificationTime() OVERRIDE
;
44 // Callback for the FilePathWatcher.
45 void OnFileUpdated(const base::FilePath
& path
, bool error
);
47 // 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|.
49 void LoadPolicyForDomain(
51 const std::string
& domain_name
,
52 PolicyBundle
* bundle
);
54 // Loads the policies described in |schema| from the bundle identified by
55 // |bundle_id_string|, and stores them in |policy|.
56 void LoadPolicyForComponent(const std::string
& bundle_id_string
,
60 scoped_ptr
<MacPreferences
> preferences_
;
62 // Path to the managed preferences file for the current user, if it could
63 // be found. Updates of this file trigger a policy reload.
64 base::FilePath managed_policy_path_
;
66 // Watches for events on the |managed_policy_path_|.
67 base::FilePathWatcher watcher_
;
69 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac
);
74 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_MAC_H_