Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of Web Payments feature #143

Open
wants to merge 9 commits into
base: wolvic
Choose a base branch
from

Conversation

javifernandez
Copy link
Member

This PR provides a very basic implementation of the Payment Request API and the minimum viable logic for the Payment Handlers.

In the latter case, it provides support just to launch a new tab that loads a service worker provided by the payment request.

A new modal window will be launched to load the service worker. This window is controlled by the WolvicPaymentUiService class, which will handle the service-worker result of the generate the payment request response.

A new ServiceTabLauncher class is implemented in Wolvic in order to launch this kind of modal dialogs.

Finally, this PR adds a new method in the WebContentsObserver to notify Wolvic when the new payment-handler WebContent instance is ready to be loaded in the modal window.

@@ -363,6 +363,10 @@ blink::mojom::PermissionStatus WolvicPermissionManager::GetPermissionStatus(
blink::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
if (permission == blink::PermissionType::PAYMENT_HANDLER) {
return blink::mojom::PermissionStatus::GRANTED;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think we should still ask for this permission anyway

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, I guess, but bear in mind that Chrome Desktop doesn't do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a matter of fact, the Chromium code that handles the web payment method manifest downloading expect the permission to be GRANTED by default. I don't think we can ask the user about this.

javifernandez and others added 7 commits January 20, 2025 02:16
This patch adds onCreateNewPaymentHandler method in
WebContentsObserver to deliver the payment handler's WebContents
to Wolvic side.
The PaymentUiService should not re-use the WindowAndroid instance
from the original WebContents and, instead, must create a new one
for the main activity.

Additionally, this change also implements the close() method, so
that we can properly destroy the newly created WebContent instance
for the payment handler.
We need to detect when the user dismiss the Payment Handler UI
so that we can close properly the ongoing Payment Request.

For now observing the the destruction of the PaymentHandler's
WebContent instance is the only way we have to detect this situation.
@mshin-wolvic mshin-wolvic requested a review from ns-mshin January 20, 2025 01:21
This new class can be used to create instance of Tabs that can
handle PaymentHandler work-flow. The Client interface provides
an API to control the window's life-cycle.
…Client interface

Now that the WolvicPaymentUiService implements the PaymentRequestUI.Client interface
we can use it to control the PaymentHandler window's life-cycle. In order to do this,
we need to create the PaymentRequestUI instance in Chromium, and getting it in Wolvic
from the WebContents received in the onCreateNewPaymentHandler.

The current design didn't allow to call the WebContentImpl::getOrSetUSerData method,
becuase it'd require the PaymentRequestUI to have a sinple consrtuctor with just one
WebContents parameter. Additionally, this WebContents instance might be already
initialized, which is not the case of our current design.

So the solution to implement the PaymentRequestUI::getFromContents was to add a new
public method in the WebContentsImpl class to directly set userData as an already
created object.
Copy link

@ns-mshin ns-mshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mshin-wolvic mshin-wolvic requested review from ns-mshin and removed request for ns-mshin January 21, 2025 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants