Methods Summary |
---|
public void | addJavascriptInterface(java.lang.Object obj, java.lang.String interfaceName)
if (mJSInterfaceMap == null) {
mJSInterfaceMap = new HashMap<String, Object>();
}
if (mJSInterfaceMap.containsKey(interfaceName)) {
mJSInterfaceMap.remove(interfaceName);
}
mJSInterfaceMap.put(interfaceName, obj);
|
public native boolean | cacheDisabled()
|
void | certificate(android.net.http.SslCertificate certificate)We have received an SSL certificate for the main top-level page.
!!!Called from the network thread!!!
if (mIsMainFrame) {
// we want to make this call even if the certificate is null
// (ie, the site is not secure)
mCallbackProxy.onReceivedCertificate(certificate);
}
|
public native void | clearCache()
|
private void | closeWindow(WebViewCore w)Close this frame and window.
mCallbackProxy.onCloseWindow(w.getWebView());
|
boolean | committed()
return mCommitted;
|
private android.webkit.BrowserFrame | createWindow(boolean dialog, boolean userGesture)Request a new window from the client.
WebView w = mCallbackProxy.createWindow(dialog, userGesture);
if (w != null) {
return w.getWebViewCore().getBrowserFrame();
}
return null;
|
private void | decidePolicyForFormResubmission(int policyFunction)
Message dontResend = obtainMessage(POLICY_FUNCTION, policyFunction,
POLICY_IGNORE);
Message resend = obtainMessage(POLICY_FUNCTION, policyFunction,
POLICY_USE);
mCallbackProxy.onFormResubmission(dontResend, resend);
|
public void | destroy()Destroy all native components of the BrowserFrame.
nativeDestroyFrame();
removeCallbacksAndMessages(null);
|
void | didFirstLayout()
if (!mFirstLayoutDone) {
mFirstLayoutDone = true;
// ensure {@link WebViewCore#webkitDraw} is called as we were
// blocking the update in {@link #loadStarted}
mWebViewCore.contentDraw();
}
mWebViewCore.mEndScaleZoom = true;
|
private void | didReceiveIcon(android.graphics.Bitmap icon)Send the icon to the activity for display.
mCallbackProxy.onReceivedIcon(icon);
|
public void | documentAsText(android.os.Message callback)Retrieves the visual text of the current frame, puts it as the object for
the message and sends the message.
callback.obj = documentAsText();;
callback.sendToTarget();
|
private native java.lang.String | documentAsText()Return the text drawn on the screen as a string
|
public native boolean | documentHasImages()Return true if the document has images.
|
public void | externalRepresentation(android.os.Message callback)Retrieves the render tree of this frame and puts it as the object for
the message and sends the message.
callback.obj = externalRepresentation();;
callback.sendToTarget();
|
private native java.lang.String | externalRepresentation()Return the render tree as a string
|
boolean | firstLayoutDone()
return mFirstLayoutDone;
|
CallbackProxy | getCallbackProxy()Get the CallbackProxy for sending messages to the UI thread.
return mCallbackProxy;
|
private native java.util.HashMap | getFormTextData()Get form's "text" type data associated with the current frame.
|
java.lang.String | getRawResFilename(int id)
int resid;
switch (id) {
case NODOMAIN:
resid = com.android.internal.R.raw.nodomain;
break;
case LOADERROR:
resid = com.android.internal.R.raw.loaderror;
break;
default:
Log.e(LOGTAG, "getRawResFilename got incompatible resource ID");
return new String();
}
TypedValue value = new TypedValue();
mContext.getResources().getValue(resid, value, true);
return value.string.toString();
|
java.lang.String | getUserAgentString()Returns the User Agent used by this frame
return mSettings.getUserAgentString();
|
private native java.lang.String[] | getUsernamePassword()Get username and password in the current frame. If found, String[0] is
username and String[1] is password. Otherwise return NULL.
|
public void | goBackOrForward(int steps)Go back or forward the number of steps given.
mLoadInitFromJava = true;
nativeGoBackOrForward(steps);
mLoadInitFromJava = false;
|
public void | handleMessage(android.os.Message msg)Handle messages posted to us.
switch (msg.what) {
case FRAME_COMPLETED: {
if (mSettings.getSavePassword() && hasPasswordField()) {
if (Config.DEBUG) {
Assert.assertNotNull(mCallbackProxy.getBackForwardList()
.getCurrentItem());
}
WebAddress uri = new WebAddress(
mCallbackProxy.getBackForwardList().getCurrentItem()
.getUrl());
String schemePlusHost = uri.mScheme + uri.mHost;
String[] up = mDatabase.getUsernamePassword(schemePlusHost);
if (up != null && up[0] != null) {
setUsernamePassword(up[0], up[1]);
}
}
CacheManager.trimCacheIfNeeded();
break;
}
case POLICY_FUNCTION: {
nativeCallPolicyFunction(msg.arg1, msg.arg2);
break;
}
default:
break;
}
|
public boolean | handleUrl(java.lang.String url)This method is called by WebCore to check whether application
wants to hijack url loading
if (mLoadInitFromJava == true) {
return false;
}
if (mCallbackProxy.shouldOverrideUrlLoading(url)) {
// if the url is hijacked, reset the state of the BrowserFrame
didFirstLayout();
return true;
} else {
return false;
}
|
private native boolean | hasPasswordField()
|
public void | loadData(java.lang.String baseUrl, java.lang.String data, java.lang.String mimeType, java.lang.String encoding, java.lang.String failUrl)Load the content as if it was loaded by the provided base URL. The
failUrl is used as the history entry for the load data. If null or
an empty string is passed for the failUrl, then no history entry is
created.
mLoadInitFromJava = true;
if (failUrl == null) {
failUrl = "";
}
if (data == null) {
data = "";
}
// Setup defaults for missing values. These defaults where taken from
// WebKit's WebFrame.mm
if (baseUrl == null || baseUrl.length() == 0) {
baseUrl = "about:blank";
}
if (mimeType == null || mimeType.length() == 0) {
mimeType = "text/html";
}
nativeLoadData(baseUrl, data, mimeType, encoding, failUrl);
mLoadInitFromJava = false;
|
private void | loadFinished(java.lang.String url, int loadType, boolean isMainFrame)native callback
Indicates the end of a new load.
This method will be called once for the main frame.
// mIsMainFrame and isMainFrame are better be equal!!!
if (isMainFrame || loadType == FRAME_LOADTYPE_STANDARD) {
if (isMainFrame) {
resetLoadingStates();
mCallbackProxy.switchOutDrawHistory();
mCallbackProxy.onPageFinished(url);
}
}
|
private void | loadStarted(java.lang.String url, android.graphics.Bitmap favicon, int loadType, boolean isMainFrame)native callback
Indicates the beginning of a new load.
This method will be called once for the main frame.
mIsMainFrame = isMainFrame;
if (isMainFrame || loadType == FRAME_LOADTYPE_STANDARD) {
mLoadType = loadType;
if (isMainFrame) {
// Call onPageStarted for main frames.
mCallbackProxy.onPageStarted(url, favicon);
// as didFirstLayout() is only called for the main frame, reset
// mFirstLayoutDone only for the main frames
mFirstLayoutDone = false;
mCommitted = false;
// remove pending draw to block update until mFirstLayoutDone is
// set to true in didFirstLayout()
mWebViewCore.removeMessages(WebViewCore.EventHub.WEBKIT_DRAW);
}
// Note: only saves committed form data in standard load
if (loadType == FRAME_LOADTYPE_STANDARD
&& mSettings.getSaveFormData()) {
final WebHistoryItem h = mCallbackProxy.getBackForwardList()
.getCurrentItem();
if (h != null) {
String currentUrl = h.getUrl();
if (currentUrl != null) {
mDatabase.setFormData(currentUrl, getFormTextData());
}
}
}
}
|
int | loadType()
return mLoadType;
|
public void | loadUrl(java.lang.String url)Load a url from the network or the filesystem into the main frame.
Following the same behaviour as Safari, javascript: URLs are not
passed to the main frame, instead they are evaluated immediately.
mLoadInitFromJava = true;
if (URLUtil.isJavaScriptUrl(url)) {
// strip off the scheme and evaluate the string
stringByEvaluatingJavaScriptFromString(
url.substring("javascript:".length()));
} else {
nativeLoadUrl(url);
}
mLoadInitFromJava = false;
|
private native void | nativeAddJavascriptInterface(int nativeFramePointer, java.lang.Object obj, java.lang.String interfaceName)Add a javascript interface to the main frame.
|
private native void | nativeCallPolicyFunction(int policyFunction, int decision)
|
private native void | nativeCreateFrame(WebViewCore w, android.content.res.AssetManager am, WebBackForwardList list)Create a new native frame for a given WebView
|
public native void | nativeDestroyFrame()Destroy the native frame.
|
private native void | nativeGoBackOrForward(int steps)Go back or forward the number of steps given.
|
private native void | nativeLoadData(java.lang.String baseUrl, java.lang.String data, java.lang.String mimeType, java.lang.String encoding, java.lang.String failUrl)
|
private native void | nativeLoadUrl(java.lang.String url)Returns false if the url is bad.
|
private native void | nativeStopLoading()
|
public native void | reload(boolean allowStale)Reload the current main frame.
|
private void | reportError(int errorCode, java.lang.String description, java.lang.String failingUrl)native callback
Report an error to an activity.
// As this is called for the main resource and loading will be stopped
// after, reset the state variables.
resetLoadingStates();
mCallbackProxy.onReceivedError(errorCode, description, failingUrl);
|
private void | requestFocus()Try to focus this WebView.
mCallbackProxy.onRequestFocus();
|
private void | resetLoadingStates()
mCommitted = true;
mWebViewCore.mEndScaleZoom = mFirstLayoutDone == false;
mFirstLayoutDone = true;
|
private native void | setCacheDisabled(boolean disabled)Enable or disable the native cache.
|
private void | setProgress(int newProgress)Set the progress for the browser activity. Called by native code.
Uses a delay so it does not happen too often.
mCallbackProxy.onProgressChanged(newProgress);
if (newProgress == 100) {
sendMessageDelayed(obtainMessage(FRAME_COMPLETED), 100);
}
// FIXME: Need to figure out a better way to switch out of the history
// drawing mode. Maybe we can somehow compare the history picture with
// the current picture, and switch when it contains more content.
if (mFirstLayoutDone && newProgress > TRANSITION_SWITCH_THRESHOLD) {
mCallbackProxy.switchOutDrawHistory();
}
|
private void | setTitle(java.lang.String title)Punch-through for WebCore to set the document
title. Inform the Activity of the new title.
// FIXME: The activity must call getTitle (a native method) to get the
// title. We should try and cache the title if we can also keep it in
// sync with the document.
mCallbackProxy.onReceivedTitle(title);
|
private native void | setUsernamePassword(java.lang.String username, java.lang.String password)Set username and password to the proper fields in the current frame
|
private LoadListener | startLoadingResource(int loaderHandle, java.lang.String url, java.lang.String method, java.util.HashMap headers, byte[] postData, int cacheMode, boolean isHighPriority, boolean synchronous)Start loading a resource.
PerfChecker checker = new PerfChecker();
if (mSettings.getCacheMode() != WebSettings.LOAD_DEFAULT) {
cacheMode = mSettings.getCacheMode();
}
if (method.equals("POST")) {
// Don't use the cache on POSTs when issuing a normal POST
// request.
if (cacheMode == WebSettings.LOAD_NORMAL) {
cacheMode = WebSettings.LOAD_NO_CACHE;
}
if (mSettings.getSavePassword() && hasPasswordField()) {
try {
if (Config.DEBUG) {
Assert.assertNotNull(mCallbackProxy.getBackForwardList()
.getCurrentItem());
}
WebAddress uri = new WebAddress(mCallbackProxy
.getBackForwardList().getCurrentItem().getUrl());
String schemePlusHost = uri.mScheme + uri.mHost;
String[] ret = getUsernamePassword();
// Has the user entered a username/password pair and is
// there some POST data
if (ret != null && postData != null &&
ret[0].length() > 0 && ret[1].length() > 0) {
// Check to see if the username & password appear in
// the post data (there could be another form on the
// page and that was posted instead.
String postString = new String(postData);
if (postString.contains(URLEncoder.encode(ret[0])) &&
postString.contains(URLEncoder.encode(ret[1]))) {
String[] saved = mDatabase.getUsernamePassword(
schemePlusHost);
if (saved != null) {
// null username implies that user has chosen not to
// save password
if (saved[0] != null) {
// non-null username implies that user has
// chosen to save password, so update the
// recorded password
mDatabase.setUsernamePassword(
schemePlusHost, ret[0], ret[1]);
}
} else {
// CallbackProxy will handle creating the resume
// message
mCallbackProxy.onSavePassword(schemePlusHost, ret[0],
ret[1], null);
}
}
}
} catch (ParseException ex) {
// if it is bad uri, don't save its password
}
}
}
// is this resource the main-frame top-level page?
boolean isMainFramePage = mIsMainFrame;
if (Config.LOGV) {
Log.v(LOGTAG, "startLoadingResource: url=" + url + ", method="
+ method + ", postData=" + postData + ", isHighPriority="
+ isHighPriority + ", isMainFramePage=" + isMainFramePage);
}
// Create a LoadListener
LoadListener loadListener = LoadListener.getLoadListener(mContext, this, url,
loaderHandle, synchronous, isMainFramePage);
mCallbackProxy.onLoadResource(url);
if (LoadListener.getNativeLoaderCount() > MAX_OUTSTANDING_REQUESTS) {
loadListener.error(
android.net.http.EventHandler.ERROR, mContext.getString(
com.android.internal.R.string.httpErrorTooManyRequests));
loadListener.notifyError();
loadListener.tearDown();
return null;
}
// during synchronous load, the WebViewCore thread is blocked, so we
// need to endCacheTransaction first so that http thread won't be
// blocked in setupFile() when createCacheFile.
if (synchronous) {
CacheManager.endCacheTransaction();
}
FrameLoader loader = new FrameLoader(loadListener, mSettings,
method, isHighPriority);
loader.setHeaders(headers);
loader.setPostData(postData);
// Set the load mode to the mode used for the current page.
// If WebKit wants validation, go to network directly.
loader.setCacheMode(headers.containsKey("If-Modified-Since")
|| headers.containsKey("If-None-Match") ?
WebSettings.LOAD_NO_CACHE : cacheMode);
// Set referrer to current URL?
if (!loader.executeLoad()) {
checker.responseAlert("startLoadingResource fail");
}
checker.responseAlert("startLoadingResource succeed");
if (synchronous) {
CacheManager.startCacheTransaction();
}
return !synchronous ? loadListener : null;
|
public void | stopLoading()Stop loading the current page.
if (mIsMainFrame) {
resetLoadingStates();
}
nativeStopLoading();
|
public native java.lang.String | stringByEvaluatingJavaScriptFromString(java.lang.String script)stringByEvaluatingJavaScriptFromString will execute the
JS passed in in the context of this browser frame.
|
private void | transitionToCommitted(int loadType, boolean isMainFrame)native callback
Indicates the WebKit has committed to the new load
// loadType is not used yet
if (isMainFrame) {
mCommitted = true;
}
|
private void | updateVisitedHistory(java.lang.String url, boolean isReload)Tell the activity to update its global history.
mCallbackProxy.doUpdateVisitedHistory(url, isReload);
|
private void | windowObjectCleared(int nativeFramePointer)
if (mJSInterfaceMap != null) {
Iterator iter = mJSInterfaceMap.keySet().iterator();
while (iter.hasNext()) {
String interfaceName = (String) iter.next();
nativeAddJavascriptInterface(nativeFramePointer,
mJSInterfaceMap.get(interfaceName), interfaceName);
}
}
|