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_service.h" | 5 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 SignPermission::UNLIMITED, true /* new permission value */, | 644 SignPermission::UNLIMITED, true /* new permission value */, |
645 public_key_spki_der, extension_id, | 645 public_key_spki_der, extension_id, |
646 base::Bind(&PlatformKeysService::TaskFinished, base::Unretained(this)), | 646 base::Bind(&PlatformKeysService::TaskFinished, base::Unretained(this)), |
647 this))); | 647 this))); |
648 } | 648 } |
649 | 649 |
650 void PlatformKeysService::GenerateRSAKey(const std::string& token_id, | 650 void PlatformKeysService::GenerateRSAKey(const std::string& token_id, |
651 unsigned int modulus_length, | 651 unsigned int modulus_length, |
652 const std::string& extension_id, | 652 const std::string& extension_id, |
653 const GenerateKeyCallback& callback) { | 653 const GenerateKeyCallback& callback) { |
654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 654 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
655 | 655 |
656 platform_keys::subtle::GenerateRSAKey( | 656 platform_keys::subtle::GenerateRSAKey( |
657 token_id, modulus_length, | 657 token_id, modulus_length, |
658 base::Bind(&PlatformKeysService::GeneratedKey, weak_factory_.GetWeakPtr(), | 658 base::Bind(&PlatformKeysService::GeneratedKey, weak_factory_.GetWeakPtr(), |
659 extension_id, callback), | 659 extension_id, callback), |
660 browser_context_); | 660 browser_context_); |
661 } | 661 } |
662 | 662 |
663 void PlatformKeysService::SignRSAPKCS1Digest( | 663 void PlatformKeysService::SignRSAPKCS1Digest( |
664 const std::string& token_id, | 664 const std::string& token_id, |
665 const std::string& data, | 665 const std::string& data, |
666 const std::string& public_key, | 666 const std::string& public_key, |
667 platform_keys::HashAlgorithm hash_algorithm, | 667 platform_keys::HashAlgorithm hash_algorithm, |
668 const std::string& extension_id, | 668 const std::string& extension_id, |
669 const SignCallback& callback) { | 669 const SignCallback& callback) { |
670 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 670 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
671 StartOrQueueTask(make_scoped_ptr(new SignTask( | 671 StartOrQueueTask(make_scoped_ptr(new SignTask( |
672 token_id, data, public_key, false /* digest before signing */, | 672 token_id, data, public_key, false /* digest before signing */, |
673 hash_algorithm, extension_id, callback, this))); | 673 hash_algorithm, extension_id, callback, this))); |
674 } | 674 } |
675 | 675 |
676 void PlatformKeysService::SignRSAPKCS1Raw(const std::string& token_id, | 676 void PlatformKeysService::SignRSAPKCS1Raw(const std::string& token_id, |
677 const std::string& data, | 677 const std::string& data, |
678 const std::string& public_key, | 678 const std::string& public_key, |
679 const std::string& extension_id, | 679 const std::string& extension_id, |
680 const SignCallback& callback) { | 680 const SignCallback& callback) { |
681 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 681 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
682 StartOrQueueTask(make_scoped_ptr(new SignTask( | 682 StartOrQueueTask(make_scoped_ptr(new SignTask( |
683 token_id, data, public_key, true /* sign directly without hashing */, | 683 token_id, data, public_key, true /* sign directly without hashing */, |
684 platform_keys::HASH_ALGORITHM_NONE, extension_id, callback, this))); | 684 platform_keys::HASH_ALGORITHM_NONE, extension_id, callback, this))); |
685 } | 685 } |
686 | 686 |
687 void PlatformKeysService::SelectClientCertificates( | 687 void PlatformKeysService::SelectClientCertificates( |
688 const platform_keys::ClientCertificateRequest& request, | 688 const platform_keys::ClientCertificateRequest& request, |
689 bool interactive, | 689 bool interactive, |
690 const std::string& extension_id, | 690 const std::string& extension_id, |
691 const SelectCertificatesCallback& callback, | 691 const SelectCertificatesCallback& callback, |
692 content::WebContents* web_contents) { | 692 content::WebContents* web_contents) { |
693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 693 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
694 StartOrQueueTask(make_scoped_ptr(new SelectTask( | 694 StartOrQueueTask(make_scoped_ptr(new SelectTask( |
695 request, interactive, extension_id, callback, web_contents, this))); | 695 request, interactive, extension_id, callback, web_contents, this))); |
696 } | 696 } |
697 | 697 |
698 void PlatformKeysService::StartOrQueueTask(scoped_ptr<Task> task) { | 698 void PlatformKeysService::StartOrQueueTask(scoped_ptr<Task> task) { |
699 tasks_.push(make_linked_ptr(task.release())); | 699 tasks_.push(make_linked_ptr(task.release())); |
700 if (tasks_.size() == 1) | 700 if (tasks_.size() == 1) |
701 tasks_.front()->Start(); | 701 tasks_.front()->Start(); |
702 } | 702 } |
703 | 703 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 const GetPlatformKeysCallback& callback, | 761 const GetPlatformKeysCallback& callback, |
762 scoped_ptr<base::Value> value) { | 762 scoped_ptr<base::Value> value) { |
763 scoped_ptr<KeyEntries> key_entries(new KeyEntries); | 763 scoped_ptr<KeyEntries> key_entries(new KeyEntries); |
764 if (value) | 764 if (value) |
765 key_entries = KeyEntriesFromState(*value); | 765 key_entries = KeyEntriesFromState(*value); |
766 | 766 |
767 callback.Run(key_entries.Pass()); | 767 callback.Run(key_entries.Pass()); |
768 } | 768 } |
769 | 769 |
770 } // namespace chromeos | 770 } // namespace chromeos |
OLD | NEW |