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

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

Issue 2645813006: Download web payment manifests. (Closed)
Patch Set: At most INT_MAX sections in manifest and fingperints in section Created 3 years, 9 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.annotations.CalledByNative;
8 import org.chromium.base.annotations.JNINamespace;
9 import org.chromium.payments.mojom.PaymentManifestSection;
10
11 /** Parses payment manifests in a utility process. */
12 @JNINamespace("payments")
13 public class PaymentManifestParser {
14 /** Interface for the callback to invoke when finished parsing. */
15 public interface ManifestParseCallback {
16 /**
17 * Called on successful parse of a payment method manifest.
18 *
19 * @param manifest The successfully parsed payment method manifest.
20 */
21 @CalledByNative("ManifestParseCallback")
22 void onManifestParseSuccess(PaymentManifestSection[] manifest);
23
24 /** Called on failed parse of a payment method manifest. */
25 @CalledByNative("ManifestParseCallback")
26 void onManifestParseFailure();
27 }
28
29 /** Owned native host of the utility process that parses manifest contents. */
30 private long mNativePaymentManifestParserAndroid;
31
32 /** Starts the utility process. */
33 public void startUtilityProcess() {
34 assert mNativePaymentManifestParserAndroid == 0;
35 mNativePaymentManifestParserAndroid = nativeCreatePaymentManifestParserA ndroid();
36 nativeStartUtilityProcess(mNativePaymentManifestParserAndroid);
37 }
38
39 /** Stops the utility process. */
40 public void stopUtilityProcess() {
41 assert mNativePaymentManifestParserAndroid != 0;
42 nativeStopUtilityProcess(mNativePaymentManifestParserAndroid);
43 mNativePaymentManifestParserAndroid = 0;
44 }
45
46 /**
47 * Parses the manifest file asynchronously.
48 *
49 * @param content The content to parse.
50 * @param callback The callback to invoke when finished parsing.
51 */
52 public void parse(String content, ManifestParseCallback callback) {
53 nativeParsePaymentManifest(mNativePaymentManifestParserAndroid, content, callback);
54 }
55
56 @CalledByNative
57 private static PaymentManifestSection[] createManifest(int size) {
58 return new PaymentManifestSection[size];
59 }
60
61 @CalledByNative
62 private static void addSectionToManifest(PaymentManifestSection[] manifest, int sectionIndex,
63 String packageName, long version, int fingerprintsSize) {
64 manifest[sectionIndex] = new PaymentManifestSection();
65 manifest[sectionIndex].packageName = packageName;
66 manifest[sectionIndex].version = version;
67 manifest[sectionIndex].sha256CertFingerprints = new String[fingerprintsS ize];
68 }
69
70 @CalledByNative
71 private static void addFingerprintToSection(PaymentManifestSection[] manifes t, int sectionIndex,
72 int fingerprintIndex, String fingerprint) {
73 manifest[sectionIndex].sha256CertFingerprints[fingerprintIndex] = finger print;
74 }
75
76 private static native long nativeCreatePaymentManifestParserAndroid();
77 private static native void nativeStartUtilityProcess(long nativePaymentManif estParserAndroid);
78 private static native void nativeParsePaymentManifest(long nativePaymentMani festParserAndroid,
79 String content, ManifestParseCallback callback);
80 private static native void nativeStopUtilityProcess(long nativePaymentManife stParserAndroid);
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698