| 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 "chromeos/cryptohome/homedir_methods.h" | 5 #include "chromeos/cryptohome/homedir_methods.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (it->number) | 91 if (it->number) |
| 92 entry->set_number(*it->number); | 92 entry->set_number(*it->number); |
| 93 if (it->bytes) | 93 if (it->bytes) |
| 94 entry->set_bytes(*it->bytes); | 94 entry->set_bytes(*it->bytes); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Fill identification protobuffer. | 98 // Fill identification protobuffer. |
| 99 void FillIdentificationProtobuf(const Identification& id, | 99 void FillIdentificationProtobuf(const Identification& id, |
| 100 cryptohome::AccountIdentifier* id_proto) { | 100 cryptohome::AccountIdentifier* id_proto) { |
| 101 id_proto->set_email(id.user_id); | 101 id_proto->set_account_id(id.id()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Fill authorization protobuffer. | 104 // Fill authorization protobuffer. |
| 105 void FillAuthorizationProtobuf(const Authorization& auth, | 105 void FillAuthorizationProtobuf(const Authorization& auth, |
| 106 cryptohome::AuthorizationRequest* auth_proto) { | 106 cryptohome::AuthorizationRequest* auth_proto) { |
| 107 Key* key = auth_proto->mutable_key(); | 107 Key* key = auth_proto->mutable_key(); |
| 108 if (!auth.label.empty()) { | 108 if (!auth.label.empty()) { |
| 109 key->mutable_data()->set_label(auth.label); | 109 key->mutable_data()->set_label(auth.label); |
| 110 } | 110 } |
| 111 key->set_secret(auth.key); | 111 key->set_secret(auth.key); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 cryptohome::AccountIdentifier id_proto; | 299 cryptohome::AccountIdentifier id_proto; |
| 300 cryptohome::AuthorizationRequest auth_proto; | 300 cryptohome::AuthorizationRequest auth_proto; |
| 301 cryptohome::UpdateKeyRequest pb_update_key; | 301 cryptohome::UpdateKeyRequest pb_update_key; |
| 302 | 302 |
| 303 FillIdentificationProtobuf(id, &id_proto); | 303 FillIdentificationProtobuf(id, &id_proto); |
| 304 FillAuthorizationProtobuf(auth, &auth_proto); | 304 FillAuthorizationProtobuf(auth, &auth_proto); |
| 305 FillKeyProtobuf(new_key, pb_update_key.mutable_changes()); | 305 FillKeyProtobuf(new_key, pb_update_key.mutable_changes()); |
| 306 pb_update_key.set_authorization_signature(signature); | 306 pb_update_key.set_authorization_signature(signature); |
| 307 | 307 |
| 308 DBusThreadManager::Get()->GetCryptohomeClient()->UpdateKeyEx( | 308 DBusThreadManager::Get()->GetCryptohomeClient()->UpdateKeyEx( |
| 309 id_proto, | 309 id_proto, auth_proto, pb_update_key, |
| 310 auth_proto, | |
| 311 pb_update_key, | |
| 312 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, | 310 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, |
| 313 weak_ptr_factory_.GetWeakPtr(), | 311 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 314 callback)); | 312 } |
| 313 |
| 314 void RenameCryptohome(const Identification& id_from, |
| 315 const Identification& id_to, |
| 316 const Callback& callback) override { |
| 317 cryptohome::AccountIdentifier id_from_proto; |
| 318 cryptohome::AccountIdentifier id_to_proto; |
| 319 |
| 320 FillIdentificationProtobuf(id_from, &id_from_proto); |
| 321 FillIdentificationProtobuf(id_to, &id_to_proto); |
| 322 |
| 323 DBusThreadManager::Get()->GetCryptohomeClient()->RenameCryptohome( |
| 324 id_from_proto, id_to_proto, |
| 325 base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, |
| 326 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 315 } | 327 } |
| 316 | 328 |
| 317 private: | 329 private: |
| 318 void OnGetKeyDataExCallback(const GetKeyDataCallback& callback, | 330 void OnGetKeyDataExCallback(const GetKeyDataCallback& callback, |
| 319 chromeos::DBusMethodCallStatus call_status, | 331 chromeos::DBusMethodCallStatus call_status, |
| 320 bool result, | 332 bool result, |
| 321 const BaseReply& reply) { | 333 const BaseReply& reply) { |
| 322 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { | 334 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { |
| 323 callback.Run(false, MOUNT_ERROR_FATAL, std::vector<KeyDefinition>()); | 335 callback.Run(false, MOUNT_ERROR_FATAL, std::vector<KeyDefinition>()); |
| 324 return; | 336 return; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 498 } |
| 487 delete g_homedir_methods; | 499 delete g_homedir_methods; |
| 488 g_homedir_methods = NULL; | 500 g_homedir_methods = NULL; |
| 489 VLOG(1) << "HomedirMethods Shutdown completed"; | 501 VLOG(1) << "HomedirMethods Shutdown completed"; |
| 490 } | 502 } |
| 491 | 503 |
| 492 // static | 504 // static |
| 493 HomedirMethods* HomedirMethods::GetInstance() { return g_homedir_methods; } | 505 HomedirMethods* HomedirMethods::GetInstance() { return g_homedir_methods; } |
| 494 | 506 |
| 495 } // namespace cryptohome | 507 } // namespace cryptohome |
| OLD | NEW |