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

Side by Side Diff: chrome/android/webapk/libs/client/src/org/chromium/webapk/lib/client/WebApkValidator.java

Issue 2056383002: Upstream: Initialize ChromeWebApkHost in WebappLaunchActivity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.webapk.lib.client; 5 package org.chromium.webapk.lib.client;
6 6
7 import static org.chromium.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREF IX; 7 import static org.chromium.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREF IX;
8 8
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.Intent; 10 import android.content.Intent;
11 import android.content.pm.PackageInfo; 11 import android.content.pm.PackageInfo;
12 import android.content.pm.PackageManager; 12 import android.content.pm.PackageManager;
13 import android.content.pm.PackageManager.NameNotFoundException; 13 import android.content.pm.PackageManager.NameNotFoundException;
14 import android.content.pm.ResolveInfo; 14 import android.content.pm.ResolveInfo;
15 import android.content.pm.Signature; 15 import android.content.pm.Signature;
16 import android.util.Log; 16 import android.util.Log;
17 17
18 import java.util.Arrays; 18 import java.util.Arrays;
19 import java.util.List; 19 import java.util.List;
20 20
21 /** 21 /**
22 * Checks whether a URL belongs to a WebAPK, and whether a WebAPK is signed by t he WebAPK Minting 22 * Checks whether a URL belongs to a WebAPK, and whether a WebAPK is signed by t he WebAPK Minting
23 * Server. 23 * Server.
24 */ 24 */
25 public class WebApkValidator { 25 public class WebApkValidator {
26 26
27 private static final String TAG = "WebApkValidator"; 27 private static final String TAG = "WebApkValidator";
28 private static byte[] sExpectedSignature; 28 private static byte[] sExpectedSignature;
29 private static boolean sIsInitialized = false;
29 30
30 /** 31 /**
31 * Queries the PackageManager to determine whether a WebAPK can handle the U RL. Ignores 32 * Queries the PackageManager to determine whether a WebAPK can handle the U RL. Ignores
32 * whether the user has selected a default handler for the URL and whether t he default 33 * whether the user has selected a default handler for the URL and whether t he default
33 * handler is the WebAPK. 34 * handler is the WebAPK.
34 * 35 *
35 * NOTE(yfriedman): This can fail if multiple WebAPKs can match the supplied url. 36 * NOTE(yfriedman): This can fail if multiple WebAPKs can match the supplied url.
36 * 37 *
37 * @param context The application context. 38 * @param context The application context.
38 * @param url The url to check. 39 * @param url The url to check.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Log.d(TAG, "WebApk invalid"); 112 Log.d(TAG, "WebApk invalid");
112 return false; 113 return false;
113 } 114 }
114 115
115 /** 116 /**
116 * Initializes the WebApkValidator with the expected signature that WebAPKs must be signed 117 * Initializes the WebApkValidator with the expected signature that WebAPKs must be signed
117 * with for the current host. 118 * with for the current host.
118 * @param expectedSignature 119 * @param expectedSignature
119 */ 120 */
120 public static void initWithBrowserHostSignature(byte[] expectedSignature) { 121 public static void initWithBrowserHostSignature(byte[] expectedSignature) {
122 if (sIsInitialized) {
pkotwicz 2016/06/10 21:34:14 Can we return if sExpectedSignature != null ?
Xi Han 2016/06/13 20:10:53 Done.
123 return;
124 }
121 sExpectedSignature = Arrays.copyOf(expectedSignature, expectedSignature. length); 125 sExpectedSignature = Arrays.copyOf(expectedSignature, expectedSignature. length);
126 sIsInitialized = true;
122 } 127 }
123 } 128 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698