Merge change 9682

* changes:
  Add a callback for the url of an apple-touch-icon.
This commit is contained in:
Android (Google) Code Review
2009-08-05 09:50:29 -07:00
6 changed files with 73 additions and 1 deletions

View File

@@ -107,7 +107,8 @@ public class Browser {
public static final String[] HISTORY_PROJECTION = new String[] {
BookmarkColumns._ID, BookmarkColumns.URL, BookmarkColumns.VISITS,
BookmarkColumns.DATE, BookmarkColumns.BOOKMARK, BookmarkColumns.TITLE,
BookmarkColumns.FAVICON, BookmarkColumns.THUMBNAIL };
BookmarkColumns.FAVICON, BookmarkColumns.THUMBNAIL,
BookmarkColumns.TOUCH_ICON };
/* these indices dependent on HISTORY_PROJECTION */
public static final int HISTORY_PROJECTION_ID_INDEX = 0;
@@ -121,6 +122,10 @@ public class Browser {
* @hide
*/
public static final int HISTORY_PROJECTION_THUMBNAIL_INDEX = 7;
/**
* @hide
*/
public static final int HISTORY_PROJECTION_TOUCH_ICON_INDEX = 8;
/* columns needed to determine whether to truncate history */
public static final String[] TRUNCATE_HISTORY_PROJECTION = new String[] {
@@ -521,6 +526,10 @@ public class Browser {
* @hide
*/
public static final String THUMBNAIL = "thumbnail";
/**
* @hide
*/
public static final String TOUCH_ICON = "touch_icon";
}
public static class SearchColumns implements BaseColumns {

View File

@@ -615,6 +615,11 @@ class BrowserFrame extends Handler {
mCallbackProxy.onReceivedIcon(icon);
}
// Called by JNI when an apple-touch-icon attribute was found.
private void didReceiveTouchIconUrl(String url) {
mCallbackProxy.onReceivedTouchIconUrl(url);
}
/**
* Request a new window from the client.
* @return The BrowserFrame object stored in the new WebView.

View File

@@ -104,6 +104,7 @@ class CallbackProxy extends Handler {
private static final int ADD_MESSAGE_TO_CONSOLE = 129;
private static final int GEOLOCATION_PERMISSIONS_SHOW_PROMPT = 130;
private static final int GEOLOCATION_PERMISSIONS_HIDE_PROMPT = 131;
private static final int RECEIVED_TOUCH_ICON_URL = 132;
// Message triggered by the client to resume execution
private static final int NOTIFY = 200;
@@ -244,6 +245,13 @@ class CallbackProxy extends Handler {
}
break;
case RECEIVED_TOUCH_ICON_URL:
if (mWebChromeClient != null) {
mWebChromeClient.onReceivedTouchIconUrl(mWebView,
(String) msg.obj);
}
break;
case RECEIVED_TITLE:
if (mWebChromeClient != null) {
mWebChromeClient.onReceivedTitle(mWebView,
@@ -1054,6 +1062,21 @@ class CallbackProxy extends Handler {
sendMessage(obtainMessage(RECEIVED_ICON, icon));
}
/* package */ void onReceivedTouchIconUrl(String url) {
// We should have a current item but we do not want to crash so check
// for null.
WebHistoryItem i = mBackForwardList.getCurrentItem();
if (i != null) {
i.setTouchIconUrl(url);
}
// Do an unsynchronized quick check to avoid posting if no callback has
// been set.
if (mWebChromeClient == null) {
return;
}
sendMessage(obtainMessage(RECEIVED_TOUCH_ICON_URL, url));
}
public void onReceivedTitle(String title) {
// Do an unsynchronized quick check to avoid posting if no callback has
// been set.

View File

@@ -44,6 +44,14 @@ public class WebChromeClient {
*/
public void onReceivedIcon(WebView view, Bitmap icon) {}
/**
* Notify the host application of the url for an apple-touch-icon.
* @param view The WebView that initiated the callback.
* @param url The icon url.
* @hide pending council approval
*/
public void onReceivedTouchIconUrl(WebView view, String url) {}
/**
* A callback interface used by the host application to notify
* the current page that its custom view has been dismissed.

View File

@@ -39,6 +39,8 @@ 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;
/**
* Basic constructor that assigns a unique id to the item. Called by JNI
@@ -126,6 +128,14 @@ public class WebHistoryItem implements Cloneable {
return mFavicon;
}
/**
* Return the touch icon url.
* @hide
*/
public String getTouchIconUrl() {
return mTouchIconUrl;
}
/**
* Set the favicon.
* @param icon A Bitmap containing the favicon for this history item.
@@ -136,6 +146,14 @@ public class WebHistoryItem implements Cloneable {
mFavicon = icon;
}
/**
* Set the touch icon url.
* @hide
*/
/*package*/ void setTouchIconUrl(String url) {
mTouchIconUrl = url;
}
/**
* Get the pre-flattened data.
* Note: The VM ensures 32-bit atomic read/write operations so we don't have

View File

@@ -2002,6 +2002,15 @@ public class WebView extends AbsoluteLayout
return h != null ? h.getFavicon() : null;
}
/**
* Get the touch icon url for the apple-touch-icon <link> element.
* @hide
*/
public String getTouchIconUrl() {
WebHistoryItem h = mCallbackProxy.getBackForwardList().getCurrentItem();
return h != null ? h.getTouchIconUrl() : null;
}
/**
* Get the progress for the current page.
* @return The progress for the current page between 0 and 100.