@AnyThread public static class GeckoSession.Loader extends Object
GeckoSession
.
The simplest use case is loading a URIs with no extra options, this can
be accomplished by specifying the URI in uri(java.lang.String)
and then calling
GeckoSession.load(org.mozilla.geckoview.GeckoSession.Loader)
, e.g.
session.load(new Loader().uri("http://mozilla.org"));
This class can also be used to load data:
URIs, either from
a byte[]
array or a String
using data(byte[], java.lang.String)
, e.g.
session.load(new Loader().data("the data:1234,5678", "text/plain"));
This class also allows you to specify some extra data, e.g. you can set
a referrer using referrer(org.mozilla.geckoview.GeckoSession)
which can either be a GeckoSession
or a plain URL string. You can also specify some Load
Flags using flags(int)
.
The class is structured as a Builder, so method calls can be easily
chained, e.g.
session.load(new Loader()
.url("http://mozilla.org")
.referrer("http://my-referrer.com")
.flags(...));
Constructor and Description |
---|
Loader() |
Modifier and Type | Method and Description |
---|---|
GeckoSession.Loader |
additionalHeaders(Map<String,String> headers)
Add headers for this load.
|
GeckoSession.Loader |
data(byte[] bytes,
String mimeType)
Set the data URI of the resource to load.
|
GeckoSession.Loader |
data(String data,
String mimeType)
Set the data URI of the resource to load.
|
boolean |
equals(Object obj) |
GeckoSession.Loader |
flags(int flags)
Set the load flags for this load.
|
int |
hashCode() |
GeckoSession.Loader |
headerFilter(int filter)
Modify the header filter behavior.
|
GeckoSession.Loader |
referrer(GeckoSession referrer)
Set the referrer for this load.
|
GeckoSession.Loader |
referrer(String referrerUri)
Set the referrer for this load.
|
GeckoSession.Loader |
referrer(Uri referrerUri)
Set the referrer for this load.
|
GeckoSession.Loader |
uri(String uri)
Set the URI of the resource to load.
|
GeckoSession.Loader |
uri(Uri uri)
Set the URI of the resource to load.
|
@NonNull public GeckoSession.Loader uri(@NonNull String uri)
uri
- a String containg the URIGeckoSession.Loader
instance.@NonNull public GeckoSession.Loader uri(@NonNull Uri uri)
uri
- a Uri
instanceGeckoSession.Loader
instance.@NonNull public GeckoSession.Loader data(@NonNull byte[] bytes, @Nullable String mimeType)
bytes
- a byte
array containing the data to load.mimeType
- a String
containing the mime type for this
data URI, e.g. "text/plain"GeckoSession.Loader
instance.@NonNull public GeckoSession.Loader data(@NonNull String data, @Nullable String mimeType)
data
- a String
array containing the data to load.mimeType
- a String
containing the mime type for this
data URI, e.g. "text/plain"GeckoSession.Loader
instance.@NonNull public GeckoSession.Loader referrer(@NonNull GeckoSession referrer)
referrer
- a GeckoSession
that will be used as the referrerGeckoSession.Loader
instance.@NonNull public GeckoSession.Loader referrer(@NonNull Uri referrerUri)
referrerUri
- a Uri
that will be used as the referrerGeckoSession.Loader
instance.@NonNull public GeckoSession.Loader referrer(@NonNull String referrerUri)
referrerUri
- a String
containing the URI
that will be used as the referrerGeckoSession.Loader
instance.@NonNull public GeckoSession.Loader additionalHeaders(@NonNull Map<String,String> headers)
headerFilter(int)
.
See
CORS-safelisted request header
.headers
- a Map
containing headers that will
be added to this load.GeckoSession.Loader
instance.@NonNull public GeckoSession.Loader headerFilter(int filter)
filter
- one of the
HEADER_FILTER_*
constants.GeckoSession.Loader
instance.@NonNull public GeckoSession.Loader flags(int flags)
flags
- the load flags to use, an OR-ed value of
LOAD_FLAGS_*
that will be used as the referrerGeckoSession.Loader
instance.