From fdecf5aa2b83114abd1ae43b59ec3f1a2ed62aaf Mon Sep 17 00:00:00 2001 From: Miyoung Shin Date: Thu, 29 Aug 2019 07:43:49 +0000 Subject: [PATCH] Convert InternalAuthenticator to new Mojo types This CL converts InternalAuthenticator{Ptr, Reqeust} in components to the new Mojo types. Bug: 955171 Change-Id: Ibc5ab83b99cb1fbfc6cbee2fdfa04735652e12e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773009 Commit-Queue: Vadym Doroshenko Reviewed-by: Ken Rockot Reviewed-by: Vadym Doroshenko Cr-Commit-Position: refs/heads/master@{#691515} --- components/autofill/DEPS | 1 + .../autofill/content/browser/content_autofill_driver.cc | 6 +++--- .../autofill/content/browser/content_autofill_driver.h | 4 +++- components/autofill/core/browser/autofill_driver.h | 3 ++- .../browser/payments/credit_card_fido_authenticator.cc | 8 +++++--- .../browser/payments/credit_card_fido_authenticator.h | 5 +++-- components/autofill/core/browser/test_autofill_driver.cc | 2 +- components/autofill/core/browser/test_autofill_driver.h | 4 +++- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/components/autofill/DEPS b/components/autofill/DEPS index 4d8612624c6974..1e677456feabeb 100644 --- a/components/autofill/DEPS +++ b/components/autofill/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+components/strings/grit/components_strings.h", "+google_apis/gaia/gaia_urls.h", "+net", + "+mojo/public", "+third_party/protobuf", "+third_party/skia", "+third_party/zlib/google", diff --git a/components/autofill/content/browser/content_autofill_driver.cc b/components/autofill/content/browser/content_autofill_driver.cc index 81f4c7f902fe56..587b1dfd3f4336 100644 --- a/components/autofill/content/browser/content_autofill_driver.cc +++ b/components/autofill/content/browser/content_autofill_driver.cc @@ -98,13 +98,13 @@ bool ContentAutofillDriver::RendererIsAvailable() { } void ContentAutofillDriver::ConnectToAuthenticator( - blink::mojom::InternalAuthenticatorRequest request) { + mojo::PendingReceiver receiver) { #if defined(OS_ANDROID) - render_frame_host_->GetJavaInterfaces()->GetInterface(std::move(request)); + render_frame_host_->GetJavaInterfaces()->GetInterface(std::move(receiver)); #else authenticator_impl_ = std::make_unique( render_frame_host_, url::Origin::Create(payments::GetBaseSecureUrl())); - authenticator_impl_->Bind(std::move(request)); + authenticator_impl_->Bind(std::move(receiver)); #endif } diff --git a/components/autofill/content/browser/content_autofill_driver.h b/components/autofill/content/browser/content_autofill_driver.h index cc007793097d2d..02353aa33bfa4e 100644 --- a/components/autofill/content/browser/content_autofill_driver.h +++ b/components/autofill/content/browser/content_autofill_driver.h @@ -19,6 +19,7 @@ #include "components/autofill/core/browser/autofill_manager.h" #include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/associated_remote.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" namespace content { class NavigationHandle; @@ -59,7 +60,8 @@ class ContentAutofillDriver : public AutofillDriver, scoped_refptr GetURLLoaderFactory() override; bool RendererIsAvailable() override; void ConnectToAuthenticator( - blink::mojom::InternalAuthenticatorRequest request) override; + mojo::PendingReceiver receiver) + override; void SendFormDataToRenderer(int query_id, RendererFormDataAction action, const FormData& data) override; diff --git a/components/autofill/core/browser/autofill_driver.h b/components/autofill/core/browser/autofill_driver.h index 33dc3ff3d25f53..b9e205706e45d9 100644 --- a/components/autofill/core/browser/autofill_driver.h +++ b/components/autofill/core/browser/autofill_driver.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_refptr.h" #include "build/build_config.h" #include "components/autofill/core/common/form_data.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" #if !defined(OS_IOS) #include "third_party/blink/public/mojom/webauthn/internal_authenticator.mojom.h" @@ -65,7 +66,7 @@ class AutofillDriver { #if !defined(OS_IOS) // Binds the mojom request in order to facilitate WebAuthn flows. virtual void ConnectToAuthenticator( - blink::mojom::InternalAuthenticatorRequest request) = 0; + mojo::PendingReceiver receiver) = 0; #endif // Forwards |data| to the renderer. |query_id| is the id of the renderer's diff --git a/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc b/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc index 20bf3de69c245d..86afb2f2a66f94 100644 --- a/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc +++ b/components/autofill/core/browser/payments/credit_card_fido_authenticator.cc @@ -96,7 +96,7 @@ void CreditCardFIDOAuthenticator::IsUserVerifiable( if (base::FeatureList::IsEnabled( features::kAutofillCreditCardAuthentication)) { autofill_driver_->ConnectToAuthenticator( - mojo::MakeRequest(&authenticator_)); + authenticator_.BindNewPipeAndPassReceiver()); authenticator_->IsUserVerifyingPlatformAuthenticatorAvailable( std::move(callback)); } else { @@ -133,7 +133,8 @@ void CreditCardFIDOAuthenticator::SyncUserOptIn( void CreditCardFIDOAuthenticator::GetAssertion( PublicKeyCredentialRequestOptionsPtr request_options) { - autofill_driver_->ConnectToAuthenticator(mojo::MakeRequest(&authenticator_)); + autofill_driver_->ConnectToAuthenticator( + authenticator_.BindNewPipeAndPassReceiver()); authenticator_->GetAssertion( std::move(request_options), base::BindOnce(&CreditCardFIDOAuthenticator::OnDidGetAssertion, @@ -142,7 +143,8 @@ void CreditCardFIDOAuthenticator::GetAssertion( void CreditCardFIDOAuthenticator::MakeCredential( PublicKeyCredentialCreationOptionsPtr creation_options) { - autofill_driver_->ConnectToAuthenticator(mojo::MakeRequest(&authenticator_)); + autofill_driver_->ConnectToAuthenticator( + authenticator_.BindNewPipeAndPassReceiver()); authenticator_->MakeCredential( std::move(creation_options), base::BindOnce(&CreditCardFIDOAuthenticator::OnDidMakeCredential, diff --git a/components/autofill/core/browser/payments/credit_card_fido_authenticator.h b/components/autofill/core/browser/payments/credit_card_fido_authenticator.h index d2318391200ca0..60608cd66be9b8 100644 --- a/components/autofill/core/browser/payments/credit_card_fido_authenticator.h +++ b/components/autofill/core/browser/payments/credit_card_fido_authenticator.h @@ -14,6 +14,7 @@ #include "components/autofill/core/browser/payments/full_card_request.h" #include "components/autofill/core/browser/payments/payments_client.h" #include "device/fido/fido_constants.h" +#include "mojo/public/cpp/bindings/remote.h" #include "third_party/blink/public/mojom/webauthn/internal_authenticator.mojom.h" namespace autofill { @@ -21,7 +22,7 @@ namespace autofill { using blink::mojom::AuthenticatorStatus; using blink::mojom::GetAssertionAuthenticatorResponse; using blink::mojom::GetAssertionAuthenticatorResponsePtr; -using blink::mojom::InternalAuthenticatorPtr; +using blink::mojom::InternalAuthenticator; using blink::mojom::MakeCredentialAuthenticatorResponse; using blink::mojom::MakeCredentialAuthenticatorResponsePtr; using blink::mojom::PublicKeyCredentialCreationOptions; @@ -192,7 +193,7 @@ class CreditCardFIDOAuthenticator payments::PaymentsClient* const payments_client_; // Authenticator pointer to facilitate WebAuthn. - InternalAuthenticatorPtr authenticator_; + mojo::Remote authenticator_; // Responsible for getting the full card details, including the PAN and the // CVC. diff --git a/components/autofill/core/browser/test_autofill_driver.cc b/components/autofill/core/browser/test_autofill_driver.cc index 64361b2fdc1132..dd51b9637b6f86 100644 --- a/components/autofill/core/browser/test_autofill_driver.cc +++ b/components/autofill/core/browser/test_autofill_driver.cc @@ -45,7 +45,7 @@ bool TestAutofillDriver::RendererIsAvailable() { #if !defined(OS_IOS) void TestAutofillDriver::ConnectToAuthenticator( - blink::mojom::InternalAuthenticatorRequest request) {} + mojo::PendingReceiver receiver) {} #endif void TestAutofillDriver::SendFormDataToRenderer(int query_id, diff --git a/components/autofill/core/browser/test_autofill_driver.h b/components/autofill/core/browser/test_autofill_driver.h index ad7373b929300b..d65c2b23cd8420 100644 --- a/components/autofill/core/browser/test_autofill_driver.h +++ b/components/autofill/core/browser/test_autofill_driver.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_refptr.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_driver.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" #include "services/network/test/test_url_loader_factory.h" namespace autofill { @@ -28,7 +29,8 @@ class TestAutofillDriver : public AutofillDriver { bool RendererIsAvailable() override; #if !defined(OS_IOS) void ConnectToAuthenticator( - blink::mojom::InternalAuthenticatorRequest request) override; + mojo::PendingReceiver receiver) + override; #endif void SendFormDataToRenderer(int query_id, RendererFormDataAction action,