Merge "If no touch icon is specified by a <link> tag, return <host>/apple-touch-icon.png as the touch incon url instead. The DownloadTouchIcon class will handle the case that this file does not exist on the server."
This commit is contained in:
@@ -1222,9 +1222,7 @@ class CallbackProxy extends Handler {
|
||||
// for null.
|
||||
WebHistoryItem i = mBackForwardList.getCurrentItem();
|
||||
if (i != null) {
|
||||
if (precomposed || i.getTouchIconUrl() == null) {
|
||||
i.setTouchIconUrl(url);
|
||||
}
|
||||
i.setTouchIconUrl(url, precomposed);
|
||||
}
|
||||
// Do an unsynchronized quick check to avoid posting if no callback has
|
||||
// been set.
|
||||
|
||||
@@ -18,6 +18,9 @@ package android.webkit;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* A convenience class for accessing fields in an entry in the back/forward list
|
||||
* of a WebView. Each WebHistoryItem is a snapshot of the requested history
|
||||
@@ -39,8 +42,12 @@ public class WebHistoryItem implements Cloneable {
|
||||
private Bitmap mFavicon;
|
||||
// The pre-flattened data used for saving the state.
|
||||
private byte[] mFlattenedData;
|
||||
// The apple-touch-icon url for use when adding the site to the home screen
|
||||
private String mTouchIconUrl;
|
||||
// The apple-touch-icon url for use when adding the site to the home screen,
|
||||
// as obtained from a <link> element in the page.
|
||||
private String mTouchIconUrlFromLink;
|
||||
// If no <link> is specified, this holds the default location of the
|
||||
// apple-touch-icon.
|
||||
private String mTouchIconUrlServerDefault;
|
||||
// Custom client data that is not flattened or read by native code.
|
||||
private Object mCustomData;
|
||||
|
||||
@@ -132,10 +139,28 @@ public class WebHistoryItem implements Cloneable {
|
||||
|
||||
/**
|
||||
* Return the touch icon url.
|
||||
* If no touch icon <link> tag was specified, returns
|
||||
* <host>/apple-touch-icon.png. The DownloadTouchIcon class that
|
||||
* attempts to retrieve the touch icon will handle the case where
|
||||
* that file does not exist. An icon set by a <link> tag is always
|
||||
* used in preference to an icon saved on the server.
|
||||
* @hide
|
||||
*/
|
||||
public String getTouchIconUrl() {
|
||||
return mTouchIconUrl;
|
||||
if (mTouchIconUrlFromLink != null) {
|
||||
return mTouchIconUrlFromLink;
|
||||
} else if (mTouchIconUrlServerDefault != null) {
|
||||
return mTouchIconUrlServerDefault;
|
||||
}
|
||||
|
||||
try {
|
||||
URL url = new URL(mOriginalUrl);
|
||||
mTouchIconUrlServerDefault = new URL(url.getProtocol(), url.getHost(), url.getPort(),
|
||||
"/apple-touch-icon.png").toString();
|
||||
} catch (MalformedURLException e) {
|
||||
return null;
|
||||
}
|
||||
return mTouchIconUrlServerDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,11 +196,14 @@ public class WebHistoryItem implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the touch icon url.
|
||||
* Set the touch icon url. Will not overwrite an icon that has been
|
||||
* set already from a <link> tag, unless the new icon is precomposed.
|
||||
* @hide
|
||||
*/
|
||||
/*package*/ void setTouchIconUrl(String url) {
|
||||
mTouchIconUrl = url;
|
||||
/*package*/ void setTouchIconUrl(String url, boolean precomposed) {
|
||||
if (precomposed || mTouchIconUrlFromLink == null) {
|
||||
mTouchIconUrlFromLink = url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2314,7 +2314,9 @@ public class WebView extends AbsoluteLayout
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the touch icon url for the apple-touch-icon <link> element.
|
||||
* Get the touch icon url for the apple-touch-icon <link> element, or
|
||||
* a URL on this site's server pointing to the standard location of a
|
||||
* touch icon.
|
||||
* @hide
|
||||
*/
|
||||
public String getTouchIconUrl() {
|
||||
|
||||
Reference in New Issue
Block a user