public final class BrowserSelector
extends java.lang.Object
Utility class to obtain the browser package name to be used for
AuthorizationService.performAuthorizationRequest(
net.openid.appauth.AuthorizationRequest,
android.app.PendingIntent) calls. It prioritizes browsers which support
custom tabs. To mitigate
man-in-the-middle attacks by malicious apps pretending to be browsers for the specific URI we
query, only those which are registered as a handler for all HTTP and HTTPS URIs will be
used.
| Constructor and Description |
|---|
BrowserSelector() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<BrowserDescriptor> |
getAllBrowsers(android.content.Context context)
Retrieves the full list of browsers installed on the device.
|
static BrowserDescriptor |
select(android.content.Context context,
BrowserMatcher browserMatcher)
Searches through all browsers for the best match based on the supplied browser matcher.
|
@NonNull public static java.util.List<BrowserDescriptor> getAllBrowsers(android.content.Context context)
Retrieves the full list of browsers installed on the device. Two entries will exist
for each browser that supports custom tabs, with the BrowserDescriptor.useCustomTab
flag set to true in one and false in the other. The list is in the
order returned by the package manager, so indirectly reflects the user’s preferences
(i.e. their default browser, if set, should be the first entry in the list).
@Nullable public static BrowserDescriptor select(android.content.Context context, BrowserMatcher browserMatcher)
Searches through all browsers for the best match based on the supplied browser matcher. Custom tab supporting browsers are preferred, if the matcher permits them, and browsers are evaluated in the order returned by the package manager, which should indirectly match the user’s preferences.
context - Context to use for accessing PackageManager.