Skip to content

Commit

Permalink
Convert InternalAuthenticator to new Mojo types
Browse files Browse the repository at this point in the history
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 <dvadym@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Vadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691515}
  • Loading branch information
MyidShin authored and Commit Bot committed Aug 29, 2019
1 parent 7dfccec commit fdecf5a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions components/autofill/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ bool ContentAutofillDriver::RendererIsAvailable() {
}

void ContentAutofillDriver::ConnectToAuthenticator(
blink::mojom::InternalAuthenticatorRequest request) {
mojo::PendingReceiver<blink::mojom::InternalAuthenticator> 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<content::InternalAuthenticatorImpl>(
render_frame_host_, url::Origin::Create(payments::GetBaseSecureUrl()));
authenticator_impl_->Bind(std::move(request));
authenticator_impl_->Bind(std::move(receiver));
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,7 +60,8 @@ class ContentAutofillDriver : public AutofillDriver,
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
bool RendererIsAvailable() override;
void ConnectToAuthenticator(
blink::mojom::InternalAuthenticatorRequest request) override;
mojo::PendingReceiver<blink::mojom::InternalAuthenticator> receiver)
override;
void SendFormDataToRenderer(int query_id,
RendererFormDataAction action,
const FormData& data) override;
Expand Down
3 changes: 2 additions & 1 deletion components/autofill/core/browser/autofill_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<blink::mojom::InternalAuthenticator> receiver) = 0;
#endif

// Forwards |data| to the renderer. |query_id| is the id of the renderer's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
#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 {

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;
Expand Down Expand Up @@ -192,7 +193,7 @@ class CreditCardFIDOAuthenticator
payments::PaymentsClient* const payments_client_;

// Authenticator pointer to facilitate WebAuthn.
InternalAuthenticatorPtr authenticator_;
mojo::Remote<InternalAuthenticator> authenticator_;

// Responsible for getting the full card details, including the PAN and the
// CVC.
Expand Down
2 changes: 1 addition & 1 deletion components/autofill/core/browser/test_autofill_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool TestAutofillDriver::RendererIsAvailable() {

#if !defined(OS_IOS)
void TestAutofillDriver::ConnectToAuthenticator(
blink::mojom::InternalAuthenticatorRequest request) {}
mojo::PendingReceiver<blink::mojom::InternalAuthenticator> receiver) {}
#endif

void TestAutofillDriver::SendFormDataToRenderer(int query_id,
Expand Down
4 changes: 3 additions & 1 deletion components/autofill/core/browser/test_autofill_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,7 +29,8 @@ class TestAutofillDriver : public AutofillDriver {
bool RendererIsAvailable() override;
#if !defined(OS_IOS)
void ConnectToAuthenticator(
blink::mojom::InternalAuthenticatorRequest request) override;
mojo::PendingReceiver<blink::mojom::InternalAuthenticator> receiver)
override;
#endif
void SendFormDataToRenderer(int query_id,
RendererFormDataAction action,
Expand Down

0 comments on commit fdecf5a

Please sign in to comment.