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

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

Issue 6705031: Send policy blobs to session_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_
7
8 #include "base/gtest_prod_util.h"
9 #include "base/observer_list.h"
10 #include "base/scoped_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "base/time.h"
13 #include "chrome/browser/policy/configuration_policy_provider.h"
14 #include "chrome/browser/policy/policy_map.h"
15 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
16
17 namespace policy {
18
19 class PolicyMap;
20
21 namespace em = enterprise_management;
22
23 // Caches policy information, as set by calls to |SetPolicy()|, persists
24 // it to disk or session_manager (depending on subclass implementation),
25 // and makes it available via policy providers.
26 class CloudPolicyCacheBase : public base::NonThreadSafe {
27 public:
28 // Used to distinguish mandatory from recommended policies.
29 enum PolicyLevel {
30 // Policy is forced upon the user and should always take effect.
31 POLICY_LEVEL_MANDATORY,
32 // The value is just a recommendation that the user may override.
33 POLICY_LEVEL_RECOMMENDED,
34 };
35
36 CloudPolicyCacheBase();
37 virtual ~CloudPolicyCacheBase();
38
39 // Loads persisted policy information.
40 virtual void Load() = 0;
41
42 // Resets the policy information.
43 virtual void SetPolicy(const em::PolicyFetchResponse& policy) = 0;
44
45 ConfigurationPolicyProvider* GetManagedPolicyProvider();
46 ConfigurationPolicyProvider* GetRecommendedPolicyProvider();
47
48 virtual void SetUnmanaged() = 0;
Mattias Nissler (ping if slow) 2011/03/24 18:55:57 Why is the setter virtual and getter not? Should w
Jakob Kummerow 2011/03/28 13:53:53 Because what the setter needs to do depends on the
49 bool is_unmanaged() const {
50 return is_unmanaged_;
51 }
52
53 // Returns the time at which the policy was last fetched.
54 base::Time last_policy_refresh_time() const {
55 return last_policy_refresh_time_;
56 }
57
58 protected:
59 // Decodes the given |policy| using |DecodePolicyResponse()|, applies the
60 // contents to |{mandatory,recommended}_policy_|, and notifies observers.
61 // Returns true upon success.
62 bool SetPolicyInternal(const em::PolicyFetchResponse& policy);
63
64 // Decodes |policy_data|, populating |mandatory| and |recommended| with
65 // the results.
66 virtual bool DecodePolicyData(const em::PolicyData& policy_data,
67 PolicyMap* mandatory,
68 PolicyMap* recommended) = 0;
69
70 // Decodes a PolicyFetchResponse into two PolicyMaps and a timestamp.
71 // Also performs verification, returns NULL if any check fails.
72 bool DecodePolicyResponse(
73 const em::PolicyFetchResponse& policy_response,
74 PolicyMap* mandatory,
75 PolicyMap* recommended,
76 base::Time* timestamp);
77
78 // Policy key-value information.
79 PolicyMap mandatory_policy_;
80 PolicyMap recommended_policy_;
Mattias Nissler (ping if slow) 2011/03/24 18:55:57 Does this need to be protected?
Jakob Kummerow 2011/03/28 13:53:53 Done -- managed to make it private.
81
82 // Whether initialization has been completed. This is the case when we have
83 // valid policy, learned that the device is unmanaged or ran into
84 // unrecoverable errors.
85 bool initialization_complete_;
Mattias Nissler (ping if slow) 2011/03/24 18:55:57 Same question here?
Jakob Kummerow 2011/03/28 13:53:53 UserPolicyCache needs to read it. I made the membe
86
87 // Whether the the server has indicated this device is unmanaged.
88 bool is_unmanaged_;
89
90 // The time at which the policy was last refreshed.
91 base::Time last_policy_refresh_time_;
Mattias Nissler (ping if slow) 2011/03/24 18:55:57 And here?
Jakob Kummerow 2011/03/28 13:53:53 Currently, both when this field is set and to whic
92
93 // Provider observers that are registered with this cache's providers.
94 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_;
Mattias Nissler (ping if slow) 2011/03/24 18:55:57 And here?
Jakob Kummerow 2011/03/28 13:53:53 Done -- managed to make it private.
95
96 private:
97 class CloudPolicyProvider;
98
99 friend class DevicePolicyCacheTest;
100 friend class UserPolicyCacheTest;
101
102 // Policy providers.
103 scoped_ptr<ConfigurationPolicyProvider> managed_policy_provider_;
104 scoped_ptr<ConfigurationPolicyProvider> recommended_policy_provider_;
105
106 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCacheBase);
107 };
108
109 } // namespace policy
110
111 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698