OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" | 5 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" |
6 | 6 |
7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 state)); | 134 state)); |
135 } | 135 } |
136 | 136 |
137 class GenerateRSAKeyState : public NSSOperationState { | 137 class GenerateRSAKeyState : public NSSOperationState { |
138 public: | 138 public: |
139 GenerateRSAKeyState(unsigned int modulus_length_bits, | 139 GenerateRSAKeyState(unsigned int modulus_length_bits, |
140 const subtle::GenerateKeyCallback& callback); | 140 const subtle::GenerateKeyCallback& callback); |
141 virtual ~GenerateRSAKeyState() {} | 141 virtual ~GenerateRSAKeyState() {} |
142 | 142 |
143 virtual void OnError(const tracked_objects::Location& from, | 143 virtual void OnError(const tracked_objects::Location& from, |
144 const std::string& error_message) OVERRIDE { | 144 const std::string& error_message) override { |
145 CallBack(from, std::string() /* no public key */, error_message); | 145 CallBack(from, std::string() /* no public key */, error_message); |
146 } | 146 } |
147 | 147 |
148 void CallBack(const tracked_objects::Location& from, | 148 void CallBack(const tracked_objects::Location& from, |
149 const std::string& public_key_spki_der, | 149 const std::string& public_key_spki_der, |
150 const std::string& error_message) { | 150 const std::string& error_message) { |
151 origin_task_runner_->PostTask( | 151 origin_task_runner_->PostTask( |
152 from, base::Bind(callback_, public_key_spki_der, error_message)); | 152 from, base::Bind(callback_, public_key_spki_der, error_message)); |
153 } | 153 } |
154 | 154 |
155 const unsigned int modulus_length_bits_; | 155 const unsigned int modulus_length_bits_; |
156 | 156 |
157 private: | 157 private: |
158 // Must be called on origin thread, therefore use CallBack(). | 158 // Must be called on origin thread, therefore use CallBack(). |
159 subtle::GenerateKeyCallback callback_; | 159 subtle::GenerateKeyCallback callback_; |
160 }; | 160 }; |
161 | 161 |
162 class SignState : public NSSOperationState { | 162 class SignState : public NSSOperationState { |
163 public: | 163 public: |
164 SignState(const std::string& public_key, | 164 SignState(const std::string& public_key, |
165 HashAlgorithm hash_algorithm, | 165 HashAlgorithm hash_algorithm, |
166 const std::string& data, | 166 const std::string& data, |
167 const subtle::SignCallback& callback); | 167 const subtle::SignCallback& callback); |
168 virtual ~SignState() {} | 168 virtual ~SignState() {} |
169 | 169 |
170 virtual void OnError(const tracked_objects::Location& from, | 170 virtual void OnError(const tracked_objects::Location& from, |
171 const std::string& error_message) OVERRIDE { | 171 const std::string& error_message) override { |
172 CallBack(from, std::string() /* no signature */, error_message); | 172 CallBack(from, std::string() /* no signature */, error_message); |
173 } | 173 } |
174 | 174 |
175 void CallBack(const tracked_objects::Location& from, | 175 void CallBack(const tracked_objects::Location& from, |
176 const std::string& signature, | 176 const std::string& signature, |
177 const std::string& error_message) { | 177 const std::string& error_message) { |
178 origin_task_runner_->PostTask( | 178 origin_task_runner_->PostTask( |
179 from, base::Bind(callback_, signature, error_message)); | 179 from, base::Bind(callback_, signature, error_message)); |
180 } | 180 } |
181 | 181 |
182 const std::string public_key_; | 182 const std::string public_key_; |
183 HashAlgorithm hash_algorithm_; | 183 HashAlgorithm hash_algorithm_; |
184 const std::string data_; | 184 const std::string data_; |
185 | 185 |
186 private: | 186 private: |
187 // Must be called on origin thread, therefore use CallBack(). | 187 // Must be called on origin thread, therefore use CallBack(). |
188 subtle::SignCallback callback_; | 188 subtle::SignCallback callback_; |
189 }; | 189 }; |
190 | 190 |
191 class GetCertificatesState : public NSSOperationState { | 191 class GetCertificatesState : public NSSOperationState { |
192 public: | 192 public: |
193 explicit GetCertificatesState(const GetCertificatesCallback& callback); | 193 explicit GetCertificatesState(const GetCertificatesCallback& callback); |
194 virtual ~GetCertificatesState() {} | 194 virtual ~GetCertificatesState() {} |
195 | 195 |
196 virtual void OnError(const tracked_objects::Location& from, | 196 virtual void OnError(const tracked_objects::Location& from, |
197 const std::string& error_message) OVERRIDE { | 197 const std::string& error_message) override { |
198 CallBack(from, | 198 CallBack(from, |
199 scoped_ptr<net::CertificateList>() /* no certificates */, | 199 scoped_ptr<net::CertificateList>() /* no certificates */, |
200 error_message); | 200 error_message); |
201 } | 201 } |
202 | 202 |
203 void CallBack(const tracked_objects::Location& from, | 203 void CallBack(const tracked_objects::Location& from, |
204 scoped_ptr<net::CertificateList> certs, | 204 scoped_ptr<net::CertificateList> certs, |
205 const std::string& error_message) { | 205 const std::string& error_message) { |
206 origin_task_runner_->PostTask( | 206 origin_task_runner_->PostTask( |
207 from, base::Bind(callback_, base::Passed(&certs), error_message)); | 207 from, base::Bind(callback_, base::Passed(&certs), error_message)); |
208 } | 208 } |
209 | 209 |
210 scoped_ptr<net::CertificateList> certs_; | 210 scoped_ptr<net::CertificateList> certs_; |
211 | 211 |
212 private: | 212 private: |
213 // Must be called on origin thread, therefore use CallBack(). | 213 // Must be called on origin thread, therefore use CallBack(). |
214 GetCertificatesCallback callback_; | 214 GetCertificatesCallback callback_; |
215 }; | 215 }; |
216 | 216 |
217 class ImportCertificateState : public NSSOperationState { | 217 class ImportCertificateState : public NSSOperationState { |
218 public: | 218 public: |
219 ImportCertificateState(scoped_refptr<net::X509Certificate> certificate, | 219 ImportCertificateState(scoped_refptr<net::X509Certificate> certificate, |
220 const ImportCertificateCallback& callback); | 220 const ImportCertificateCallback& callback); |
221 virtual ~ImportCertificateState() {} | 221 virtual ~ImportCertificateState() {} |
222 | 222 |
223 virtual void OnError(const tracked_objects::Location& from, | 223 virtual void OnError(const tracked_objects::Location& from, |
224 const std::string& error_message) OVERRIDE { | 224 const std::string& error_message) override { |
225 CallBack(from, error_message); | 225 CallBack(from, error_message); |
226 } | 226 } |
227 | 227 |
228 void CallBack(const tracked_objects::Location& from, | 228 void CallBack(const tracked_objects::Location& from, |
229 const std::string& error_message) { | 229 const std::string& error_message) { |
230 origin_task_runner_->PostTask(from, base::Bind(callback_, error_message)); | 230 origin_task_runner_->PostTask(from, base::Bind(callback_, error_message)); |
231 } | 231 } |
232 | 232 |
233 scoped_refptr<net::X509Certificate> certificate_; | 233 scoped_refptr<net::X509Certificate> certificate_; |
234 | 234 |
235 private: | 235 private: |
236 // Must be called on origin thread, therefore use CallBack(). | 236 // Must be called on origin thread, therefore use CallBack(). |
237 ImportCertificateCallback callback_; | 237 ImportCertificateCallback callback_; |
238 }; | 238 }; |
239 | 239 |
240 class RemoveCertificateState : public NSSOperationState { | 240 class RemoveCertificateState : public NSSOperationState { |
241 public: | 241 public: |
242 RemoveCertificateState(scoped_refptr<net::X509Certificate> certificate, | 242 RemoveCertificateState(scoped_refptr<net::X509Certificate> certificate, |
243 const RemoveCertificateCallback& callback); | 243 const RemoveCertificateCallback& callback); |
244 virtual ~RemoveCertificateState() {} | 244 virtual ~RemoveCertificateState() {} |
245 | 245 |
246 virtual void OnError(const tracked_objects::Location& from, | 246 virtual void OnError(const tracked_objects::Location& from, |
247 const std::string& error_message) OVERRIDE { | 247 const std::string& error_message) override { |
248 CallBack(from, error_message); | 248 CallBack(from, error_message); |
249 } | 249 } |
250 | 250 |
251 void CallBack(const tracked_objects::Location& from, | 251 void CallBack(const tracked_objects::Location& from, |
252 const std::string& error_message) { | 252 const std::string& error_message) { |
253 origin_task_runner_->PostTask(from, base::Bind(callback_, error_message)); | 253 origin_task_runner_->PostTask(from, base::Bind(callback_, error_message)); |
254 } | 254 } |
255 | 255 |
256 scoped_refptr<net::X509Certificate> certificate_; | 256 scoped_refptr<net::X509Certificate> certificate_; |
257 | 257 |
258 private: | 258 private: |
259 // Must be called on origin thread, therefore use CallBack(). | 259 // Must be called on origin thread, therefore use CallBack(). |
260 RemoveCertificateCallback callback_; | 260 RemoveCertificateCallback callback_; |
261 }; | 261 }; |
262 | 262 |
263 class GetTokensState : public NSSOperationState { | 263 class GetTokensState : public NSSOperationState { |
264 public: | 264 public: |
265 explicit GetTokensState(const GetTokensCallback& callback); | 265 explicit GetTokensState(const GetTokensCallback& callback); |
266 virtual ~GetTokensState() {} | 266 virtual ~GetTokensState() {} |
267 | 267 |
268 virtual void OnError(const tracked_objects::Location& from, | 268 virtual void OnError(const tracked_objects::Location& from, |
269 const std::string& error_message) OVERRIDE { | 269 const std::string& error_message) override { |
270 CallBack(from, | 270 CallBack(from, |
271 scoped_ptr<std::vector<std::string> >() /* no token ids */, | 271 scoped_ptr<std::vector<std::string> >() /* no token ids */, |
272 error_message); | 272 error_message); |
273 } | 273 } |
274 | 274 |
275 void CallBack(const tracked_objects::Location& from, | 275 void CallBack(const tracked_objects::Location& from, |
276 scoped_ptr<std::vector<std::string> > token_ids, | 276 scoped_ptr<std::vector<std::string> > token_ids, |
277 const std::string& error_message) { | 277 const std::string& error_message) { |
278 origin_task_runner_->PostTask( | 278 origin_task_runner_->PostTask( |
279 from, base::Bind(callback_, base::Passed(&token_ids), error_message)); | 279 from, base::Bind(callback_, base::Passed(&token_ids), error_message)); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 NSSOperationState* state_ptr = state.get(); | 656 NSSOperationState* state_ptr = state.get(); |
657 GetCertDatabase(std::string() /* don't get any specific slot */, | 657 GetCertDatabase(std::string() /* don't get any specific slot */, |
658 base::Bind(&GetTokensWithDB, base::Passed(&state)), | 658 base::Bind(&GetTokensWithDB, base::Passed(&state)), |
659 browser_context, | 659 browser_context, |
660 state_ptr); | 660 state_ptr); |
661 } | 661 } |
662 | 662 |
663 } // namespace platform_keys | 663 } // namespace platform_keys |
664 | 664 |
665 } // namespace chromeos | 665 } // namespace chromeos |
OLD | NEW |