Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1357)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentPreferencesUtil.java

Issue 2647573005: [Payments] Allow users enable and disable Android payment apps in payment request (Closed)
Patch Set: rename Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.payments;
6
7 import org.chromium.base.ContextUtils;
8
9 /** Place to define and control payment preferences. */
10 public class PaymentPreferencesUtil {
11 // Avoid instantiation by accident.
12 private PaymentPreferencesUtil() {}
13
14 /** Preference to indicate whether payment request has been completed succes sfully once.*/
15 private static final String PAYMENT_COMPLETE_ONCE = "payment_complete_once";
16
17 /** Prefix of the preferences to persist Android payment apps' status. */
18 public static final String PAYMENT_ANDROID_APP_ENABLED_ = "payment_android_a pp_enabled_";
19
20 /**
21 * Checks whehter the payment request has been successfully completed once.
22 *
23 * @return True If payment request has been successfully completed once.
24 */
25 public static boolean isPaymentCompleteOnce() {
26 return ContextUtils.getAppSharedPreferences().getBoolean(PAYMENT_COMPLET E_ONCE, false);
27 }
28
29 /** Sets the payment request has been successfully completed once. */
30 public static void setPaymentCompleteOnce() {
31 ContextUtils.getAppSharedPreferences()
32 .edit()
33 .putBoolean(PAYMENT_COMPLETE_ONCE, true)
34 .apply();
35 }
36
37 /**
38 * Checks whether the Android payment app is enabled by user from the settin gs. The default
39 * status is enabled.
40 *
41 * @param packageName The package name of the Android payment app.
42 * @return True If the Android payment app is enabled by user.
43 */
44 public static boolean isAndroidPaymentAppEnabled(String packageName) {
45 return ContextUtils.getAppSharedPreferences().getBoolean(
46 getAndroidPaymentAppEnabledPreferenceKey(packageName), true);
47 }
48
49 /**
50 * Gets preference key for status of the Android payment app.
51 *
52 * @param packageName The packageName of the Android payment app.
53 * @return The preference key.
54 */
55 public static String getAndroidPaymentAppEnabledPreferenceKey(String package Name) {
56 return PAYMENT_ANDROID_APP_ENABLED_ + packageName;
57 }
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698