Build 1.0_r1(from source)

android.webkit.gears
Class UrlInterceptHandlerGears

java.lang.Object
  extended by android.webkit.gears.UrlInterceptHandlerGears
All Implemented Interfaces:
UrlInterceptHandler

public class UrlInterceptHandlerGears
extends Object
implements UrlInterceptHandler

Services requests to handle URLs coming from the browser or HttpRequestAndroid. This registers itself with the UrlInterceptRegister in Android so we get a chance to service all URLs passing through the browser before anything else.


Nested Class Summary
static class UrlInterceptHandlerGears.ServiceRequest
          Object passed to the native side, containing information about the URL to service.
 class UrlInterceptHandlerGears.ServiceResponse
          Object returned by the native side, containing information needed to pass the entire response back to the browser or HttpRequestAndroid.
 
Field Summary
static int HEADERS_MAP_INDEX_KEY
          The unmodified (case-sensitive) key in the headers map is the same index as used by HttpRequestAndroid.
static int HEADERS_MAP_INDEX_VALUE
          The associated value in the headers map is the same index as used by HttpRequestAndroid.
 
Constructor Summary
UrlInterceptHandlerGears()
          Construct and initialize the singleton instance.
 
Method Summary
static void enableLogging(boolean on)
          Turn on/off logging in this class.
static UrlInterceptHandlerGears getInstance()
          Get the singleton instance.
 UrlInterceptHandlerGears.ServiceResponse getServiceResponse(String url, Map<String,String[]> requestHeaders)
          Given an URL, returns a CacheResult and headers which contain the response for the request.
 void register()
          Register the singleton instance with the browser's interception mechanism.
 CacheManager.CacheResult service(String url, Map<String,String> requestHeaders)
          Given an URL, returns a CacheResult which contains the response for the request.
 void unregister()
          Unregister the singleton instance from the browser's interception mechanism.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADERS_MAP_INDEX_KEY

public static final int HEADERS_MAP_INDEX_KEY
The unmodified (case-sensitive) key in the headers map is the same index as used by HttpRequestAndroid.

See Also:
Constant Field Values

HEADERS_MAP_INDEX_VALUE

public static final int HEADERS_MAP_INDEX_VALUE
The associated value in the headers map is the same index as used by HttpRequestAndroid.

See Also:
Constant Field Values
Constructor Detail

UrlInterceptHandlerGears

public UrlInterceptHandlerGears()
Construct and initialize the singleton instance.

Method Detail

enableLogging

public static void enableLogging(boolean on)
Turn on/off logging in this class.

Parameters:
on - Logging enable state.

getInstance

public static UrlInterceptHandlerGears getInstance()
Get the singleton instance.

Returns:
The singleton instance.

register

public void register()
Register the singleton instance with the browser's interception mechanism.


unregister

public void unregister()
Unregister the singleton instance from the browser's interception mechanism.


service

public CacheManager.CacheResult service(String url,
                                        Map<String,String> requestHeaders)
Given an URL, returns a CacheResult which contains the response for the request. This implements the UrlInterceptHandler interface.

Specified by:
service in interface UrlInterceptHandler
Parameters:
url - The fully qualified URL being requested.
requestHeaders - The request headers for this URL.
Returns:
If a response can be crafted, a CacheResult initialized to return the surrogate response. If this URL cannot be serviced, returns null.

getServiceResponse

public UrlInterceptHandlerGears.ServiceResponse getServiceResponse(String url,
                                                                   Map<String,String[]> requestHeaders)
Given an URL, returns a CacheResult and headers which contain the response for the request.

Parameters:
url - The fully qualified URL being requested.
requestHeaders - The request headers for this URL.
Returns:
If a response can be crafted, a ServiceResponse is created which contains all response headers and an InputStream attached to the body. If there is no response, null is returned.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature