@Test public void testStartSafeBrowsingUseApplicationContext() throws Exception { assumeTrue(WebViewFeature.isFeatureSupported(WebViewFeature.START_SAFE_BROWSING)); final MockContext ctx = new MockContext(InstrumentationRegistry.getTargetContext().getApplicationContext()); final CountDownLatch resultLatch = new CountDownLatch(1); WebViewCompat.startSafeBrowsing(ctx, new ValueCallback<Boolean>() { @Override public void onReceiveValue(Boolean value) { assertTrue(ctx.wasGetApplicationContextCalled()); resultLatch.countDown(); return; } }); assertTrue(resultLatch.await(TEST_TIMEOUT, TimeUnit.MILLISECONDS)); }
@SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") public static void startSafeBrowsing(@NonNull Context context, @Nullable ValueCallback<Boolean> callback) { WebViewFeatureInternal webviewFeature = WebViewFeatureInternal.getFeature(WebViewFeature.START_SAFE_BROWSING); if (webviewFeature.isSupportedByFramework()) { WebView.startSafeBrowsing(context, callback); } else if (webviewFeature.isSupportedByWebView()) { getFactory().getStatics().initSafeBrowsing(context, callback); } else { throw WebViewFeatureInternal.getUnsupportedOperationException(); } }
WebViewCompat { @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") public static void startSafeBrowsing(@NonNull Context context, @Nullable ValueCallback<Boolean> callback) { WebViewFeatureInternal webviewFeature = WebViewFeatureInternal.getFeature(WebViewFeature.START_SAFE_BROWSING); if (webviewFeature.isSupportedByFramework()) { WebView.startSafeBrowsing(context, callback); } else if (webviewFeature.isSupportedByWebView()) { getFactory().getStatics().initSafeBrowsing(context, callback); } else { throw WebViewFeatureInternal.getUnsupportedOperationException(); } } }
WebViewCompat { @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") public static void startSafeBrowsing(@NonNull Context context, @Nullable ValueCallback<Boolean> callback) { WebViewFeatureInternal webviewFeature = WebViewFeatureInternal.getFeature(WebViewFeature.START_SAFE_BROWSING); if (webviewFeature.isSupportedByFramework()) { WebView.startSafeBrowsing(context, callback); } else if (webviewFeature.isSupportedByWebView()) { getFactory().getStatics().initSafeBrowsing(context, callback); } else { throw WebViewFeatureInternal.getUnsupportedOperationException(); } } private  WebViewCompat(); }
WebViewCompat { @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") public static void startSafeBrowsing(@NonNull Context context, @Nullable ValueCallback<Boolean> callback) { WebViewFeatureInternal webviewFeature = WebViewFeatureInternal.getFeature(WebViewFeature.START_SAFE_BROWSING); if (webviewFeature.isSupportedByFramework()) { WebView.startSafeBrowsing(context, callback); } else if (webviewFeature.isSupportedByWebView()) { getFactory().getStatics().initSafeBrowsing(context, callback); } else { throw WebViewFeatureInternal.getUnsupportedOperationException(); } } private  WebViewCompat(); @SuppressWarnings("NewApi") @RequiresFeature(name = WebViewFeature.VISUAL_STATE_CALLBACK, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static void postVisualStateCallback(@NonNull WebView webview, long requestId,
            @NonNull final VisualStateCallback callback); @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static void startSafeBrowsing(@NonNull Context context,
            @Nullable ValueCallback<Boolean> callback); @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_WHITELIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static void setSafeBrowsingWhitelist(@NonNull List<String> hosts,
            @Nullable ValueCallback<Boolean> callback); @SuppressLint("NewApi") @NonNull @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static Uri getSafeBrowsingPrivacyPolicyUrl(); @Nullable static PackageInfo getCurrentWebViewPackage(@NonNull Context context); static @NonNull WebMessagePortCompat[] createWebMessageChannel(
            @NonNull WebView webview); static void postWebMessage(@NonNull WebView webview, @NonNull WebMessageCompat message,
            @NonNull Uri targetOrigin); }
WebViewCompat { @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") public static void startSafeBrowsing(@NonNull Context context, @Nullable ValueCallback<Boolean> callback) { WebViewFeatureInternal webviewFeature = WebViewFeatureInternal.getFeature(WebViewFeature.START_SAFE_BROWSING); if (webviewFeature.isSupportedByFramework()) { WebView.startSafeBrowsing(context, callback); } else if (webviewFeature.isSupportedByWebView()) { getFactory().getStatics().initSafeBrowsing(context, callback); } else { throw WebViewFeatureInternal.getUnsupportedOperationException(); } } private  WebViewCompat(); @SuppressWarnings("NewApi") @RequiresFeature(name = WebViewFeature.VISUAL_STATE_CALLBACK, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static void postVisualStateCallback(@NonNull WebView webview, long requestId,
            @NonNull final VisualStateCallback callback); @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.START_SAFE_BROWSING, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static void startSafeBrowsing(@NonNull Context context,
            @Nullable ValueCallback<Boolean> callback); @SuppressLint("NewApi") @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_WHITELIST, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static void setSafeBrowsingWhitelist(@NonNull List<String> hosts,
            @Nullable ValueCallback<Boolean> callback); @SuppressLint("NewApi") @NonNull @RequiresFeature(name = WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") static Uri getSafeBrowsingPrivacyPolicyUrl(); @Nullable static PackageInfo getCurrentWebViewPackage(@NonNull Context context); static @NonNull WebMessagePortCompat[] createWebMessageChannel(
            @NonNull WebView webview); static void postWebMessage(@NonNull WebView webview, @NonNull WebMessageCompat message,
            @NonNull Uri targetOrigin);  }