OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "chrome/browser/policy/cloud_policy_constants.h" |
13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 14 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
14 | 15 |
15 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
16 #include "chrome/browser/policy/device_status_collector.h" | 17 #include "chrome/browser/policy/device_status_collector.h" |
17 #endif | 18 #endif |
18 | 19 |
19 namespace policy { | 20 namespace policy { |
20 | 21 |
21 // Stores in memory all the data that is used in the cloud policy subsystem, | 22 // Stores in memory all the data that is used in the cloud policy subsystem, |
22 // and manages notification about changes to these fields. | 23 // and manages notification about changes to these fields. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void SetupForTesting(const std::string& device_token, | 76 void SetupForTesting(const std::string& device_token, |
76 const std::string& device_id, | 77 const std::string& device_id, |
77 const std::string& user_name, | 78 const std::string& user_name, |
78 const std::string& gaia_token, | 79 const std::string& gaia_token, |
79 bool token_cache_loaded); | 80 bool token_cache_loaded); |
80 | 81 |
81 void set_device_id(const std::string& device_id); | 82 void set_device_id(const std::string& device_id); |
82 void set_machine_id(const std::string& machine_id); | 83 void set_machine_id(const std::string& machine_id); |
83 void set_machine_model(const std::string& machine_model); | 84 void set_machine_model(const std::string& machine_model); |
84 void set_user_name(const std::string& user_name); | 85 void set_user_name(const std::string& user_name); |
85 void set_user_affiliation(UserAffiliation user_affiliation); | 86 void set_user_affiliation(policy::UserAffiliation user_affiliation); |
86 | 87 |
87 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
88 void set_device_status_collector(DeviceStatusCollector* collector); | 89 void set_device_status_collector(DeviceStatusCollector* collector); |
89 DeviceStatusCollector* device_status_collector(); | 90 DeviceStatusCollector* device_status_collector(); |
90 #endif | 91 #endif |
91 | 92 |
92 const std::string& device_id() const; | 93 const std::string& device_id() const; |
93 const std::string& device_token() const; | 94 const std::string& device_token() const; |
94 const std::string& gaia_token() const; | 95 const std::string& gaia_token() const; |
95 const std::string& oauth_token() const; | 96 const std::string& oauth_token() const; |
96 bool has_auth_token() const; | 97 bool has_auth_token() const; |
97 const std::string& machine_id() const; | 98 const std::string& machine_id() const; |
98 const std::string& machine_model() const; | 99 const std::string& machine_model() const; |
99 enterprise_management::DeviceRegisterRequest_Type | 100 enterprise_management::DeviceRegisterRequest_Type |
100 policy_register_type() const; | 101 policy_register_type() const; |
101 const std::string& policy_type() const; | 102 const std::string& policy_type() const; |
102 bool token_cache_loaded() const; | 103 bool token_cache_loaded() const; |
103 const std::string& user_name() const; | 104 const std::string& user_name() const; |
104 UserAffiliation user_affiliation() const; | 105 policy::UserAffiliation user_affiliation() const; |
105 | 106 |
106 void AddObserver(Observer* observer); | 107 void AddObserver(Observer* observer); |
107 void RemoveObserver(Observer* observer); | 108 void RemoveObserver(Observer* observer); |
108 | 109 |
109 void NotifyCredentialsChanged(); | 110 void NotifyCredentialsChanged(); |
110 void NotifyDeviceTokenChanged(); | 111 void NotifyDeviceTokenChanged(); |
111 | 112 |
112 private: | 113 private: |
113 CloudPolicyDataStore( | 114 CloudPolicyDataStore( |
114 const enterprise_management::DeviceRegisterRequest_Type register_type, | 115 const enterprise_management::DeviceRegisterRequest_Type register_type, |
115 const std::string& policy_type); | 116 const std::string& policy_type); |
116 | 117 |
117 // Data necessary for constructing register requests. | 118 // Data necessary for constructing register requests. |
118 std::string gaia_token_; | 119 std::string gaia_token_; |
119 std::string oauth_token_; | 120 std::string oauth_token_; |
120 std::string user_name_; | 121 std::string user_name_; |
121 | 122 |
122 // Data necessary for constructing policy requests. | 123 // Data necessary for constructing policy requests. |
123 std::string device_token_; | 124 std::string device_token_; |
124 UserAffiliation user_affiliation_; | 125 policy::UserAffiliation user_affiliation_; |
125 | 126 |
126 // Constants that won't change over the life-time of a cloud policy | 127 // Constants that won't change over the life-time of a cloud policy |
127 // subsystem. | 128 // subsystem. |
128 const enterprise_management::DeviceRegisterRequest_Type policy_register_type_; | 129 const enterprise_management::DeviceRegisterRequest_Type policy_register_type_; |
129 const std::string policy_type_; | 130 const std::string policy_type_; |
130 | 131 |
131 // Data used for constructiong both register and policy requests. | 132 // Data used for constructiong both register and policy requests. |
132 std::string device_id_; | 133 std::string device_id_; |
133 std::string machine_model_; | 134 std::string machine_model_; |
134 std::string machine_id_; | 135 std::string machine_id_; |
135 | 136 |
136 bool token_cache_loaded_; | 137 bool token_cache_loaded_; |
137 | 138 |
138 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
139 scoped_ptr<DeviceStatusCollector> device_status_collector_; | 140 scoped_ptr<DeviceStatusCollector> device_status_collector_; |
140 #endif | 141 #endif |
141 | 142 |
142 ObserverList<Observer, true> observer_list_; | 143 ObserverList<Observer, true> observer_list_; |
143 | 144 |
144 DISALLOW_COPY_AND_ASSIGN(CloudPolicyDataStore); | 145 DISALLOW_COPY_AND_ASSIGN(CloudPolicyDataStore); |
145 }; | 146 }; |
146 | 147 |
147 } // namespace policy | 148 } // namespace policy |
148 | 149 |
149 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ | 150 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_DATA_STORE_H_ |
OLD | NEW |