blob: 6ecbe92dd5288dbecf20498c0f2fe038b37ac2f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_IOS_H_
#define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_IOS_H_
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "components/policy/core/common/async_policy_loader.h"
#include "components/policy/policy_export.h"
namespace policy {
class SchemaRegistry;
// A policy loader that loads policy from the managed app configuration
// introduced in iOS 7.
class POLICY_EXPORT PolicyLoaderIOS : public AsyncPolicyLoader {
public:
explicit PolicyLoaderIOS(
SchemaRegistry* registry,
scoped_refptr<base::SequencedTaskRunner> task_runner);
PolicyLoaderIOS(const PolicyLoaderIOS&) = delete;
PolicyLoaderIOS& operator=(const PolicyLoaderIOS&) = delete;
~PolicyLoaderIOS() override;
// AsyncPolicyLoader implementation.
void InitOnBackgroundThread() override;
std::unique_ptr<PolicyBundle> Load() override;
base::Time LastModificationTime() override;
private:
void UserDefaultsChanged();
// Loads the Chrome policies in |dictionary| into the given |bundle|.
void LoadNSDictionaryToPolicyBundle(NSDictionary* dictionary,
PolicyBundle* bundle);
// Validates the given policy data against the stored |schema_|, converting
// data to the expected type if necessary. The returned value is suitable for
// adding to a PolicyMap.
base::Value ConvertPolicyDataIfNecessary(const std::string& key,
const base::Value& value);
// The schema used by |ValidatePolicyData()|.
const Schema* policy_schema_;
// Used to manage the registration for NSNotificationCenter notifications.
__strong id notification_observer_;
// Timestamp of the last notification.
// Used to coalesce repeated notifications into a single Load() call.
base::Time last_notification_time_;
// Used to Bind() a WeakPtr to |this| for the callback passed to the
// |notification_observer_|.
base::WeakPtrFactory<PolicyLoaderIOS> weak_factory_;
};
} // namespace policy
#endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_IOS_H_
|