Package org.mozilla.geckoview
Class ContentBlocking.SafeBrowsingProvider
Object
org.mozilla.geckoview.RuntimeSettings
org.mozilla.geckoview.ContentBlocking.SafeBrowsingProvider
- All Implemented Interfaces:
Parcelable
- Enclosing class:
- ContentBlocking
Holds configuration for a SafeBrowsing provider.
This class can be used to modify existing configuration for SafeBrowsing providers or to add a custom SafeBrowsing provider to the app.
Default configuration for Google's SafeBrowsing servers can be found at
This class is immutable, once constructed its values cannot be changed.
You can, however, use the
You can also add a custom SafeBrowsing provider using the
This class can be used to modify existing configuration for SafeBrowsing providers or to add a custom SafeBrowsing provider to the app.
Default configuration for Google's SafeBrowsing servers can be found at
ContentBlocking.GOOGLE_SAFE_BROWSING_PROVIDER
and ContentBlocking.GOOGLE_LEGACY_SAFE_BROWSING_PROVIDER
. This class is immutable, once constructed its values cannot be changed.
You can, however, use the
from(org.mozilla.geckoview.ContentBlocking.SafeBrowsingProvider)
method to build upon an existing configuration. For
example to override the Google's server configuration, you can do the following:
SafeBrowsingProvider override = SafeBrowsingProvider
.from(ContentBlocking.GOOGLE_SAFE_BROWSING_PROVIDER)
.getHashUrl("http://my-custom-server.com/...")
.updateUrl("http://my-custom-server.com/...")
.build();
runtime.getContentBlocking().setSafeBrowsingProviders(override);
This will override the configuration. You can also add a custom SafeBrowsing provider using the
withName(java.lang.String)
method. For
example, to add a custom provider that provides the list testprovider-phish-digest256
do the following:
SafeBrowsingProvider custom = SafeBrowsingProvider
.withName("custom-provider")
.version("2.2")
.lists("testprovider-phish-digest256")
.updateUrl("http://my-custom-server2.com/...")
.getHashUrl("http://my-custom-server2.com/...")
.build();
And then add the custom provider (adding optionally existing providers):
runtime.getContentBlocking().setSafeBrowsingProviders(
custom,
// Add this if you want to keep the existing configuration too.
ContentBlocking.GOOGLE_SAFE_BROWSING_PROVIDER,
ContentBlocking.GOOGLE_LEGACY_SAFE_BROWSING_PROVIDER);
And set the list in the phishing configuration
runtime.getContentBlocking().setSafeBrowsingPhishingTable(
"testprovider-phish-digest256",
// Existing configuration
"goog-phish-proto");
Note that any list present in the phishing or malware tables need to appear in one safe
browsing provider's getLists()
property.
See also safe-browsing/v4.
-
Nested Class Summary
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Parcelable.Creator<ContentBlocking.SafeBrowsingProvider>
Creator instance for this class.Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Method Summary
Modifier and TypeMethodDescriptionfrom
(ContentBlocking.SafeBrowsingProvider provider) Creates aContentBlocking.SafeBrowsingProvider.Builder
based on the given provider.Get the advisory name for this provider.Get the url that will be used to give a general advisory about this SafeBrowsing provider.Get whether to share threat data with the provider.Get the url to share threat data to the provider, if enabled bygetDataSharingEnabled()
.Get the url that will be used to get the full hashes that match a partial hash.String[]
getLists()
Get the lists provided by this provider.getName()
Get the name of this provider.Get the url that will be used to report a url mistakenly reported as Malware to the SafeBrowsing provider.Get the url that will be used to report a url mistakenly reported as Phishing to the SafeBrowsing provider.Get the url that will be used to report a url to the SafeBrowsing provider.Get the url that will be used to update the threat list for this provider.Get the version for this provider.Creates aContentBlocking.SafeBrowsingProvider.Builder
for a provider with the given name.void
writeToParcel
(Parcel out, int flags) Methods inherited from class org.mozilla.geckoview.RuntimeSettings
describeContents, readFromParcel, updatePrefs
-
Field Details
-
CREATOR
Creator instance for this class.
-
-
Method Details
-
withName
Creates aContentBlocking.SafeBrowsingProvider.Builder
for a provider with the given name.Note: the
mozilla
name is reserved for internal use, and this method will throw if you attempt to build a provider with that name.- Parameters:
name
- The name of the provider.- Returns:
- a
ContentBlocking.SafeBrowsingProvider.Builder
instance that can be used to build a provider. - Throws:
IllegalArgumentException
- if this method is called withname="mozilla"
-
from
@NonNull public static ContentBlocking.SafeBrowsingProvider.Builder from(@NonNull ContentBlocking.SafeBrowsingProvider provider) Creates aContentBlocking.SafeBrowsingProvider.Builder
based on the given provider.All properties not otherwise specified will be copied from the provider given in input.
- Parameters:
provider
- The source provider for this builder.- Returns:
- a
ContentBlocking.SafeBrowsingProvider.Builder
instance that can be used to create a configuration based on the builder in input.
-
getName
Get the name of this provider.- Returns:
- a string containing the name.
-
getVersion
Get the version for this provider.- Returns:
- a string representing the version, e.g. "2.2" or "4".
-
getLists
Get the lists provided by this provider.- Returns:
- an array of string identifiers for the lists
-
getUpdateUrl
Get the url that will be used to update the threat list for this provider.See also v4/threadListUpdates/fetch .
- Returns:
- a string containing the URL.
-
getGetHashUrl
Get the url that will be used to get the full hashes that match a partial hash.See also v4/fullHashes/find .
- Returns:
- a string containing the URL.
-
getReportUrl
Get the url that will be used to report a url to the SafeBrowsing provider.- Returns:
- a string containing the URL.
-
getReportPhishingMistakeUrl
Get the url that will be used to report a url mistakenly reported as Phishing to the SafeBrowsing provider.- Returns:
- a string containing the URL.
-
getReportMalwareMistakeUrl
Get the url that will be used to report a url mistakenly reported as Malware to the SafeBrowsing provider.- Returns:
- a string containing the URL.
-
getAdvisoryUrl
Get the url that will be used to give a general advisory about this SafeBrowsing provider.- Returns:
- a string containing the URL.
-
getAdvisoryName
Get the advisory name for this provider.- Returns:
- a string containing the URL.
-
getDataSharingUrl
Get the url to share threat data to the provider, if enabled bygetDataSharingEnabled()
.- Returns:
- this
ContentBlocking.SafeBrowsingProvider.Builder
instance.
-
getDataSharingEnabled
Get whether to share threat data with the provider.- Returns:
true
if the browser should whare threat data with the provider,false
otherwise.
-
writeToParcel
- Specified by:
writeToParcel
in interfaceParcelable
- Overrides:
writeToParcel
in classRuntimeSettings
-