Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_private/enterpr ise_platform_keys_private_api.h" 5 #include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterpr ise_platform_keys_private_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 EPKPChallengeKeyBase::PrepareKeyContext::~PrepareKeyContext() { 77 EPKPChallengeKeyBase::PrepareKeyContext::~PrepareKeyContext() {
78 } 78 }
79 79
80 EPKPChallengeKeyBase::EPKPChallengeKeyBase() 80 EPKPChallengeKeyBase::EPKPChallengeKeyBase()
81 : cryptohome_client_( 81 : cryptohome_client_(
82 chromeos::DBusThreadManager::Get()->GetCryptohomeClient()), 82 chromeos::DBusThreadManager::Get()->GetCryptohomeClient()),
83 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()), 83 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()),
84 install_attributes_(g_browser_process->platform_part() 84 install_attributes_(g_browser_process->platform_part()
85 ->browser_policy_connector_chromeos() 85 ->browser_policy_connector_chromeos()
86 ->GetInstallAttributes()) { 86 ->GetInstallAttributes()) {
87 scoped_ptr<chromeos::attestation::ServerProxy> ca_client( 87 std::unique_ptr<chromeos::attestation::ServerProxy> ca_client(
88 new chromeos::attestation::AttestationCAClient()); 88 new chromeos::attestation::AttestationCAClient());
89 default_attestation_flow_.reset(new chromeos::attestation::AttestationFlow( 89 default_attestation_flow_.reset(new chromeos::attestation::AttestationFlow(
90 async_caller_, cryptohome_client_, std::move(ca_client))); 90 async_caller_, cryptohome_client_, std::move(ca_client)));
91 attestation_flow_ = default_attestation_flow_.get(); 91 attestation_flow_ = default_attestation_flow_.get();
92 } 92 }
93 93
94 EPKPChallengeKeyBase::EPKPChallengeKeyBase( 94 EPKPChallengeKeyBase::EPKPChallengeKeyBase(
95 chromeos::CryptohomeClient* cryptohome_client, 95 chromeos::CryptohomeClient* cryptohome_client,
96 cryptohome::AsyncMethodCaller* async_caller, 96 cryptohome::AsyncMethodCaller* async_caller,
97 chromeos::attestation::AttestationFlow* attestation_flow, 97 chromeos::attestation::AttestationFlow* attestation_flow,
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction:: 559 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction::
560 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction( 560 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction(
561 EPKPChallengeMachineKey* impl_for_testing) 561 EPKPChallengeMachineKey* impl_for_testing)
562 : impl_(impl_for_testing) {} 562 : impl_(impl_for_testing) {}
563 563
564 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction:: 564 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction::
565 ~EnterprisePlatformKeysPrivateChallengeMachineKeyFunction() = default; 565 ~EnterprisePlatformKeysPrivateChallengeMachineKeyFunction() = default;
566 566
567 ExtensionFunction::ResponseAction 567 ExtensionFunction::ResponseAction
568 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction::Run() { 568 EnterprisePlatformKeysPrivateChallengeMachineKeyFunction::Run() {
569 scoped_ptr<api_epkp::ChallengeMachineKey::Params> params( 569 std::unique_ptr<api_epkp::ChallengeMachineKey::Params> params(
570 api_epkp::ChallengeMachineKey::Params::Create(*args_)); 570 api_epkp::ChallengeMachineKey::Params::Create(*args_));
571 EXTENSION_FUNCTION_VALIDATE(params); 571 EXTENSION_FUNCTION_VALIDATE(params);
572 ChallengeKeyCallback callback = 572 ChallengeKeyCallback callback =
573 base::Bind(&EnterprisePlatformKeysPrivateChallengeMachineKeyFunction:: 573 base::Bind(&EnterprisePlatformKeysPrivateChallengeMachineKeyFunction::
574 OnChallengedKey, 574 OnChallengedKey,
575 this); 575 this);
576 // base::Unretained is safe on impl_ since its life-cycle matches |this| and 576 // base::Unretained is safe on impl_ since its life-cycle matches |this| and
577 // |callback| holds a reference to |this|. 577 // |callback| holds a reference to |this|.
578 base::Closure task = base::Bind( 578 base::Closure task = base::Bind(
579 &EPKPChallengeMachineKey::DecodeAndRun, base::Unretained(impl_), 579 &EPKPChallengeMachineKey::DecodeAndRun, base::Unretained(impl_),
(...skipping 23 matching lines...) Expand all
603 EnterprisePlatformKeysPrivateChallengeUserKeyFunction:: 603 EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
604 EnterprisePlatformKeysPrivateChallengeUserKeyFunction( 604 EnterprisePlatformKeysPrivateChallengeUserKeyFunction(
605 EPKPChallengeUserKey* impl_for_testing) 605 EPKPChallengeUserKey* impl_for_testing)
606 : impl_(impl_for_testing) {} 606 : impl_(impl_for_testing) {}
607 607
608 EnterprisePlatformKeysPrivateChallengeUserKeyFunction:: 608 EnterprisePlatformKeysPrivateChallengeUserKeyFunction::
609 ~EnterprisePlatformKeysPrivateChallengeUserKeyFunction() = default; 609 ~EnterprisePlatformKeysPrivateChallengeUserKeyFunction() = default;
610 610
611 ExtensionFunction::ResponseAction 611 ExtensionFunction::ResponseAction
612 EnterprisePlatformKeysPrivateChallengeUserKeyFunction::Run() { 612 EnterprisePlatformKeysPrivateChallengeUserKeyFunction::Run() {
613 scoped_ptr<api_epkp::ChallengeUserKey::Params> params( 613 std::unique_ptr<api_epkp::ChallengeUserKey::Params> params(
614 api_epkp::ChallengeUserKey::Params::Create(*args_)); 614 api_epkp::ChallengeUserKey::Params::Create(*args_));
615 EXTENSION_FUNCTION_VALIDATE(params); 615 EXTENSION_FUNCTION_VALIDATE(params);
616 ChallengeKeyCallback callback = base::Bind( 616 ChallengeKeyCallback callback = base::Bind(
617 &EnterprisePlatformKeysPrivateChallengeUserKeyFunction::OnChallengedKey, 617 &EnterprisePlatformKeysPrivateChallengeUserKeyFunction::OnChallengedKey,
618 this); 618 this);
619 // base::Unretained is safe on impl_ since its life-cycle matches |this| and 619 // base::Unretained is safe on impl_ since its life-cycle matches |this| and
620 // |callback| holds a reference to |this|. 620 // |callback| holds a reference to |this|.
621 base::Closure task = base::Bind( 621 base::Closure task = base::Bind(
622 &EPKPChallengeUserKey::DecodeAndRun, base::Unretained(impl_), 622 &EPKPChallengeUserKey::DecodeAndRun, base::Unretained(impl_),
623 scoped_refptr<UIThreadExtensionFunction>(AsUIThreadExtensionFunction()), 623 scoped_refptr<UIThreadExtensionFunction>(AsUIThreadExtensionFunction()),
624 callback, params->challenge, params->register_key); 624 callback, params->challenge, params->register_key);
625 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, task); 625 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, task);
626 return RespondLater(); 626 return RespondLater();
627 } 627 }
628 628
629 void EnterprisePlatformKeysPrivateChallengeUserKeyFunction::OnChallengedKey( 629 void EnterprisePlatformKeysPrivateChallengeUserKeyFunction::OnChallengedKey(
630 bool success, 630 bool success,
631 const std::string& data) { 631 const std::string& data) {
632 if (success) { 632 if (success) {
633 std::string encoded_response; 633 std::string encoded_response;
634 base::Base64Encode(data, &encoded_response); 634 base::Base64Encode(data, &encoded_response);
635 Respond(ArgumentList( 635 Respond(ArgumentList(
636 api_epkp::ChallengeUserKey::Results::Create(encoded_response))); 636 api_epkp::ChallengeUserKey::Results::Create(encoded_response)));
637 } else { 637 } else {
638 Respond(Error(data)); 638 Respond(Error(data));
639 } 639 }
640 } 640 }
641 641
642 } // namespace extensions 642 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698