Commit 51339b89 authored by Mathieu Perreault's avatar Mathieu Perreault Committed by Commit Bot

[Payments] Add a browser-side feature to control modifiers support.

Bug: 746949
Test: browser_tests
Change-Id: I7f80fb7102bd8dd413864ec74e5084587d74744c
Reviewed-on: https://chromium-review.googlesource.com/579569
Commit-Queue: Mathieu Perreault <mathp@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488279}
parent 4bb43166
......@@ -9,6 +9,7 @@ import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.DELAYED_RESPONSE;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.ENABLE_WEB_PAYMENTS_MODIFIERS;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.HAVE_INSTRUMENTS;
import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.IMMEDIATE_RESPONSE;
......@@ -39,7 +40,7 @@ import java.util.concurrent.TimeoutException;
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({
ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG, ENABLE_WEB_PAYMENTS_MODIFIERS,
})
public class PaymentRequestPaymentAppAndBasicCardWithModifiersTest
implements PaymentRequestTestRule.MainActivityStartCallback {
......
......@@ -10,6 +10,7 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.autofill.CardUnmaskPrompt;
import org.chromium.chrome.browser.payments.PaymentRequestTestCommon.PaymentRequestTestCommonCallback;
......@@ -53,6 +54,10 @@ public class PaymentRequestTestRule extends ChromeActivityTestRule<ChromeTabbedA
/** The billing address dropdown index for the first billing address. */
public static final int FIRST_BILLING_ADDRESS = PaymentRequestTestCommon.FIRST_BILLING_ADDRESS;
/** Command line flag to enable payment details modifiers in tests. */
public static final String ENABLE_WEB_PAYMENTS_MODIFIERS =
"enable-features=" + ChromeFeatureList.WEB_PAYMENTS_MODIFIERS;
private final PaymentRequestTestCommon mTestCommon;
private final MainActivityStartCallback mCallback;
......
......@@ -1558,6 +1558,7 @@ split_static_library("browser") {
"//components/password_manager/core/browser",
"//components/password_manager/core/common",
"//components/password_manager/sync/browser",
"//components/payments/core",
"//components/physical_web/eddystone",
"//components/policy:generated",
"//components/policy/core/browser",
......
......@@ -62,6 +62,7 @@
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/omnibox_switches.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/payments/core/features.h"
#include "components/previews/core/previews_features.h"
#include "components/proximity_auth/switches.h"
#include "components/search_provider_logos/features.h"
......@@ -2601,6 +2602,10 @@ const FeatureEntry kFeatureEntries[] = {
{"web-payments", flag_descriptions::kWebPaymentsName,
flag_descriptions::kWebPaymentsDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kWebPayments)},
{"web-payments-modifiers", flag_descriptions::kWebPaymentsModifiersName,
flag_descriptions::kWebPaymentsModifiersDescription,
kOsAndroid | kOsDesktop,
FEATURE_VALUE_TYPE(payments::features::kWebPaymentsModifiers)},
#if defined(OS_ANDROID)
{"enable-android-pay-integration-v1",
flag_descriptions::kEnableAndroidPayIntegrationV1Name,
......@@ -2734,9 +2739,6 @@ const FeatureEntry kFeatureEntries[] = {
kOsAndroid,
FEATURE_VALUE_TYPE(
offline_pages::kOfflinePagesSvelteConcurrentLoadingFeature)},
{"web-payments-modifiers", flag_descriptions::kWebPaymentsModifiersName,
flag_descriptions::kWebPaymentsModifiersDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kWebPaymentsModifiers)},
{"xgeo-visible-networks", flag_descriptions::kXGEOVisibleNetworksName,
flag_descriptions::kXGEOVisibleNetworksDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kXGEOVisibleNetworks)},
......
......@@ -18,6 +18,7 @@
#include "components/ntp_snippets/features.h"
#include "components/offline_pages/core/offline_page_feature.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/payments/core/features.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "content/public/common/content_features.h"
#include "jni/ChromeFeatureList_jni.h"
......@@ -92,7 +93,7 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kVideoPersistence,
&kVrBrowsingFeedback,
&kVrCustomTabBrowsing,
&kWebPaymentsModifiers,
&payments::features::kWebPaymentsModifiers,
&kWebPaymentsSingleAppUiSkip,
&kWebVrAutopresent,
&kWebVRCardboardSupport,
......@@ -258,9 +259,6 @@ const base::Feature kVrBrowsingFeedback{"VrBrowsingFeedback",
const base::Feature kVrCustomTabBrowsing{"VrCustomTabBrowsing",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kWebPaymentsModifiers{"WebPaymentsModifiers",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kWebPaymentsSingleAppUiSkip{
"WebPaymentsSingleAppUiSkip", base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -58,7 +58,6 @@ extern const base::Feature kUserMediaScreenCapturing;
extern const base::Feature kVideoPersistence;
extern const base::Feature kVrBrowsingFeedback;
extern const base::Feature kVrCustomTabBrowsing;
extern const base::Feature kWebPaymentsModifiers;
extern const base::Feature kWebPaymentsSingleAppUiSkip;
extern const base::Feature kWebVrAutopresent;
extern const base::Feature kWebVRCardboardSupport;
......
......@@ -1320,6 +1320,13 @@ const char kWebPaymentsName[] = "Web Payments";
const char kWebPaymentsDescription[] =
"Enable Web Payments API integration, a JavaScript API for merchants.";
const char kWebPaymentsModifiersName[] = "Enable web payment modifiers";
const char kWebPaymentsModifiersDescription[] =
"If the website provides modifiers in the payment request, show the custom "
"total for each payment instrument, update the shopping cart when "
"instruments are switched, and send modified payment method specific data "
"to the payment app.";
const char kWebrtcEchoCanceller3Name[] = "WebRTC Echo Canceller 3.";
const char kWebrtcEchoCanceller3Description[] =
"Experimental WebRTC echo canceller (AEC3).";
......@@ -1843,13 +1850,6 @@ const char kUseDdljsonApiName[] = "Use new ddljson API for Doodles";
const char kUseDdljsonApiDescription[] =
"Enables the new ddljson API to fetch Doodles for the NTP.";
const char kWebPaymentsModifiersName[] = "Enable web payment modifiers";
const char kWebPaymentsModifiersDescription[] =
"If the website provides modifiers in the payment request, show the custom "
"total for each payment instrument, update the shopping cart when "
"instruments are switched, and send modified payment method specific data "
"to the payment app.";
const char kXGEOVisibleNetworksName[] = "Enable XGEO Visible Networks";
const char kXGEOVisibleNetworksDescription[] =
"If location permissions are granted, include visible networks in the XGEO "
......
......@@ -818,6 +818,9 @@ extern const char kWebMidiDescription[];
extern const char kWebPaymentsName[];
extern const char kWebPaymentsDescription[];
extern const char kWebPaymentsModifiersName[];
extern const char kWebPaymentsModifiersDescription[];
extern const char kWebrtcEchoCanceller3Name[];
extern const char kWebrtcEchoCanceller3Description[];
......@@ -1132,9 +1135,6 @@ extern const char kUseAndroidMidiApiDescription[];
extern const char kUseDdljsonApiName[];
extern const char kUseDdljsonApiDescription[];
extern const char kWebPaymentsModifiersName[];
extern const char kWebPaymentsModifiersDescription[];
extern const char kXGEOVisibleNetworksName[];
extern const char kXGEOVisibleNetworksDescription[];
......
......@@ -6,9 +6,11 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
#include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/payments/core/features.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
......@@ -28,7 +30,16 @@ class PaymentRequestModifiersTest : public PaymentRequestBrowserTestBase {
switches::kEnableExperimentalWebPlatformFeatures);
}
void SetUpInProcessBrowserTestFixture() override {
PaymentRequestBrowserTestBase::SetUpInProcessBrowserTestFixture();
// Enable browser-side modifiers support.
feature_list_.InitAndEnableFeature(features::kWebPaymentsModifiers);
}
private:
base::test::ScopedFeatureList feature_list_;
DISALLOW_COPY_AND_ASSIGN(PaymentRequestModifiersTest);
};
......
......@@ -6,8 +6,10 @@
#include <utility>
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "components/payments/core/features.h"
#include "components/payments/core/payment_instrument.h"
#include "components/payments/core/payment_method_data.h"
#include "components/payments/core/payment_request_data_util.h"
......@@ -263,7 +265,8 @@ PaymentRequestSpec::GetShippingOptions() const {
const mojom::PaymentDetailsModifierPtr*
PaymentRequestSpec::GetApplicableModifier(
PaymentInstrument* selected_instrument) const {
if (!selected_instrument)
if (!selected_instrument ||
!base::FeatureList::IsEnabled(features::kWebPaymentsModifiers))
return nullptr;
for (const auto& modifier : details().modifiers) {
......
......@@ -12,5 +12,8 @@ const base::Feature kWebPayments{"WebPayments",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif
const base::Feature kWebPaymentsModifiers{"WebPaymentsModifiers",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features
} // namespace payments
......@@ -16,6 +16,9 @@ namespace features {
extern const base::Feature kWebPayments;
#endif
// Used to control the support for Payment Details modifiers.
extern const base::Feature kWebPaymentsModifiers;
} // namespace features
} // namespace payments
......
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