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 CallBack(from, std::string() /* no public key */, error_message); | 134 CallBack(from, std::string() /* no public key */, error_message); |
135 } | 135 } |
136 | 136 |
137 void CallBack(const tracked_objects::Location& from, | 137 void CallBack(const tracked_objects::Location& from, |
138 const std::string& public_key_spki_der, | 138 const std::string& public_key_spki_der, |
139 const std::string& error_message) { | 139 const std::string& error_message) { |
140 origin_task_runner_->PostTask( | 140 origin_task_runner_->PostTask( |
141 from, base::Bind(callback_, public_key_spki_der, error_message)); | 141 from, base::Bind(callback_, public_key_spki_der, error_message)); |
142 } | 142 } |
143 | 143 |
144 unsigned int modulus_length_; | 144 const unsigned int modulus_length_; |
145 | 145 |
146 private: | 146 private: |
147 // Must be called on origin thread, use CallBack() therefore. | 147 // Must be called on origin thread, use CallBack() therefore. |
148 GenerateKeyCallback callback_; | 148 GenerateKeyCallback callback_; |
149 }; | 149 }; |
150 | 150 |
151 class SignState : public NSSOperationState { | 151 class SignState : public NSSOperationState { |
152 public: | 152 public: |
153 SignState(const std::string& public_key, | 153 SignState(const std::string& public_key, |
154 const std::string& data, | 154 const std::string& data, |
155 const SignCallback& callback); | 155 const SignCallback& callback); |
156 virtual ~SignState() {} | 156 virtual ~SignState() {} |
157 | 157 |
158 virtual void OnError(const tracked_objects::Location& from, | 158 virtual void OnError(const tracked_objects::Location& from, |
159 const std::string& error_message) OVERRIDE { | 159 const std::string& error_message) OVERRIDE { |
160 CallBack(from, std::string() /* no signature */, error_message); | 160 CallBack(from, std::string() /* no signature */, error_message); |
161 } | 161 } |
162 | 162 |
163 void CallBack(const tracked_objects::Location& from, | 163 void CallBack(const tracked_objects::Location& from, |
164 const std::string& signature, | 164 const std::string& signature, |
165 const std::string& error_message) { | 165 const std::string& error_message) { |
166 origin_task_runner_->PostTask( | 166 origin_task_runner_->PostTask( |
167 from, base::Bind(callback_, signature, error_message)); | 167 from, base::Bind(callback_, signature, error_message)); |
168 } | 168 } |
169 | 169 |
170 std::string public_key_; | 170 const std::string public_key_; |
171 std::string data_; | 171 const std::string data_; |
172 | 172 |
173 private: | 173 private: |
174 // Must be called on origin thread, use CallBack() therefore. | 174 // Must be called on origin thread, use CallBack() therefore. |
175 SignCallback callback_; | 175 SignCallback callback_; |
176 }; | 176 }; |
177 | 177 |
178 class GetCertificatesState : public NSSOperationState { | 178 class GetCertificatesState : public NSSOperationState { |
179 public: | 179 public: |
180 explicit GetCertificatesState(const GetCertificatesCallback& callback); | 180 explicit GetCertificatesState(const GetCertificatesCallback& callback); |
181 virtual ~GetCertificatesState() {} | 181 virtual ~GetCertificatesState() {} |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // Must be called on origin thread, use CallBack() therefore. | 246 // Must be called on origin thread, use CallBack() therefore. |
247 RemoveCertificateCallback callback_; | 247 RemoveCertificateCallback callback_; |
248 }; | 248 }; |
249 | 249 |
250 NSSOperationState::NSSOperationState() | 250 NSSOperationState::NSSOperationState() |
251 : origin_task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 251 : origin_task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
252 } | 252 } |
253 | 253 |
254 GenerateRSAKeyState::GenerateRSAKeyState(unsigned int modulus_length, | 254 GenerateRSAKeyState::GenerateRSAKeyState(unsigned int modulus_length, |
255 const GenerateKeyCallback& callback) | 255 const GenerateKeyCallback& callback) |
256 : modulus_length_(modulus_length), callback_(callback) { | 256 : modulus_length_(modulus_length), |
| 257 callback_(callback) { |
257 } | 258 } |
258 | 259 |
259 SignState::SignState(const std::string& public_key, | 260 SignState::SignState(const std::string& public_key, |
260 const std::string& data, | 261 const std::string& data, |
261 const SignCallback& callback) | 262 const SignCallback& callback) |
262 : public_key_(public_key), data_(data), callback_(callback) { | 263 : public_key_(public_key), data_(data), callback_(callback) { |
263 } | 264 } |
264 | 265 |
265 GetCertificatesState::GetCertificatesState( | 266 GetCertificatesState::GetCertificatesState( |
266 const GetCertificatesCallback& callback) | 267 const GetCertificatesCallback& callback) |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 // we would get more informative error messages. | 555 // we would get more informative error messages. |
555 GetCertDatabase(token_id, | 556 GetCertDatabase(token_id, |
556 base::Bind(&RemoveCertificateWithDB, base::Passed(&state)), | 557 base::Bind(&RemoveCertificateWithDB, base::Passed(&state)), |
557 profile, | 558 profile, |
558 state_ptr); | 559 state_ptr); |
559 } | 560 } |
560 | 561 |
561 } // namespace platform_keys | 562 } // namespace platform_keys |
562 | 563 |
563 } // namespace chromeos | 564 } // namespace chromeos |
OLD | NEW |