Package org.mozilla.geckoview
Class GeckoSession.Loader
Object
org.mozilla.geckoview.GeckoSession.Loader
- Enclosing class:
- GeckoSession
Main entry point for loading URIs into a
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionadditionalHeaders
(Map<String, String> headers) Add headers for this load.Set the data URI of the resource to load.Set the data URI of the resource to load.boolean
flags
(int flags) Set the load flags for this load.int
hashCode()
headerFilter
(int filter) Modify the header filter behavior.Set the referrer for this load.Set the referrer for this load.referrer
(GeckoSession referrer) Set the referrer for this load.Set the URI of the resource to load.Set the URI of the resource to load.
-
Constructor Details
-
Loader
public Loader()
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
uri
Set the URI of the resource to load.- Parameters:
uri
- a String containg the URI- Returns:
- this
GeckoSession.Loader
instance.
-
uri
Set the URI of the resource to load.- Parameters:
uri
- aUri
instance- Returns:
- this
GeckoSession.Loader
instance.
-
data
Set the data URI of the resource to load.- Parameters:
bytes
- abyte
array containing the data to load.mimeType
- aString
containing the mime type for this data URI, e.g. "text/plain"- Returns:
- this
GeckoSession.Loader
instance.
-
data
Set the data URI of the resource to load.- Parameters:
data
- aString
array containing the data to load.mimeType
- aString
containing the mime type for this data URI, e.g. "text/plain"- Returns:
- this
GeckoSession.Loader
instance.
-
referrer
Set the referrer for this load.- Parameters:
referrer
- aGeckoSession
that will be used as the referrer- Returns:
- this
GeckoSession.Loader
instance.
-
referrer
Set the referrer for this load.- Parameters:
referrerUri
- aUri
that will be used as the referrer- Returns:
- this
GeckoSession.Loader
instance.
-
referrer
Set the referrer for this load.- Parameters:
referrerUri
- aString
containing the URI that will be used as the referrer- Returns:
- this
GeckoSession.Loader
instance.
-
additionalHeaders
Add headers for this load.Note: only CORS safelisted headers are allowed by default. To modify this behavior use
headerFilter(int)
.- Parameters:
headers
- aMap
containing headers that will be added to this load.- Returns:
- this
GeckoSession.Loader
instance.
-
headerFilter
Modify the header filter behavior. By default only CORS safelisted headers are allowed.- Parameters:
filter
- one of theHEADER_FILTER_*
constants.- Returns:
- this
GeckoSession.Loader
instance.
-
flags
Set the load flags for this load.- Parameters:
flags
- the load flags to use, an OR-ed value ofLOAD_FLAGS_*
that will be used as the referrer- Returns:
- this
GeckoSession.Loader
instance.
-