| Index: components/installedapp/android/java/src/org/chromium/device/installedapp/InstalledAppProviderImpl.java
|
| diff --git a/components/installedapp/android/java/src/org/chromium/device/installedapp/InstalledAppProviderImpl.java b/components/installedapp/android/java/src/org/chromium/device/installedapp/InstalledAppProviderImpl.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9c26c08434ea8b352f15f1d71783053317671743
|
| --- /dev/null
|
| +++ b/components/installedapp/android/java/src/org/chromium/device/installedapp/InstalledAppProviderImpl.java
|
| @@ -0,0 +1,73 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.components.installedapp;
|
| +
|
| +import android.content.Context;
|
| +import android.content.pm.PackageManager;
|
| +
|
| +import org.chromium.mojom.components.InstalledAppProvider;
|
| +import org.chromium.mojo.system.MojoException;
|
| +
|
| +import java.util.Map;
|
| +import android.util.Log;
|
| +import java.util.Arrays;
|
| +import java.util.HashSet;
|
| +
|
| +/**
|
| + * This is the implementation of the C++ counterpart InstalledAppProvider.
|
| + */
|
| +public class InstalledAppProviderImpl implements InstalledAppProvider {
|
| + private Context mContext;
|
| +
|
| + public InstalledAppProviderImpl(Context context) {
|
| + // Log.w("TAG", "Installed app provider made!.");
|
| + mContext = context;
|
| + }
|
| +
|
| + @Override
|
| + public void isAppInstalled(
|
| + String asset1, String asset2, String origin, IsAppInstalledResponse callback) {
|
| + // PackageManager pm = mContext.getPackageManager();
|
| + // callback.call(AssociationVerifier.verifyCertFingerprints(asset1, asset2, pm) &&
|
| + // AssociationVerifier.isOriginAssociatedWithPackage(asset1, origin, pm));
|
| + }
|
| +
|
| + @Override
|
| + public void isNativeAppInstalled(Map<String, String[]> verification, String origin,
|
| + IsNativeAppInstalledResponse callback) {
|
| + // TODO: fill in.
|
| + String[] packageName = verification.get("packageName");
|
| + String[] key = verification.get("signingKey");
|
| + if (packageName == null || packageName.length == 0 || key == null || key.length == 0) {
|
| + callback.call(false);
|
| + return;
|
| + }
|
| +
|
| + callback.call(isPackageVerified(packageName[0], key, origin));
|
| + }
|
| +
|
| + @Override
|
| + public void close() {}
|
| +
|
| + @Override
|
| + public void onConnectionError(MojoException e) {}
|
| +
|
| + private boolean isPackageVerified(String packageName, String[] signingKeys, String origin) {
|
| + // HashSet<String> keySet = new HashSet<String>(Arrays.asList(signingKeys));
|
| + String signingKey = signingKeys[0];
|
| + if (packageName.length() == 0 || signingKey.length() == 0 || origin.length() == 0) {
|
| + Log.w("TAG", "Oh no.");
|
| + return false;
|
| + }
|
| +
|
| + Log.w("TAG", "Oh no2.");
|
| + Log.w("TAG", packageName + signingKey + origin);
|
| +
|
| + PackageManager pm = mContext.getPackageManager();
|
| + return AssociationVerifier.verifyCertFingerprints(
|
| + packageName, Arrays.asList(signingKeys), pm)
|
| + && AssociationVerifier.isOriginAssociatedWithPackage(packageName, origin, pm);
|
| + }
|
| +}
|
|
|