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/easy_unlock_private/easy_unlock_private_
api.h" | 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_
api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 const std::string challenge = | 635 const std::string challenge = |
636 EasyUnlockService::Get(profile)->GetChallenge(); | 636 EasyUnlockService::Get(profile)->GetChallenge(); |
637 if (!challenge.empty() && !params->nonce.empty()) { | 637 if (!challenge.empty() && !params->nonce.empty()) { |
638 EasyUnlockTpmKeyManager* key_manager = | 638 EasyUnlockTpmKeyManager* key_manager = |
639 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile); | 639 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile); |
640 if (!key_manager) { | 640 if (!key_manager) { |
641 SetError("No EasyUnlockTpmKeyManager."); | 641 SetError("No EasyUnlockTpmKeyManager."); |
642 return false; | 642 return false; |
643 } | 643 } |
644 key_manager->SignUsingTpmKey( | 644 key_manager->SignUsingTpmKey( |
645 EasyUnlockService::Get(profile)->GetUserEmail(), | 645 EasyUnlockService::Get(profile)->GetUserID(), |
646 std::string(params->nonce.begin(), params->nonce.end()), | 646 std::string(params->nonce.begin(), params->nonce.end()), |
647 base::Bind(&EasyUnlockPrivateGetSignInChallengeFunction::OnDone, this, | 647 base::Bind(&EasyUnlockPrivateGetSignInChallengeFunction::OnDone, this, |
648 challenge)); | 648 challenge)); |
649 } else { | 649 } else { |
650 OnDone(challenge, std::string()); | 650 OnDone(challenge, std::string()); |
651 } | 651 } |
652 return true; | 652 return true; |
653 #else // if !defined(OS_CHROMEOS) | 653 #else // if !defined(OS_CHROMEOS) |
654 SetError("Sign-in not supported."); | 654 SetError("Sign-in not supported."); |
655 return false; | 655 return false; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() { | 687 EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() { |
688 } | 688 } |
689 | 689 |
690 EasyUnlockPrivateGetUserInfoFunction::~EasyUnlockPrivateGetUserInfoFunction() { | 690 EasyUnlockPrivateGetUserInfoFunction::~EasyUnlockPrivateGetUserInfoFunction() { |
691 } | 691 } |
692 | 692 |
693 bool EasyUnlockPrivateGetUserInfoFunction::RunSync() { | 693 bool EasyUnlockPrivateGetUserInfoFunction::RunSync() { |
694 EasyUnlockService* service = | 694 EasyUnlockService* service = |
695 EasyUnlockService::Get(Profile::FromBrowserContext(browser_context())); | 695 EasyUnlockService::Get(Profile::FromBrowserContext(browser_context())); |
696 std::vector<linked_ptr<easy_unlock_private::UserInfo> > users; | 696 std::vector<linked_ptr<easy_unlock_private::UserInfo> > users; |
697 std::string user_id = service->GetUserEmail(); | 697 user_manager::UserID user_id = service->GetUserID(); |
698 if (!user_id.empty()) { | 698 if (!user_id.empty()) { |
699 users.push_back( | 699 users.push_back( |
700 linked_ptr<easy_unlock_private::UserInfo>( | 700 linked_ptr<easy_unlock_private::UserInfo>( |
701 new easy_unlock_private::UserInfo())); | 701 new easy_unlock_private::UserInfo())); |
702 users[0]->user_id = user_id; | 702 users[0]->user_id = user_id; |
703 users[0]->logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; | 703 users[0]->logged_in = service->GetType() == EasyUnlockService::TYPE_REGULAR; |
704 users[0]->data_ready = users[0]->logged_in || | 704 users[0]->data_ready = users[0]->logged_in || |
705 service->GetRemoteDevices() != NULL; | 705 service->GetRemoteDevices() != NULL; |
706 | 706 |
707 EasyUnlockService::UserSettings user_settings = | 707 EasyUnlockService::UserSettings user_settings = |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 error_message = *params->result.error_message; | 836 error_message = *params->result.error_message; |
837 | 837 |
838 Profile* profile = Profile::FromBrowserContext(browser_context()); | 838 Profile* profile = Profile::FromBrowserContext(browser_context()); |
839 EasyUnlockService::Get(profile) | 839 EasyUnlockService::Get(profile) |
840 ->SetAutoPairingResult(params->result.success, error_message); | 840 ->SetAutoPairingResult(params->result.success, error_message); |
841 | 841 |
842 return true; | 842 return true; |
843 } | 843 } |
844 | 844 |
845 } // namespace extensions | 845 } // namespace extensions |
OLD | NEW |