Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SecurePaymentConfirmation] Add PaymentCredential
Add the PaymentCredential credential type to enable use of Credential Management API for enrolling payment instruments associated with Web Authentication credentials. This adds the renderer-side code for creating the credential and also a mojo interface for sending the information to the Payments component for storage. Bug:1110325 Change-Id: I7bf2ad1cf0d499a6a211e730e785d9b970fcdb07 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360313 Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Commit-Queue: Ken Buchanan <kenrb@chromium.org> Cr-Commit-Position: refs/heads/master@{#801871}
- Loading branch information
Showing
31 changed files
with
634 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/payments/payment_credential_factory.h" | ||
|
||
#include "base/feature_list.h" | ||
#include "chrome/browser/payments/chrome_payment_request_delegate.h" | ||
#include "components/payments/content/payment_request_web_contents_manager.h" | ||
#include "content/public/browser/render_frame_host.h" | ||
#include "content/public/browser/web_contents.h" | ||
|
||
namespace payments { | ||
|
||
void CreatePaymentCredential( | ||
content::RenderFrameHost* render_frame_host, | ||
mojo::PendingReceiver<mojom::PaymentCredential> receiver) { | ||
content::WebContents* web_contents = | ||
content::WebContents::FromRenderFrameHost(render_frame_host); | ||
if (!web_contents) | ||
return; | ||
PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents) | ||
->CreatePaymentCredential(std::move(receiver)); | ||
} | ||
|
||
} // namespace payments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_PAYMENTS_PAYMENT_CREDENTIAL_FACTORY_H_ | ||
#define CHROME_BROWSER_PAYMENTS_PAYMENT_CREDENTIAL_FACTORY_H_ | ||
|
||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
#include "third_party/blink/public/mojom/payments/payment_credential.mojom-forward.h" | ||
|
||
namespace content { | ||
class RenderFrameHost; | ||
} | ||
|
||
namespace payments { | ||
|
||
// Connect a PaymentCredential receiver to handle payment credential creation. | ||
void CreatePaymentCredential( | ||
content::RenderFrameHost* render_frame_host, | ||
mojo::PendingReceiver<mojom::PaymentCredential> receiver); | ||
|
||
} // namespace payments | ||
|
||
#endif // CHROME_BROWSER_PAYMENTS_PAYMENT_CREDENTIAL_FACTORY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/payments/content/payment_credential.h" | ||
|
||
namespace payments { | ||
|
||
PaymentCredential::PaymentCredential( | ||
mojo::PendingReceiver<mojom::PaymentCredential> receiver) { | ||
receiver_.Bind(std::move(receiver)); | ||
} | ||
|
||
PaymentCredential::~PaymentCredential() = default; | ||
|
||
void PaymentCredential::StorePaymentCredential( | ||
payments::mojom::PaymentCredentialInstrumentPtr instrument, | ||
const std::vector<uint8_t>& credential_id, | ||
const std::string& rp_id, | ||
StorePaymentCredentialCallback callback) { | ||
// TODO(kenrb): Create storage for this credential and save it. | ||
std::move(callback).Run(mojom::PaymentCredentialCreationStatus::SUCCESS); | ||
} | ||
|
||
} // namespace payments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_CREDENTIAL_H_ | ||
#define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_CREDENTIAL_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
#include "mojo/public/cpp/bindings/receiver.h" | ||
#include "third_party/blink/public/mojom/payments/payment_credential.mojom.h" | ||
|
||
namespace payments { | ||
|
||
// Implementation of the mojom::PaymentCredential interface for storing | ||
// PaymentCredential instruments and their associated WebAuthn credential IDs. | ||
// These can be retrieved later to authenticate during a PaymentRequest | ||
// that uses Secure Payment Confirmation. | ||
class PaymentCredential : public mojom::PaymentCredential { | ||
public: | ||
explicit PaymentCredential( | ||
mojo::PendingReceiver<mojom::PaymentCredential> receiver); | ||
~PaymentCredential() override; | ||
|
||
PaymentCredential(const PaymentCredential&) = delete; | ||
PaymentCredential& operator=(const PaymentCredential&) = delete; | ||
|
||
// mojom::PaymentCredential: | ||
void StorePaymentCredential( | ||
payments::mojom::PaymentCredentialInstrumentPtr instrument, | ||
const std::vector<uint8_t>& credential_id, | ||
const std::string& rp_id, | ||
StorePaymentCredentialCallback callback) override; | ||
|
||
private: | ||
mojo::Receiver<mojom::PaymentCredential> receiver_{this}; | ||
}; | ||
|
||
} // namespace payments | ||
|
||
#endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_CREDENTIAL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.