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/extensions/api/enterprise_platform_keys/enterprise_plat
form_keys_api.h" | 5 #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_plat
form_keys_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" | 10 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 extension_id(), | 57 extension_id(), |
58 base::Bind( | 58 base::Bind( |
59 &EnterprisePlatformKeysInternalGenerateKeyFunction::OnGeneratedKey, | 59 &EnterprisePlatformKeysInternalGenerateKeyFunction::OnGeneratedKey, |
60 this)); | 60 this)); |
61 return RespondLater(); | 61 return RespondLater(); |
62 } | 62 } |
63 | 63 |
64 void EnterprisePlatformKeysInternalGenerateKeyFunction::OnGeneratedKey( | 64 void EnterprisePlatformKeysInternalGenerateKeyFunction::OnGeneratedKey( |
65 const std::string& public_key_der, | 65 const std::string& public_key_der, |
66 const std::string& error_message) { | 66 const std::string& error_message) { |
67 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 67 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
68 if (error_message.empty()) { | 68 if (error_message.empty()) { |
69 Respond(ArgumentList(api_epki::GenerateKey::Results::Create( | 69 Respond(ArgumentList(api_epki::GenerateKey::Results::Create( |
70 std::vector<char>(public_key_der.begin(), public_key_der.end())))); | 70 std::vector<char>(public_key_der.begin(), public_key_der.end())))); |
71 } else { | 71 } else { |
72 Respond(Error(error_message)); | 72 Respond(Error(error_message)); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 EnterprisePlatformKeysGetCertificatesFunction:: | 76 EnterprisePlatformKeysGetCertificatesFunction:: |
77 ~EnterprisePlatformKeysGetCertificatesFunction() { | 77 ~EnterprisePlatformKeysGetCertificatesFunction() { |
(...skipping 13 matching lines...) Expand all Loading... |
91 base::Bind( | 91 base::Bind( |
92 &EnterprisePlatformKeysGetCertificatesFunction::OnGotCertificates, | 92 &EnterprisePlatformKeysGetCertificatesFunction::OnGotCertificates, |
93 this), | 93 this), |
94 browser_context()); | 94 browser_context()); |
95 return RespondLater(); | 95 return RespondLater(); |
96 } | 96 } |
97 | 97 |
98 void EnterprisePlatformKeysGetCertificatesFunction::OnGotCertificates( | 98 void EnterprisePlatformKeysGetCertificatesFunction::OnGotCertificates( |
99 scoped_ptr<net::CertificateList> certs, | 99 scoped_ptr<net::CertificateList> certs, |
100 const std::string& error_message) { | 100 const std::string& error_message) { |
101 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 101 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
102 if (!error_message.empty()) { | 102 if (!error_message.empty()) { |
103 Respond(Error(error_message)); | 103 Respond(Error(error_message)); |
104 return; | 104 return; |
105 } | 105 } |
106 | 106 |
107 scoped_ptr<base::ListValue> client_certs(new base::ListValue()); | 107 scoped_ptr<base::ListValue> client_certs(new base::ListValue()); |
108 for (net::CertificateList::const_iterator it = certs->begin(); | 108 for (net::CertificateList::const_iterator it = certs->begin(); |
109 it != certs->end(); | 109 it != certs->end(); |
110 ++it) { | 110 ++it) { |
111 std::string der_encoding; | 111 std::string der_encoding; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 cert_x509, | 144 cert_x509, |
145 base::Bind(&EnterprisePlatformKeysImportCertificateFunction:: | 145 base::Bind(&EnterprisePlatformKeysImportCertificateFunction:: |
146 OnImportedCertificate, | 146 OnImportedCertificate, |
147 this), | 147 this), |
148 browser_context()); | 148 browser_context()); |
149 return RespondLater(); | 149 return RespondLater(); |
150 } | 150 } |
151 | 151 |
152 void EnterprisePlatformKeysImportCertificateFunction::OnImportedCertificate( | 152 void EnterprisePlatformKeysImportCertificateFunction::OnImportedCertificate( |
153 const std::string& error_message) { | 153 const std::string& error_message) { |
154 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
155 if (error_message.empty()) | 155 if (error_message.empty()) |
156 Respond(NoArguments()); | 156 Respond(NoArguments()); |
157 else | 157 else |
158 Respond(Error(error_message)); | 158 Respond(Error(error_message)); |
159 } | 159 } |
160 | 160 |
161 EnterprisePlatformKeysRemoveCertificateFunction:: | 161 EnterprisePlatformKeysRemoveCertificateFunction:: |
162 ~EnterprisePlatformKeysRemoveCertificateFunction() { | 162 ~EnterprisePlatformKeysRemoveCertificateFunction() { |
163 } | 163 } |
164 | 164 |
(...skipping 18 matching lines...) Expand all Loading... |
183 cert_x509, | 183 cert_x509, |
184 base::Bind(&EnterprisePlatformKeysRemoveCertificateFunction:: | 184 base::Bind(&EnterprisePlatformKeysRemoveCertificateFunction:: |
185 OnRemovedCertificate, | 185 OnRemovedCertificate, |
186 this), | 186 this), |
187 browser_context()); | 187 browser_context()); |
188 return RespondLater(); | 188 return RespondLater(); |
189 } | 189 } |
190 | 190 |
191 void EnterprisePlatformKeysRemoveCertificateFunction::OnRemovedCertificate( | 191 void EnterprisePlatformKeysRemoveCertificateFunction::OnRemovedCertificate( |
192 const std::string& error_message) { | 192 const std::string& error_message) { |
193 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 193 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
194 if (error_message.empty()) | 194 if (error_message.empty()) |
195 Respond(NoArguments()); | 195 Respond(NoArguments()); |
196 else | 196 else |
197 Respond(Error(error_message)); | 197 Respond(Error(error_message)); |
198 } | 198 } |
199 | 199 |
200 EnterprisePlatformKeysInternalGetTokensFunction:: | 200 EnterprisePlatformKeysInternalGetTokensFunction:: |
201 ~EnterprisePlatformKeysInternalGetTokensFunction() { | 201 ~EnterprisePlatformKeysInternalGetTokensFunction() { |
202 } | 202 } |
203 | 203 |
204 ExtensionFunction::ResponseAction | 204 ExtensionFunction::ResponseAction |
205 EnterprisePlatformKeysInternalGetTokensFunction::Run() { | 205 EnterprisePlatformKeysInternalGetTokensFunction::Run() { |
206 EXTENSION_FUNCTION_VALIDATE(args_->empty()); | 206 EXTENSION_FUNCTION_VALIDATE(args_->empty()); |
207 | 207 |
208 chromeos::platform_keys::GetTokens( | 208 chromeos::platform_keys::GetTokens( |
209 base::Bind(&EnterprisePlatformKeysInternalGetTokensFunction::OnGotTokens, | 209 base::Bind(&EnterprisePlatformKeysInternalGetTokensFunction::OnGotTokens, |
210 this), | 210 this), |
211 browser_context()); | 211 browser_context()); |
212 return RespondLater(); | 212 return RespondLater(); |
213 } | 213 } |
214 | 214 |
215 void EnterprisePlatformKeysInternalGetTokensFunction::OnGotTokens( | 215 void EnterprisePlatformKeysInternalGetTokensFunction::OnGotTokens( |
216 scoped_ptr<std::vector<std::string> > platform_keys_token_ids, | 216 scoped_ptr<std::vector<std::string> > platform_keys_token_ids, |
217 const std::string& error_message) { | 217 const std::string& error_message) { |
218 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
219 if (!error_message.empty()) { | 219 if (!error_message.empty()) { |
220 Respond(Error(error_message)); | 220 Respond(Error(error_message)); |
221 return; | 221 return; |
222 } | 222 } |
223 | 223 |
224 std::vector<std::string> token_ids; | 224 std::vector<std::string> token_ids; |
225 for (std::vector<std::string>::const_iterator it = | 225 for (std::vector<std::string>::const_iterator it = |
226 platform_keys_token_ids->begin(); | 226 platform_keys_token_ids->begin(); |
227 it != platform_keys_token_ids->end(); | 227 it != platform_keys_token_ids->end(); |
228 ++it) { | 228 ++it) { |
229 std::string token_id = platform_keys::PlatformKeysTokenIdToApiId(*it); | 229 std::string token_id = platform_keys::PlatformKeysTokenIdToApiId(*it); |
230 if (token_id.empty()) { | 230 if (token_id.empty()) { |
231 Respond(Error(kErrorInternal)); | 231 Respond(Error(kErrorInternal)); |
232 return; | 232 return; |
233 } | 233 } |
234 token_ids.push_back(token_id); | 234 token_ids.push_back(token_id); |
235 } | 235 } |
236 | 236 |
237 Respond(ArgumentList(api_epki::GetTokens::Results::Create(token_ids))); | 237 Respond(ArgumentList(api_epki::GetTokens::Results::Create(token_ids))); |
238 } | 238 } |
239 | 239 |
240 } // namespace extensions | 240 } // namespace extensions |
OLD | NEW |