blob: ed1d33a1a2fc4cbf25d6e1f9d1bd6643671ed99d (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2011 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 CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_
#define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_
#pragma once
#include "base/observer_list.h"
#include "chrome/browser/policy/cloud_policy_cache_base.h"
#include "chrome/browser/policy/cloud_policy_provider.h"
#include "chrome/browser/policy/policy_map.h"
namespace policy {
class CloudPolicyProviderImpl : public CloudPolicyProvider,
public CloudPolicyCacheBase::Observer {
public:
CloudPolicyProviderImpl(const PolicyDefinitionList* policy_list,
CloudPolicyCacheBase::PolicyLevel level);
virtual ~CloudPolicyProviderImpl();
// ConfigurationPolicyProvider implementation.
virtual bool Provide(PolicyMap* result) OVERRIDE;
virtual bool IsInitializationComplete() const OVERRIDE;
virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer)
OVERRIDE;
virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer)
OVERRIDE;
// CloudPolicyCacheBase::Observer implementation.
virtual void OnCacheUpdate(CloudPolicyCacheBase* cache) OVERRIDE;
virtual void OnCacheGoingAway(CloudPolicyCacheBase* cache) OVERRIDE;
virtual void AppendCache(CloudPolicyCacheBase* cache) OVERRIDE;
virtual void PrependCache(CloudPolicyCacheBase* cache) OVERRIDE;
private:
friend class CloudPolicyProviderTest;
// Combines two PolicyMap and stores the result in out_map. The policies in
// |base| take precedence over the policies in |overlay|. Proxy policies are
// only applied in groups, that is if at least one proxy policy is present in
// |base| then no proxy related policy of |overlay| will be applied.
static void CombineTwoPolicyMaps(const PolicyMap& base,
const PolicyMap& overlay,
PolicyMap* out_map);
// Recompute |combined_| from |caches_| and trigger an OnUpdatePolicy if
// something changed. This is called whenever a change in one of the caches
// is observed. For i=0..n-1: |caches_[i]| will contribute all its policies
// except those already provided by |caches_[0]|..|caches_[i-1]|. Proxy
// related policies are handled as a special case: they are only applied in
// groups.
void RecombineCachesAndMaybeTriggerUpdate();
// The underlying policy caches.
typedef std::vector<CloudPolicyCacheBase*> ListType;
ListType caches_;
// Policy level this provider will handle.
CloudPolicyCacheBase::PolicyLevel level_;
// Whether all caches are fully initialized.
bool initialization_complete_;
// Provider observers that are registered with this provider.
ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_;
// The currently valid combination of all the maps in |caches_|. Will be
// applied as is on call of Provide.
PolicyMap combined_;
DISALLOW_COPY_AND_ASSIGN(CloudPolicyProviderImpl);
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_
|