Package org.mozilla.geckoview
Class IPProtectionController
Object
org.mozilla.geckoview.IPProtectionController
Controller for managing IP protection state.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceEmbedder-provided hooks for authentication.static interfaceDelegate for receiving IP protection state notifications.static classHolds the result of an enrollment attempt.static classException type for IP proxy errors.static classHolds the current IP proxy state and any associated error.static @interfaceThe possible states of the IP protection service.static classHolds information about the current IP proxy usage. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe user has opted out from using VPN.static final intThe service is ready to be activated.static final intThe user is signed out but eligible.static final intThe user is not eligible or still not signed in.static final intThe service has not been initialized yet. -
Method Summary
Modifier and TypeMethodDescriptionactivate()Activates the IP proxy.Deactivates the IP proxy.enroll()Triggers enrollment via the active auth provider.Gets theIPProtectionController.AuthProviderfor this instance.Gets theIPProtectionController.Delegatefor this instance.Gets the current IP proxy state.Gets the current IP protection service state.init()Initializes the IP protection service.notifySignInStateChanged(boolean signedIn) Notifies the IP protection service of a sign-in state change.voidSets theIPProtectionController.AuthProviderused to supply authentication tokens.voidsetDelegate(IPProtectionController.Delegate delegate) Sets theIPProtectionController.Delegatefor this instance.uninit()Uninitializes the IP protection service, resetting the controller to its initial state.
-
Field Details
-
SERVICE_STATE_UNINITIALIZED
public static final int SERVICE_STATE_UNINITIALIZEDThe service has not been initialized yet.- See Also:
-
SERVICE_STATE_UNAVAILABLE
public static final int SERVICE_STATE_UNAVAILABLEThe user is not eligible or still not signed in.- See Also:
-
SERVICE_STATE_UNAUTHENTICATED
public static final int SERVICE_STATE_UNAUTHENTICATEDThe user is signed out but eligible.- See Also:
-
SERVICE_STATE_OPTED_OUT
public static final int SERVICE_STATE_OPTED_OUTThe user has opted out from using VPN.- See Also:
-
SERVICE_STATE_READY
public static final int SERVICE_STATE_READYThe service is ready to be activated.- See Also:
-
-
Method Details
-
init
Initializes the IP protection service.- Returns:
- A
GeckoResultthat resolves when initialization completes.
-
setDelegate
Sets theIPProtectionController.Delegatefor this instance.- Parameters:
delegate- TheIPProtectionController.Delegateinstance.
-
getDelegate
Gets theIPProtectionController.Delegatefor this instance.- Returns:
- The
IPProtectionController.Delegateinstance.
-
setAuthProvider
Sets theIPProtectionController.AuthProviderused to supply authentication tokens. Passnullto clear the provider.The provider governs token retrieval only. Sign-in state must be signalled separately via
notifySignInStateChanged(boolean).Requires
init()to have been called; otherwise the JS-side listeners that consume the provider have not yet been registered.- Parameters:
provider- TheIPProtectionController.AuthProvider, ornullto clear.
-
getAuthProvider
Gets theIPProtectionController.AuthProviderfor this instance.- Returns:
- The
IPProtectionController.AuthProviderinstance, ornullif none is set.
-
notifySignInStateChanged
Notifies the IP protection service of a sign-in state change. The service recomputes its state and may transition in or out ofSERVICE_STATE_UNAUTHENTICATED.Announcing a signed-in user requires an
IPProtectionController.AuthProviderto be set viasetAuthProvider(AuthProvider)beforehand, since the service immediately queries tokens through the provider. Announcing a signed-out user does not require a provider. If the precondition is violated, the returnedGeckoResultis rejected withIllegalStateException.Requires
init()to have been called; otherwise the JS-side listeners that consume the event have not yet been registered.- Parameters:
signedIn- Whether the embedding app currently has a signed-in user.- Returns:
- A
GeckoResultthat resolves once the JS side has acknowledged the event, or rejects withIllegalStateExceptionifsignedInis true and noIPProtectionController.AuthProviderhas been set.
-
uninit
Uninitializes the IP protection service, resetting the controller to its initial state.- Returns:
- A
GeckoResultthat resolves when uninitialization completes.
-
getServiceState
Gets the current IP protection service state.- Returns:
- A
GeckoResultthat resolves to one of theIPProtectionController.ServiceStateconstants.
-
getProxyState
Gets the current IP proxy state.- Returns:
- A
GeckoResultthat resolves to aIPProtectionController.ProxyState.
-
activate
Activates the IP proxy.- Returns:
- A
GeckoResultthat resolves when activated, or rejects with anIPProtectionController.IPProxyExceptiondescribing the failure.
-
enroll
Triggers enrollment via the active auth provider.- Returns:
- A
GeckoResultthat resolves to anIPProtectionController.EnrollResultdescribing whether the user is now enrolled and entitled, and the error string if not.
-
deactivate
Deactivates the IP proxy.- Returns:
- A
GeckoResultthat resolves when deactivated, or rejects with anIPProtectionController.IPProxyExceptionif an unexpected error occurs.
-