OLD | NEW |
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_CLOUD_POLICY_DATA_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Notifies observers that the effective token for fetching policy | 28 // Notifies observers that the effective token for fetching policy |
29 // (device_token_, token_cache_loaded_) has changed. | 29 // (device_token_, token_cache_loaded_) has changed. |
30 virtual void OnDeviceTokenChanged() = 0; | 30 virtual void OnDeviceTokenChanged() = 0; |
31 | 31 |
32 // Authentication credentials for talking to the device management service | 32 // Authentication credentials for talking to the device management service |
33 // (gaia_token_) changed. | 33 // (gaia_token_) changed. |
34 virtual void OnCredentialsChanged() = 0; | 34 virtual void OnCredentialsChanged() = 0; |
35 }; | 35 }; |
36 | 36 |
| 37 // Describes the affilitation of a user w.r.t. the managed state of the |
| 38 // device. |
| 39 enum UserAffiliation { |
| 40 // User is on the same domain the device was registered with. |
| 41 USER_AFFILIATION_MANAGED, |
| 42 // No affiliation between device and user user. |
| 43 USER_AFFILIATION_NONE, |
| 44 }; |
| 45 |
37 ~CloudPolicyDataStore(); | 46 ~CloudPolicyDataStore(); |
38 | 47 |
39 // Create CloudPolicyData with constants initialized for fetching user | 48 // Create CloudPolicyData with constants initialized for fetching user |
40 // policies. | 49 // policies. |
41 static CloudPolicyDataStore* CreateForUserPolicies(); | 50 static CloudPolicyDataStore* CreateForUserPolicies(); |
42 | 51 |
43 // Create CloudPolicyData with constants initialized for fetching device | 52 // Create CloudPolicyData with constants initialized for fetching device |
44 // policies. | 53 // policies. |
45 static CloudPolicyDataStore* CreateForDevicePolicies(); | 54 static CloudPolicyDataStore* CreateForDevicePolicies(); |
46 | 55 |
(...skipping 14 matching lines...) Expand all Loading... |
61 | 70 |
62 // Only used in tests. | 71 // Only used in tests. |
63 void SetupForTesting(const std::string& device_token, | 72 void SetupForTesting(const std::string& device_token, |
64 const std::string& device_id, | 73 const std::string& device_id, |
65 const std::string& user_name, | 74 const std::string& user_name, |
66 const std::string& gaia_token, | 75 const std::string& gaia_token, |
67 bool token_cache_loaded); | 76 bool token_cache_loaded); |
68 | 77 |
69 void set_device_id(const std::string& device_id); | 78 void set_device_id(const std::string& device_id); |
70 void set_user_name(const std::string& user_name); | 79 void set_user_name(const std::string& user_name); |
| 80 void set_user_affiliation(UserAffiliation user_affiliation); |
71 | 81 |
72 const std::string& device_id() const; | 82 const std::string& device_id() const; |
73 const std::string& device_token() const; | 83 const std::string& device_token() const; |
74 const std::string& gaia_token() const; | 84 const std::string& gaia_token() const; |
75 const std::string& oauth_token() const; | 85 const std::string& oauth_token() const; |
76 bool has_auth_token() const; | 86 bool has_auth_token() const; |
77 const std::string& machine_id() const; | 87 const std::string& machine_id() const; |
78 const std::string& machine_model() const; | 88 const std::string& machine_model() const; |
79 em::DeviceRegisterRequest_Type policy_register_type() const; | 89 em::DeviceRegisterRequest_Type policy_register_type() const; |
80 const std::string& policy_type() const; | 90 const std::string& policy_type() const; |
81 bool token_cache_loaded() const; | 91 bool token_cache_loaded() const; |
82 const std::string& user_name() const; | 92 const std::string& user_name() const; |
| 93 UserAffiliation user_affiliation() const; |
83 | 94 |
84 void AddObserver(Observer* observer); | 95 void AddObserver(Observer* observer); |
85 void RemoveObserver(Observer* observer); | 96 void RemoveObserver(Observer* observer); |
86 | 97 |
87 void NotifyCredentialsChanged(); | 98 void NotifyCredentialsChanged(); |
88 void NotifyDeviceTokenChanged(); | 99 void NotifyDeviceTokenChanged(); |
89 | 100 |
90 private: | 101 private: |
91 CloudPolicyDataStore( | 102 CloudPolicyDataStore( |
92 const em::DeviceRegisterRequest_Type policy_register_type, | 103 const em::DeviceRegisterRequest_Type policy_register_type, |
93 const std::string& policy_type, | 104 const std::string& policy_type, |
94 const std::string& machine_model, | 105 const std::string& machine_model, |
95 const std::string& machine_id); | 106 const std::string& machine_id); |
96 | 107 |
97 // Data necessary for constructing register requests. | 108 // Data necessary for constructing register requests. |
98 std::string gaia_token_; | 109 std::string gaia_token_; |
99 std::string oauth_token_; | 110 std::string oauth_token_; |
100 std::string user_name_; | 111 std::string user_name_; |
101 | 112 |
102 // Data necessary for constructing policy requests. | 113 // Data necessary for constructing policy requests. |
103 std::string device_token_; | 114 std::string device_token_; |
| 115 UserAffiliation user_affiliation_; |
104 | 116 |
105 // Constants that won't change over the life-time of a cloud policy | 117 // Constants that won't change over the life-time of a cloud policy |
106 // subsystem. | 118 // subsystem. |
107 const em::DeviceRegisterRequest_Type policy_register_type_; | 119 const em::DeviceRegisterRequest_Type policy_register_type_; |
108 const std::string policy_type_; | 120 const std::string policy_type_; |
109 const std::string machine_model_; | 121 const std::string machine_model_; |
110 const std::string machine_id_; | 122 const std::string machine_id_; |
111 | 123 |
112 // Data used for constructiong both register and policy requests. | 124 // Data used for constructiong both register and policy requests. |
113 std::string device_id_; | 125 std::string device_id_; |
114 | 126 |
115 bool token_cache_loaded_; | 127 bool token_cache_loaded_; |
116 | 128 |
117 ObserverList<Observer, true> observer_list_; | 129 ObserverList<Observer, true> observer_list_; |
118 | 130 |
119 DISALLOW_COPY_AND_ASSIGN(CloudPolicyDataStore); | 131 DISALLOW_COPY_AND_ASSIGN(CloudPolicyDataStore); |
120 }; | 132 }; |
121 | 133 |
122 } // namespace policy | 134 } // namespace policy |
123 | 135 |
124 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ | 136 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ |
OLD | NEW |