Index: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java |
index 99c2a0418e6c33bcb9d4d677230334e3549929bd..60647469811c52d6b2be72fd06c7d7cbf9e0f6eb 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java |
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.externalnav; |
import android.content.ActivityNotFoundException; |
import android.content.ComponentName; |
import android.content.Intent; |
+import android.content.pm.PackageManager; |
import android.content.pm.ResolveInfo; |
import android.net.Uri; |
import android.os.SystemClock; |
@@ -28,8 +29,10 @@ import org.chromium.chrome.browser.util.UrlUtilities; |
import org.chromium.ui.base.PageTransition; |
import java.net.URI; |
+import java.util.Collections; |
import java.util.HashSet; |
import java.util.List; |
+import java.util.Set; |
import java.util.concurrent.TimeUnit; |
/** |
@@ -112,6 +115,68 @@ public class ExternalNavigationHandler { |
browserFallbackUrl = null; |
} |
+ try { |
please use gerrit instead
2016/07/27 08:29:02
Put this block into a separate function, for examp
|
+ //scheme |
+ String scheme = intent.getData().getScheme(); |
please use gerrit instead
2016/07/27 08:29:02
You don't use "scheme" anywhere except to check th
|
+ String fragment = intent.getData().getFragment(); |
+ if (!TextUtils.isEmpty(scheme) && null != fragment && fragment.contains(";")) { |
please use gerrit instead
2016/07/27 08:29:02
Chrome style is to put null after variable:
fragm
|
+ String[] parts = fragment.split(";"); |
+ |
+ Set<Set<String>> allFingerPrint256 = new HashSet<>(); |
+ /** |
+ * same package name , different keystores, generated fingerprint256 set. |
+ * |
+ * 1.an app's signature may update and change from old, so need config and |
+ * support new and old, but this is optional.(e.g. a.only config new fingerprint |
+ * b. only config old fingerprint. c.config new and old fingerprint) |
+ * |
+ * 2.one apk itself may contain more than one keystore to sign. |
+ * |
+ * example: suppose apk's new signature is 3A4FXXXXXX,12XXXXXXX,and old signature |
+ * is 1B2AXXXX. you can config the intent like "...;sha256=3A4FXXXXXX,12XXXXXXX;.." |
+ * or "..;sha256=3A4FXXXXXX,12XXXXXXX|1B2AXXXX;.." |
+ */ |
please use gerrit instead
2016/07/27 08:29:02
Chrome style is to use // style comments when insi
|
+ String pkgName = ""; |
+ String fingerPrint256 = ""; |
+ String[] fingerPrint256DifGroups; |
+ for (String each : parts) { |
+ String[] part = each.split("="); |
please use gerrit instead
2016/07/27 08:29:02
Integer loops are more efficient on Android.
for
|
+ if (part[0].equals("sha256")) { |
please use gerrit instead
2016/07/27 08:29:02
This will crash if "each" does not contain "=".
|
+ fingerPrint256 = part[1]; |
please use gerrit instead
2016/07/27 08:29:02
This will crash if "=" is the last character of "e
|
+ |
+ } |
+ if (part[0].equals("package")) { |
+ pkgName = part[1]; |
+ } |
+ } |
+ if (!TextUtils.isEmpty(pkgName) && !TextUtils.isEmpty(fingerPrint256)) { |
+ fingerPrint256DifGroups = fingerPrint256.split("\\|"); |
+ for (int i = 0; i < fingerPrint256DifGroups.length; ++i) { |
+ Set<String> fingerPrint256GroupSignKeySet = new HashSet<>(); |
+ Collections.addAll(fingerPrint256GroupSignKeySet, fingerPrint256DifGroups[i] |
+ .split(",")); |
+ allFingerPrint256.add(fingerPrint256GroupSignKeySet); |
+ } |
+ Set<String> fingerPrint256Set = mDelegate.getPackageSHA256Fingerprints(pkgName); |
+ if (!allFingerPrint256.contains(fingerPrint256Set)) { |
+ return OverrideUrlLoadingResult.NO_OVERRIDE; |
+ } |
+ } |
+ } |
+ } catch (PackageManager.NameNotFoundException e) { |
+ return OverrideUrlLoadingResult.NO_OVERRIDE; |
+ } catch (Throwable ignore) { |
+ /** |
+ * 1. in method getSha256() , if No SHA-256 implementation found, this new feature won't |
+ * work, so it should backwards to original way to handle the intent , we should ignore |
+ * ths Throwable. |
+ * |
+ * 2. in the process above, any other exception or error except "NameNotFoundException" |
+ * happens, we can consider the feature fail ,and catch the throwable and continue next |
+ * work. |
+ */ |
+ } |
+ |
long time = SystemClock.elapsedRealtime(); |
OverrideUrlLoadingResult result = shouldOverrideUrlLoadingInternal( |
params, intent, hasBrowserFallbackUrl, browserFallbackUrl); |