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