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

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

Issue 7298012: Consolidate data storage and notifications in the cloud policy subsystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments + tweaks Created 9 years, 5 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_DEVICE_POLICY_CACHE_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string>
10
11 #include "base/memory/scoped_callback_factory.h" 9 #include "base/memory/scoped_callback_factory.h"
12 #include "chrome/browser/chromeos/login/signed_settings.h" 10 #include "chrome/browser/chromeos/login/signed_settings.h"
13 #include "chrome/browser/chromeos/login/signed_settings_helper.h" 11 #include "chrome/browser/chromeos/login/signed_settings_helper.h"
14 #include "chrome/browser/policy/cloud_policy_cache_base.h" 12 #include "chrome/browser/policy/cloud_policy_cache_base.h"
15 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" 13 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h"
16 14
17 namespace policy { 15 namespace policy {
18 16
19 class DevicePolicyIdentityStrategy;
20 class EnterpriseInstallAttributes; 17 class EnterpriseInstallAttributes;
21 class PolicyMap; 18 class PolicyMap;
22 19
23 namespace em = enterprise_management; 20 namespace em = enterprise_management;
24 21
25 // CloudPolicyCacheBase implementation that persists policy information 22 // CloudPolicyCacheBase implementation that persists policy information
26 // to ChromeOS' session manager (via SignedSettingsHelper). 23 // to ChromeOS' session manager (via SignedSettingsHelper).
27 class DevicePolicyCache : public CloudPolicyCacheBase, 24 class DevicePolicyCache : public CloudPolicyCacheBase,
28 public chromeos::SignedSettingsHelper::Callback { 25 public chromeos::SignedSettingsHelper::Callback {
29 public: 26 public:
30 explicit DevicePolicyCache(DevicePolicyIdentityStrategy* identity_strategy, 27 explicit DevicePolicyCache(CloudPolicyData* data,
31 EnterpriseInstallAttributes* install_attributes); 28 EnterpriseInstallAttributes* install_attributes);
32 virtual ~DevicePolicyCache(); 29 virtual ~DevicePolicyCache();
33 30
34 // CloudPolicyCacheBase implementation: 31 // CloudPolicyCacheBase implementation:
35 virtual void Load() OVERRIDE; 32 virtual void Load() OVERRIDE;
36 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; 33 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE;
37 virtual void SetUnmanaged() OVERRIDE; 34 virtual void SetUnmanaged() OVERRIDE;
38 virtual bool IsReady() OVERRIDE; 35 virtual bool IsReady() OVERRIDE;
39 36
40 // SignedSettingsHelper::Callback implementation: 37 // SignedSettingsHelper::Callback implementation:
41 virtual void OnRetrievePolicyCompleted( 38 virtual void OnRetrievePolicyCompleted(
42 chromeos::SignedSettings::ReturnCode code, 39 chromeos::SignedSettings::ReturnCode code,
43 const em::PolicyFetchResponse& policy) OVERRIDE; 40 const em::PolicyFetchResponse& policy) OVERRIDE;
44 41
45 private: 42 private:
46 friend class DevicePolicyCacheTest; 43 friend class DevicePolicyCacheTest;
47 44
48 // Alternate c'tor allowing tests to mock out the SignedSettingsHelper 45 // Alternate c'tor allowing tests to mock out the SignedSettingsHelper
49 // singleton. 46 // singleton.
50 DevicePolicyCache( 47 DevicePolicyCache(
51 DevicePolicyIdentityStrategy* identity_strategy, 48 CloudPolicyData* data,
52 EnterpriseInstallAttributes* install_attributes, 49 EnterpriseInstallAttributes* install_attributes,
53 chromeos::SignedSettingsHelper* signed_settings_helper); 50 chromeos::SignedSettingsHelper* signed_settings_helper);
54 51
55 // CloudPolicyCacheBase implementation: 52 // CloudPolicyCacheBase implementation:
56 virtual bool DecodePolicyData(const em::PolicyData& policy_data, 53 virtual bool DecodePolicyData(const em::PolicyData& policy_data,
57 PolicyMap* mandatory, 54 PolicyMap* mandatory,
58 PolicyMap* recommended) OVERRIDE; 55 PolicyMap* recommended) OVERRIDE;
59 56
60 void PolicyStoreOpCompleted(chromeos::SignedSettings::ReturnCode code); 57 void PolicyStoreOpCompleted(chromeos::SignedSettings::ReturnCode code);
61 58
62 // Checks with immutable attributes whether this is an enterprise device and 59 // Checks with immutable attributes whether this is an enterprise device and
63 // read the registration user if this is the case. 60 // read the registration user if this is the case.
64 void CheckImmutableAttributes(); 61 void CheckImmutableAttributes();
65 62
66 static void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, 63 static void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy,
67 PolicyMap* mandatory, 64 PolicyMap* mandatory,
68 PolicyMap* recommended); 65 PolicyMap* recommended);
69 66
70 DevicePolicyIdentityStrategy* identity_strategy_; 67 CloudPolicyData* data_;
71 EnterpriseInstallAttributes* install_attributes_; 68 EnterpriseInstallAttributes* install_attributes_;
72 69
73 chromeos::SignedSettingsHelper* signed_settings_helper_; 70 chromeos::SignedSettingsHelper* signed_settings_helper_;
74 71
75 bool starting_up_; 72 bool starting_up_;
76 73
77 base::ScopedCallbackFactory<DevicePolicyCache> callback_factory_; 74 base::ScopedCallbackFactory<DevicePolicyCache> callback_factory_;
78 75
79 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCache); 76 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCache);
80 }; 77 };
81 78
82 } // namespace policy 79 } // namespace policy
83 80
84 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ 81 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698