Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/policy/policy_loader_mac.h

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: Fixed mac tests Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16
17 class MacPreferences; 17 class MacPreferences;
18 18
19 namespace base { 19 namespace base {
20 class SequencedTaskRunner; 20 class SequencedTaskRunner;
21 class Value; 21 class Value;
22 } // namespace base 22 } // namespace base
23 23
24 namespace policy { 24 namespace policy {
25 25
26 class PolicyDomainDescriptor;
27 class PolicyMap; 26 class PolicyMap;
28 class Schema; 27 class Schema;
29 struct PolicyDefinitionList; 28 struct PolicyDefinitionList;
30 29
31 // A policy loader that loads policies from the Mac preferences system, and 30 // A policy loader that loads policies from the Mac preferences system, and
32 // watches the managed preferences files for updates. 31 // watches the managed preferences files for updates.
33 class PolicyLoaderMac : public AsyncPolicyLoader { 32 class PolicyLoaderMac : public AsyncPolicyLoader {
34 public: 33 public:
35 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner, 34 PolicyLoaderMac(scoped_refptr<base::SequencedTaskRunner> task_runner,
36 const PolicyDefinitionList* policy_list, 35 const PolicyDefinitionList* policy_list,
37 const base::FilePath& managed_policy_path, 36 const base::FilePath& managed_policy_path,
38 MacPreferences* preferences); 37 MacPreferences* preferences);
39 virtual ~PolicyLoaderMac(); 38 virtual ~PolicyLoaderMac();
40 39
41 // AsyncPolicyLoader implementation. 40 // AsyncPolicyLoader implementation.
42 virtual void InitOnBackgroundThread() OVERRIDE; 41 virtual void InitOnBackgroundThread() OVERRIDE;
43 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; 42 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE;
44 virtual base::Time LastModificationTime() OVERRIDE; 43 virtual base::Time LastModificationTime() OVERRIDE;
45 44
46 // Converts a CFPropertyListRef to the equivalent base::Value. CFDictionary 45 // Converts a CFPropertyListRef to the equivalent base::Value. CFDictionary
47 // entries whose key is not a CFStringRef are ignored. 46 // entries whose key is not a CFStringRef are ignored.
48 // The returned value is owned by the caller. 47 // The returned value is owned by the caller.
49 // Returns NULL if an invalid CFType was found, such as CFDate or CFData. 48 // Returns NULL if an invalid CFType was found, such as CFDate or CFData.
50 static base::Value* CreateValueFromProperty(CFPropertyListRef property); 49 static base::Value* CreateValueFromProperty(CFPropertyListRef property);
51 50
52 private: 51 private:
53 // Callback for the FilePathWatcher. 52 // Callback for the FilePathWatcher.
54 void OnFileUpdated(const base::FilePath& path, bool error); 53 void OnFileUpdated(const base::FilePath& path, bool error);
55 54
56 // Loads policies for the components described in |descriptor|, which belong 55 // Loads policies for the components described in the current SchemaMap,
bartfab (slow) 2013/11/05 15:53:04 Nit 1: s/SchemaMap/schema_map_/ (reference the mem
Joao da Silva 2013/11/07 13:15:00 Done.
57 // to the domain |domain_name|, and stores them in the |bundle|. 56 // which belong to the domain |domain_name|, and stores them in the |bundle|.
58 void LoadPolicyForDomain( 57 void LoadPolicyForDomain(
59 scoped_refptr<const PolicyDomainDescriptor> descriptor, 58 PolicyDomain domain,
bartfab (slow) 2013/11/05 15:53:04 Nit: #include "components/policy/core/common/polic
Joao da Silva 2013/11/07 13:15:00 Done.
60 const std::string& domain_name, 59 const std::string& domain_name,
61 PolicyBundle* bundle); 60 PolicyBundle* bundle);
bartfab (slow) 2013/11/05 15:53:04 Nit: Forward-declare PolicyBundle.
Joao da Silva 2013/11/07 13:15:00 Done.
62 61
63 // Loads the policies described in |schema| from the bundle identified by 62 // Loads the policies described in |schema| from the bundle identified by
64 // |bundle_id_string|, and stores them in |policy|. 63 // |bundle_id_string|, and stores them in |policy|.
65 void LoadPolicyForComponent(const std::string& bundle_id_string, 64 void LoadPolicyForComponent(const std::string& bundle_id_string,
66 Schema schema, 65 const Schema& schema,
67 PolicyMap* policy); 66 PolicyMap* policy);
68 67
69 // List of recognized policies. 68 // List of recognized policies.
70 const PolicyDefinitionList* policy_list_; 69 const PolicyDefinitionList* policy_list_;
71 70
72 scoped_ptr<MacPreferences> preferences_; 71 scoped_ptr<MacPreferences> preferences_;
73 72
74 // Path to the managed preferences file for the current user, if it could 73 // Path to the managed preferences file for the current user, if it could
75 // be found. Updates of this file trigger a policy reload. 74 // be found. Updates of this file trigger a policy reload.
76 base::FilePath managed_policy_path_; 75 base::FilePath managed_policy_path_;
77 76
78 // Watches for events on the |managed_policy_path_|. 77 // Watches for events on the |managed_policy_path_|.
79 base::FilePathWatcher watcher_; 78 base::FilePathWatcher watcher_;
80 79
81 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac); 80 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderMac);
82 }; 81 };
83 82
84 } // namespace policy 83 } // namespace policy
85 84
86 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_ 85 #endif // CHROME_BROWSER_POLICY_POLICY_LOADER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698