public abstract class

AmazonWebKitFactory

extends Object
java.lang.Object
   ↳ com.amazon.android.webkit.AmazonWebKitFactory

Class Overview

Provides the base class used by factory implementations to create and manage Amazon WebViews. Use the AmazonWebKitFactory class to provide custom method implementations to handle WebKit method calls.

Summary

Public Constructors
AmazonWebKitFactory()
Public Methods
AmazonWebView createWebView(Context context, int solidColor, Object tab, boolean isPrivate)
Creates a WebView object for the appropriate backing implementation.
AmazonWebView createWebView(Context context, int solidColor, Object tab, boolean isPrivate, Bundle extraData)
Creates a WebView object for the appropriate backing implementation The extraData bundle needs to be linked up with the AmazonWebChromeClient.onCreateWindow callback, it's just opaque data that needs to be passed from one call to the other.
void disableDeveloperTools()
Disables the DevTools if they are enabled, closes any connections in use.
abstract int getApiLevel()
Returns the highest Amazon WebView API level that the application can use.
abstract AmazonCookieManager getCookieManager()
Retrieves an instance of an AmazonCookieManager object appropriate for the WebKit implementation in use.
abstract AmazonCookieSyncManager getCookieSyncManager()
Retrieves an instance of an AmazonCookieSyncManager object appropriate for the WebKit implementation in use.
abstract AmazonGeolocationPermissions getGeolocationPermissions()
Retrieves an instance of an AmazonGeolocationPermissions object appropriate for the WebKit implementation in use.
abstract int getMaxApiLevelSupported()
Returns the highest Amazon WebView API level supported by the library installed on the device.
abstract AmazonWebStorage getWebStorage()
Retrieves an instance of an AmazonWebStorage object appropriate for the WebKit implementation in use.
abstract AmazonWebViewDatabase getWebViewDatabase(Context context)
Retrieves an instance of an AmazonWebViewDatabase object appropriate for the WebKit implementation in use.
abstract void initialize(Context context)
Perform initialization for the webkit implementation.
void initializeWebView(AmazonWebView webView, int solidColor, boolean isPrivate, Bundle extraData)
Ensures a WebView is properly initialized for scenarios outside createWebView(Context, int, Object, boolean, Bundle).
abstract boolean isRenderProcess(Context context)
Determines if the current process is a render process.
void setNativeLibraryPackage(String pkgName)
Sets the name of the package that the WebView implementation references to search for native libraries.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AmazonWebKitFactory ()

Public Methods

public AmazonWebView createWebView (Context context, int solidColor, Object tab, boolean isPrivate)

Creates a WebView object for the appropriate backing implementation.

See the Android WebKit constructors at WebView for additional information on createing WebView objects.

Parameters
context The application context.
solidColor The background color of the web view.
tab The tab in which the web page displays. If there is no associated tab, set the value to null.
isPrivate Set to true to specify that the WebView runs in private mode; otherwise false. When set to true, data such as history, cookies, and HTML5 local storage are stored separately from non-privates WebViews. This data is removed when the last WebView created with this flag is closed.
Returns
  • A new WebView object

public AmazonWebView createWebView (Context context, int solidColor, Object tab, boolean isPrivate, Bundle extraData)

Creates a WebView object for the appropriate backing implementation The extraData bundle needs to be linked up with the AmazonWebChromeClient.onCreateWindow callback, it's just opaque data that needs to be passed from one call to the other.

See the Android WebKit constructors at WebView for additional information on createing WebView objects.

Parameters
context The application context.
solidColor The background color of the web view.
tab The tab in which the web page displays. If there is no associated tab, set the value to null.
isPrivate Set to true to specify that the WebView runs in private mode; otherwise false. When set to true, data such as history, cookies, and HTML5 local storage are stored separately from non-privates WebViews. This data is removed when the last WebView created with this flag is closed.
extraData Additional data that is passed to the WebView constructor by the {@link AmazonWebChromeClient.onCreateWindow(AmazonWebView view, boolean dialog, boolean userGesture, Bundle extraData, OnCreateWindowCallback callback) callback method.
Returns
  • a new WebView object

public void disableDeveloperTools ()

Disables the DevTools if they are enabled, closes any connections in use.

public abstract int getApiLevel ()

Returns the highest Amazon WebView API level that the application can use.

The value returned is the lower of:


You can check the returned value and conditionally use features that are only available in later Amazon WebView API levels, while remaining compatible with early levels. For example, if the Amazon WebView API level installed on the device does not support the desired functionality you can choose to exit the application or degrade functionality by only calling methods available to the installed level of the API. Graceful degradation requires additional testing on each of the older Amazon WebView implementations that you intend to support.

Example:
 if (AmazonWebKitFactories.getDefaultFactory().getApiLevel() > AmazonApiLevels.AWV_LEVEL_2) {
      // Call a newer API added in AWV_LEVEL_3 or above.
   
 }
 

Returns
  • API Level.

public abstract AmazonCookieManager getCookieManager ()

Retrieves an instance of an AmazonCookieManager object appropriate for the WebKit implementation in use.

Returns

public abstract AmazonCookieSyncManager getCookieSyncManager ()

Retrieves an instance of an AmazonCookieSyncManager object appropriate for the WebKit implementation in use.

Returns

public abstract AmazonGeolocationPermissions getGeolocationPermissions ()

Retrieves an instance of an AmazonGeolocationPermissions object appropriate for the WebKit implementation in use.

Returns

public abstract int getMaxApiLevelSupported ()

Returns the highest Amazon WebView API level supported by the library installed on the device.

You can use this value to determine whether the application can support the Amazon WebView functionality necessary to provide an acceptable user experience. If the installed Amazon WebView API library does not support the functionality you require, you can choose to exit the application.
Example:

 if (AmazonWebKitFactories.getDefaultFactory().getMaxApiLevelSupported() < AmazonApiLevels.AWV_LEVEL_2) {
      // Exit the application.
   
 }
 

Returns
  • API Level

public abstract AmazonWebStorage getWebStorage ()

Retrieves an instance of an AmazonWebStorage object appropriate for the WebKit implementation in use.

Returns

public abstract AmazonWebViewDatabase getWebViewDatabase (Context context)

Retrieves an instance of an AmazonWebViewDatabase object appropriate for the WebKit implementation in use.

Parameters
context The application context.
Returns

public abstract void initialize (Context context)

Perform initialization for the webkit implementation. Call this method on the main thread.

Parameters
context The application context.

public void initializeWebView (AmazonWebView webView, int solidColor, boolean isPrivate, Bundle extraData)

Ensures a WebView is properly initialized for scenarios outside createWebView(Context, int, Object, boolean, Bundle).

Parameters
webView The webview to initialize.
solidColor The background color.
isPrivate Flag for private tabs. If set to true then the created webview will run in a private mode, which means that the browsing data such as history, cookies, and HTML5 local storage are maintained separately from the non-privates. This data is cleaned when the last webview created with this flag is closed.
extraData Any other extra data to be passed to the WebView constructor.
Throws
IllegalStateException if the WebView is Invalid

public abstract boolean isRenderProcess (Context context)

Determines if the current process is a render process.

Render processes construct web pages. Render processes are not created by the application. They are created and managed internally by the Amazon WebView API. To avoid conflict with the page construction process, you must not perform any application specific logic in the render process. Doing so could slow down the page load.

Call this function to determine if the current process is a render process and refrain from performing application logic if it is.

Note that AmazonWebKitFactory.initializate() or warmUp() functions must not be called in a render process.

Parameters
context The application context.
Returns
  • If the current process is a render process, true; otherwise, false.

public void setNativeLibraryPackage (String pkgName)

Sets the name of the package that the WebView implementation references to search for native libraries. This value is used when the current platform version does not put the native libraries on the linker path.

The implementation uses the libraries found in the specified package instead of the libraries found in the native library search path of the virtual machine.

Parameters
pkgName The name of the package to reference. Set to null to reset to the default com.amazon.webview package.