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