Commit 4051d1d8 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment][Desktop] Skipping UI into Android payment app.

Before this patch, when desktop Chrome directly launched an Android
payment app, it also displayed the browser payment UI, which should not
have been displayed.

This patch makes desktop Chrome never show any browser payment UI when
launching into an Android payment app for app store billing (the only
Android payment app supported on desktop).

After this patch, when desktop Chrome directly launches into Android
payment app, no other browser payment UI is displayed.

Bug: 1140815
Change-Id: Id04156b807176cb5f3d24529a586860b5b8f87b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2491494Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821252}
parent f4c09c85
...@@ -301,7 +301,11 @@ void PaymentRequest::Show(bool is_user_gesture, bool wait_for_updated_details) { ...@@ -301,7 +301,11 @@ void PaymentRequest::Show(bool is_user_gesture, bool wait_for_updated_details) {
spec_->details().total->amount->value, false /*completed*/); spec_->details().total->amount->value, false /*completed*/);
} }
display_handle_->Show(weak_ptr_factory_.GetWeakPtr()); // If an app store billing payment method is one of the payment methods being
// requested, then don't show any user interface until its known whether it's
// possible to skip UI directly into an app store billing payment app.
if (!spec_->IsAppStoreBillingAlsoRequested())
display_handle_->Show(weak_ptr_factory_.GetWeakPtr());
state_->set_is_show_user_gesture(is_show_user_gesture_); state_->set_is_show_user_gesture(is_show_user_gesture_);
state_->AreRequestedMethodsSupported( state_->AreRequestedMethodsSupported(
...@@ -387,8 +391,14 @@ void PaymentRequest::UpdateWith(mojom::PaymentDetailsPtr details) { ...@@ -387,8 +391,14 @@ void PaymentRequest::UpdateWith(mojom::PaymentDetailsPtr details) {
spec_->details().total->amount->value, false /*completed*/); spec_->details().total->amount->value, false /*completed*/);
if (SatisfiesSkipUIConstraints()) { if (SatisfiesSkipUIConstraints()) {
Pay(); Pay();
} else if (spec_->request_shipping()) { } else {
state_->SelectDefaultShippingAddressAndNotifyObservers(); // If not skipping UI, then make sure that the browser payment sheet is
// being displayed.
if (!display_handle_->was_shown())
display_handle_->Show(weak_ptr_factory_.GetWeakPtr());
if (spec_->request_shipping())
state_->SelectDefaultShippingAddressAndNotifyObservers();
} }
} }
} }
...@@ -590,8 +600,13 @@ void PaymentRequest::AreRequestedMethodsSupportedCallback( ...@@ -590,8 +600,13 @@ void PaymentRequest::AreRequestedMethodsSupportedCallback(
} }
if (methods_supported) { if (methods_supported) {
if (SatisfiesSkipUIConstraints()) if (SatisfiesSkipUIConstraints()) {
Pay(); Pay();
} else if (!display_handle_->was_shown()) {
// If not skipping UI, then make sure that the browser payment sheet is
// being displayed.
display_handle_->Show(weak_ptr_factory_.GetWeakPtr());
}
} else { } else {
VLOG(2) << "PaymentRequest (" << *spec_->details().id VLOG(2) << "PaymentRequest (" << *spec_->details().id
<< "): requested method not supported."; << "): requested method not supported.";
...@@ -827,6 +842,13 @@ void PaymentRequest::Pay() { ...@@ -827,6 +842,13 @@ void PaymentRequest::Pay() {
VLOG(2) << "PaymentRequest (" << *spec_->details().id VLOG(2) << "PaymentRequest (" << *spec_->details().id
<< "): paying with app: " << state_->selected_app()->GetLabel(); << "): paying with app: " << state_->selected_app()->GetLabel();
if (!display_handle_->was_shown() &&
state_->selected_app()->type() != PaymentApp::Type::NATIVE_MOBILE_APP) {
// If not paying with a native mobile app (such as app store billing), then
// make sure that the browser payment sheet is being displayed.
display_handle_->Show(weak_ptr_factory_.GetWeakPtr());
}
state_->selected_app()->SetPaymentHandlerHost( state_->selected_app()->SetPaymentHandlerHost(
payment_handler_host_->AsWeakPtr()); payment_handler_host_->AsWeakPtr());
state_->GeneratePaymentResponse(); state_->GeneratePaymentResponse();
......
...@@ -26,6 +26,7 @@ void PaymentRequestDisplayManager::DisplayHandle::Show( ...@@ -26,6 +26,7 @@ void PaymentRequestDisplayManager::DisplayHandle::Show(
base::WeakPtr<PaymentRequest> request) { base::WeakPtr<PaymentRequest> request) {
DCHECK(request); DCHECK(request);
DCHECK(delegate_); DCHECK(delegate_);
was_shown_ = true;
delegate_->ShowDialog(request); delegate_->ShowDialog(request);
} }
......
...@@ -43,9 +43,13 @@ class PaymentRequestDisplayManager : public KeyedService { ...@@ -43,9 +43,13 @@ class PaymentRequestDisplayManager : public KeyedService {
void DisplayPaymentHandlerWindow(const GURL& url, void DisplayPaymentHandlerWindow(const GURL& url,
PaymentHandlerOpenWindowCallback callback); PaymentHandlerOpenWindowCallback callback);
// Returns true after Show() was called.
bool was_shown() const { return was_shown_; }
private: private:
PaymentRequestDisplayManager* display_manager_; PaymentRequestDisplayManager* display_manager_;
ContentPaymentRequestDelegate* delegate_; ContentPaymentRequestDelegate* delegate_;
bool was_shown_ = false;
DISALLOW_COPY_AND_ASSIGN(DisplayHandle); DISALLOW_COPY_AND_ASSIGN(DisplayHandle);
}; };
......
...@@ -111,6 +111,8 @@ PaymentRequestSpec::PaymentRequestSpec( ...@@ -111,6 +111,8 @@ PaymentRequestSpec::PaymentRequestSpec(
ToString(request_payer_phone()), ToString(request_shipping())}, ToString(request_payer_phone()), ToString(request_shipping())},
nullptr)}; nullptr)};
} }
app_store_billing_methods_.insert(methods::kGooglePlayBilling);
} }
PaymentRequestSpec::~PaymentRequestSpec() {} PaymentRequestSpec::~PaymentRequestSpec() {}
...@@ -366,6 +368,12 @@ bool PaymentRequestSpec::IsSecurePaymentConfirmationRequested() const { ...@@ -366,6 +368,12 @@ bool PaymentRequestSpec::IsSecurePaymentConfirmationRequested() const {
methods::kSecurePaymentConfirmation; methods::kSecurePaymentConfirmation;
} }
bool PaymentRequestSpec::IsAppStoreBillingAlsoRequested() const {
return !base::STLSetIntersection<std::set<std::string>>(
app_store_billing_methods_, payment_method_identifiers_set_)
.empty();
}
base::WeakPtr<PaymentRequestSpec> PaymentRequestSpec::AsWeakPtr() { base::WeakPtr<PaymentRequestSpec> PaymentRequestSpec::AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr(); return weak_ptr_factory_.GetWeakPtr();
} }
......
...@@ -207,6 +207,10 @@ class PaymentRequestSpec : public PaymentOptionsProvider, ...@@ -207,6 +207,10 @@ class PaymentRequestSpec : public PaymentOptionsProvider,
bool IsSecurePaymentConfirmationRequested() const; bool IsSecurePaymentConfirmationRequested() const;
// Returns true if one of the payment methods being requested is an app store
// billing method, such as "https://play.google.com/billing".
bool IsAppStoreBillingAlsoRequested() const;
base::WeakPtr<PaymentRequestSpec> AsWeakPtr(); base::WeakPtr<PaymentRequestSpec> AsWeakPtr();
private: private:
...@@ -256,9 +260,9 @@ class PaymentRequestSpec : public PaymentOptionsProvider, ...@@ -256,9 +260,9 @@ class PaymentRequestSpec : public PaymentOptionsProvider,
// |supported_card_networks_set_| to check merchant support. // |supported_card_networks_set_| to check merchant support.
std::set<std::string> basic_card_specified_networks_; std::set<std::string> basic_card_specified_networks_;
// A list of supported url-based payment method identifers specified by the // A list of supported url-based payment method identifiers specified by the
// merchant. This encompasses one of the two types of payment method // merchant. This encompasses one of the two types of payment method
// identifers, the other being standardized payment method identifiers i.e., // identifiers, the other being standardized payment method identifiers i.e.,
// basic-card. // basic-card.
std::vector<GURL> url_payment_method_identifiers_; std::vector<GURL> url_payment_method_identifiers_;
...@@ -289,6 +293,8 @@ class PaymentRequestSpec : public PaymentOptionsProvider, ...@@ -289,6 +293,8 @@ class PaymentRequestSpec : public PaymentOptionsProvider,
base::string16 retry_error_message_; base::string16 retry_error_message_;
mojom::PayerErrorsPtr payer_errors_; mojom::PayerErrorsPtr payer_errors_;
std::set<std::string> app_store_billing_methods_;
base::WeakPtrFactory<PaymentRequestSpec> weak_ptr_factory_{this}; base::WeakPtrFactory<PaymentRequestSpec> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment