Home | History | Annotate | Download | only in provider
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.provider;
     18 
     19 import android.content.ContentResolver;
     20 import android.content.ContentUris;
     21 import android.content.ContentValues;
     22 import android.content.Context;
     23 import android.content.Intent;
     24 import android.database.Cursor;
     25 import android.database.DatabaseUtils;
     26 import android.graphics.BitmapFactory;
     27 import android.net.Uri;
     28 import android.os.Build;
     29 import android.provider.BrowserContract.Bookmarks;
     30 import android.provider.BrowserContract.Combined;
     31 import android.provider.BrowserContract.History;
     32 import android.provider.BrowserContract.Searches;
     33 import android.util.Log;
     34 import android.webkit.WebIconDatabase;
     35 
     36 public class Browser {
     37     private static final String LOGTAG = "browser";
     38 
     39     /**
     40      * A table containing both bookmarks and history items. The columns of the table are defined in
     41      * {@link BookmarkColumns}. Reading this table requires the
     42      * {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} permission and writing to it
     43      * requires the {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} permission.
     44      */
     45     public static final Uri BOOKMARKS_URI = Uri.parse("content://browser/bookmarks");
     46 
     47     /**
     48      * The name of extra data when starting Browser with ACTION_VIEW or
     49      * ACTION_SEARCH intent.
     50      * <p>
     51      * The value should be an integer between 0 and 1000. If not set or set to
     52      * 0, the Browser will use default. If set to 100, the Browser will start
     53      * with 100%.
     54      */
     55     public static final String INITIAL_ZOOM_LEVEL = "browser.initialZoomLevel";
     56 
     57     /**
     58      * The name of the extra data when starting the Browser from another
     59      * application.
     60      * <p>
     61      * The value is a unique identification string that will be used to
     62      * identify the calling application. The Browser will attempt to reuse the
     63      * same window each time the application launches the Browser with the same
     64      * identifier.
     65      */
     66     public static final String EXTRA_APPLICATION_ID = "com.android.browser.application_id";
     67 
     68     /**
     69      * The name of the extra data in the VIEW intent. The data are key/value
     70      * pairs in the format of Bundle. They will be sent in the HTTP request
     71      * headers for the provided url. The keys can't be the standard HTTP headers
     72      * as they are set by the WebView. The url's schema must be http(s).
     73      * <p>
     74      */
     75     public static final String EXTRA_HEADERS = "com.android.browser.headers";
     76 
     77     /* if you change column order you must also change indices
     78        below */
     79     public static final String[] HISTORY_PROJECTION = new String[] {
     80             BookmarkColumns._ID, // 0
     81             BookmarkColumns.URL, // 1
     82             BookmarkColumns.VISITS, // 2
     83             BookmarkColumns.DATE, // 3
     84             BookmarkColumns.BOOKMARK, // 4
     85             BookmarkColumns.TITLE, // 5
     86             BookmarkColumns.FAVICON, // 6
     87             BookmarkColumns.THUMBNAIL, // 7
     88             BookmarkColumns.TOUCH_ICON, // 8
     89             BookmarkColumns.USER_ENTERED, // 9
     90     };
     91 
     92     /* these indices dependent on HISTORY_PROJECTION */
     93     public static final int HISTORY_PROJECTION_ID_INDEX = 0;
     94     public static final int HISTORY_PROJECTION_URL_INDEX = 1;
     95     public static final int HISTORY_PROJECTION_VISITS_INDEX = 2;
     96     public static final int HISTORY_PROJECTION_DATE_INDEX = 3;
     97     public static final int HISTORY_PROJECTION_BOOKMARK_INDEX = 4;
     98     public static final int HISTORY_PROJECTION_TITLE_INDEX = 5;
     99     public static final int HISTORY_PROJECTION_FAVICON_INDEX = 6;
    100     /**
    101      * @hide
    102      */
    103     public static final int HISTORY_PROJECTION_THUMBNAIL_INDEX = 7;
    104     /**
    105      * @hide
    106      */
    107     public static final int HISTORY_PROJECTION_TOUCH_ICON_INDEX = 8;
    108 
    109     /* columns needed to determine whether to truncate history */
    110     public static final String[] TRUNCATE_HISTORY_PROJECTION = new String[] {
    111             BookmarkColumns._ID,
    112             BookmarkColumns.DATE,
    113     };
    114 
    115     public static final int TRUNCATE_HISTORY_PROJECTION_ID_INDEX = 0;
    116 
    117     /* truncate this many history items at a time */
    118     public static final int TRUNCATE_N_OLDEST = 5;
    119 
    120     /**
    121      * A table containing a log of browser searches. The columns of the table are defined in
    122      * {@link SearchColumns}. Reading this table requires the
    123      * {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} permission and writing to it
    124      * requires the {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS} permission.
    125      */
    126     public static final Uri SEARCHES_URI = Uri.parse("content://browser/searches");
    127 
    128     /**
    129      * A projection of {@link #SEARCHES_URI} that contains {@link SearchColumns#_ID},
    130      * {@link SearchColumns#SEARCH}, and {@link SearchColumns#DATE}.
    131      */
    132     public static final String[] SEARCHES_PROJECTION = new String[] {
    133             // if you change column order you must also change indices below
    134             SearchColumns._ID, // 0
    135             SearchColumns.SEARCH, // 1
    136             SearchColumns.DATE, // 2
    137     };
    138 
    139     /* these indices dependent on SEARCHES_PROJECTION */
    140     public static final int SEARCHES_PROJECTION_SEARCH_INDEX = 1;
    141     public static final int SEARCHES_PROJECTION_DATE_INDEX = 2;
    142 
    143     /* Set a cap on the count of history items in the history/bookmark
    144        table, to prevent db and layout operations from dragging to a
    145        crawl.  Revisit this cap when/if db/layout performance
    146        improvements are made.  Note: this does not affect bookmark
    147        entries -- if the user wants more bookmarks than the cap, they
    148        get them. */
    149     private static final int MAX_HISTORY_COUNT = 250;
    150 
    151     /**
    152      *  Open an activity to save a bookmark. Launch with a title
    153      *  and/or a url, both of which can be edited by the user before saving.
    154      *
    155      *  @param c        Context used to launch the activity to add a bookmark.
    156      *  @param title    Title for the bookmark. Can be null or empty string.
    157      *  @param url      Url for the bookmark. Can be null or empty string.
    158      */
    159     public static final void saveBookmark(Context c,
    160                                           String title,
    161                                           String url) {
    162         Intent i = new Intent(Intent.ACTION_INSERT, Browser.BOOKMARKS_URI);
    163         i.putExtra("title", title);
    164         i.putExtra("url", url);
    165         c.startActivity(i);
    166     }
    167 
    168     /**
    169      * Boolean extra passed along with an Intent to a browser, specifying that
    170      * a new tab be created.  Overrides EXTRA_APPLICATION_ID; if both are set,
    171      * a new tab will be used, rather than using the same one.
    172      */
    173     public static final String EXTRA_CREATE_NEW_TAB = "create_new_tab";
    174 
    175     /**
    176      * Stores a Bitmap extra in an {@link Intent} representing the screenshot of
    177      * a page to share.  When receiving an {@link Intent#ACTION_SEND} from the
    178      * Browser, use this to access the screenshot.
    179      * @hide
    180      */
    181     public final static String EXTRA_SHARE_SCREENSHOT = "share_screenshot";
    182 
    183     /**
    184      * Stores a Bitmap extra in an {@link Intent} representing the favicon of a
    185      * page to share.  When receiving an {@link Intent#ACTION_SEND} from the
    186      * Browser, use this to access the favicon.
    187      * @hide
    188      */
    189     public final static String EXTRA_SHARE_FAVICON = "share_favicon";
    190 
    191     /**
    192      * Sends the given string using an Intent with {@link Intent#ACTION_SEND} and a mime type
    193      * of text/plain. The string is put into {@link Intent#EXTRA_TEXT}.
    194      *
    195      * @param context the context used to start the activity
    196      * @param string the string to send
    197      */
    198     public static final void sendString(Context context, String string) {
    199         sendString(context, string, context.getString(com.android.internal.R.string.sendText));
    200     }
    201 
    202     /**
    203      *  Find an application to handle the given string and, if found, invoke
    204      *  it with the given string as a parameter.
    205      *  @param c Context used to launch the new activity.
    206      *  @param stringToSend The string to be handled.
    207      *  @param chooserDialogTitle The title of the dialog that allows the user
    208      *  to select between multiple applications that are all capable of handling
    209      *  the string.
    210      *  @hide pending API council approval
    211      */
    212     public static final void sendString(Context c,
    213                                         String stringToSend,
    214                                         String chooserDialogTitle) {
    215         Intent send = new Intent(Intent.ACTION_SEND);
    216         send.setType("text/plain");
    217         send.putExtra(Intent.EXTRA_TEXT, stringToSend);
    218 
    219         try {
    220             Intent i = Intent.createChooser(send, chooserDialogTitle);
    221             // In case this is called from outside an Activity
    222             i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    223             c.startActivity(i);
    224         } catch(android.content.ActivityNotFoundException ex) {
    225             // if no app handles it, do nothing
    226         }
    227     }
    228 
    229     /**
    230      *  Return a cursor pointing to a list of all the bookmarks. The cursor will have a single
    231      *  column, {@link BookmarkColumns#URL}.
    232      *  <p>
    233      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    234      *
    235      *  @param cr   The ContentResolver used to access the database.
    236      */
    237     public static final Cursor getAllBookmarks(ContentResolver cr) throws
    238             IllegalStateException {
    239         return cr.query(Bookmarks.CONTENT_URI,
    240                 new String[] { Bookmarks.URL },
    241                 Bookmarks.IS_FOLDER + " = 0", null, null);
    242     }
    243 
    244     /**
    245      *  Return a cursor pointing to a list of all visited site urls. The cursor will
    246      *  have a single column, {@link BookmarkColumns#URL}.
    247      *  <p>
    248      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    249      *
    250      *  @param cr   The ContentResolver used to access the database.
    251      */
    252     public static final Cursor getAllVisitedUrls(ContentResolver cr) throws
    253             IllegalStateException {
    254         return cr.query(Combined.CONTENT_URI,
    255                 new String[] { Combined.URL }, null, null,
    256                 Combined.DATE_CREATED + " ASC");
    257     }
    258 
    259     private static final void addOrUrlEquals(StringBuilder sb) {
    260         sb.append(" OR " + BookmarkColumns.URL + " = ");
    261     }
    262 
    263     private static final Cursor getVisitedLike(ContentResolver cr, String url) {
    264         boolean secure = false;
    265         String compareString = url;
    266         if (compareString.startsWith("http://")) {
    267             compareString = compareString.substring(7);
    268         } else if (compareString.startsWith("https://")) {
    269             compareString = compareString.substring(8);
    270             secure = true;
    271         }
    272         if (compareString.startsWith("www.")) {
    273             compareString = compareString.substring(4);
    274         }
    275         StringBuilder whereClause = null;
    276         if (secure) {
    277             whereClause = new StringBuilder(Bookmarks.URL + " = ");
    278             DatabaseUtils.appendEscapedSQLString(whereClause,
    279                     "https://" + compareString);
    280             addOrUrlEquals(whereClause);
    281             DatabaseUtils.appendEscapedSQLString(whereClause,
    282                     "https://www." + compareString);
    283         } else {
    284             whereClause = new StringBuilder(Bookmarks.URL + " = ");
    285             DatabaseUtils.appendEscapedSQLString(whereClause,
    286                     compareString);
    287             addOrUrlEquals(whereClause);
    288             String wwwString = "www." + compareString;
    289             DatabaseUtils.appendEscapedSQLString(whereClause,
    290                     wwwString);
    291             addOrUrlEquals(whereClause);
    292             DatabaseUtils.appendEscapedSQLString(whereClause,
    293                     "http://" + compareString);
    294             addOrUrlEquals(whereClause);
    295             DatabaseUtils.appendEscapedSQLString(whereClause,
    296                     "http://" + wwwString);
    297         }
    298         return cr.query(History.CONTENT_URI, new String[] { History._ID, History.VISITS },
    299                 whereClause.toString(), null, null);
    300     }
    301 
    302     /**
    303      *  Update the visited history to acknowledge that a site has been
    304      *  visited.
    305      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    306      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    307      *  @param cr   The ContentResolver used to access the database.
    308      *  @param url  The site being visited.
    309      *  @param real If true, this is an actual visit, and should add to the
    310      *              number of visits.  If false, the user entered it manually.
    311      */
    312     public static final void updateVisitedHistory(ContentResolver cr,
    313                                                   String url, boolean real) {
    314         long now = System.currentTimeMillis();
    315         Cursor c = null;
    316         try {
    317             c = getVisitedLike(cr, url);
    318             /* We should only get one answer that is exactly the same. */
    319             if (c.moveToFirst()) {
    320                 ContentValues values = new ContentValues();
    321                 if (real) {
    322                     values.put(History.VISITS, c.getInt(1) + 1);
    323                 } else {
    324                     values.put(History.USER_ENTERED, 1);
    325                 }
    326                 values.put(History.DATE_LAST_VISITED, now);
    327                 cr.update(ContentUris.withAppendedId(History.CONTENT_URI, c.getLong(0)),
    328                         values, null, null);
    329             } else {
    330                 truncateHistory(cr);
    331                 ContentValues values = new ContentValues();
    332                 int visits;
    333                 int user_entered;
    334                 if (real) {
    335                     visits = 1;
    336                     user_entered = 0;
    337                 } else {
    338                     visits = 0;
    339                     user_entered = 1;
    340                 }
    341                 values.put(History.URL, url);
    342                 values.put(History.VISITS, visits);
    343                 values.put(History.DATE_LAST_VISITED, now);
    344                 values.put(History.TITLE, url);
    345                 values.put(History.DATE_CREATED, 0);
    346                 values.put(History.USER_ENTERED, user_entered);
    347                 cr.insert(History.CONTENT_URI, values);
    348             }
    349         } catch (IllegalStateException e) {
    350             Log.e(LOGTAG, "updateVisitedHistory", e);
    351         } finally {
    352             if (c != null) c.close();
    353         }
    354     }
    355 
    356     /**
    357      *  Returns all the URLs in the history.
    358      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    359      *  @param cr   The ContentResolver used to access the database.
    360      *  @hide pending API council approval
    361      */
    362     public static final String[] getVisitedHistory(ContentResolver cr) {
    363         Cursor c = null;
    364         String[] str = null;
    365         try {
    366             String[] projection = new String[] {
    367                     History.URL,
    368             };
    369             c = cr.query(History.CONTENT_URI, projection, History.VISITS + " > 0", null, null);
    370             if (c == null) return new String[0];
    371             str = new String[c.getCount()];
    372             int i = 0;
    373             while (c.moveToNext()) {
    374                 str[i] = c.getString(0);
    375                 i++;
    376             }
    377         } catch (IllegalStateException e) {
    378             Log.e(LOGTAG, "getVisitedHistory", e);
    379             str = new String[0];
    380         } finally {
    381             if (c != null) c.close();
    382         }
    383         return str;
    384     }
    385 
    386     /**
    387      * If there are more than MAX_HISTORY_COUNT non-bookmark history
    388      * items in the bookmark/history table, delete TRUNCATE_N_OLDEST
    389      * of them.  This is used to keep our history table to a
    390      * reasonable size.  Note: it does not prune bookmarks.  If the
    391      * user wants 1000 bookmarks, the user gets 1000 bookmarks.
    392      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    393      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    394      *
    395      * @param cr The ContentResolver used to access the database.
    396      */
    397     public static final void truncateHistory(ContentResolver cr) {
    398         // TODO make a single request to the provider to do this in a single transaction
    399         Cursor cursor = null;
    400         try {
    401 
    402             // Select non-bookmark history, ordered by date
    403             cursor = cr.query(History.CONTENT_URI,
    404                     new String[] { History._ID, History.URL, History.DATE_LAST_VISITED },
    405                     null, null, History.DATE_LAST_VISITED + " ASC");
    406 
    407             if (cursor.moveToFirst() && cursor.getCount() >= MAX_HISTORY_COUNT) {
    408                 /* eliminate oldest history items */
    409                 for (int i = 0; i < TRUNCATE_N_OLDEST; i++) {
    410                     cr.delete(ContentUris.withAppendedId(History.CONTENT_URI, cursor.getLong(0)),
    411                         null, null);
    412                     if (!cursor.moveToNext()) break;
    413                 }
    414             }
    415         } catch (IllegalStateException e) {
    416             Log.e(LOGTAG, "truncateHistory", e);
    417         } finally {
    418             if (cursor != null) cursor.close();
    419         }
    420     }
    421 
    422     /**
    423      * Returns whether there is any history to clear.
    424      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    425      * @param cr   The ContentResolver used to access the database.
    426      * @return boolean  True if the history can be cleared.
    427      */
    428     public static final boolean canClearHistory(ContentResolver cr) {
    429         Cursor cursor = null;
    430         boolean ret = false;
    431         try {
    432             cursor = cr.query(History.CONTENT_URI,
    433                 new String [] { History._ID, History.VISITS },
    434                 null, null, null);
    435             ret = cursor.getCount() > 0;
    436         } catch (IllegalStateException e) {
    437             Log.e(LOGTAG, "canClearHistory", e);
    438         } finally {
    439             if (cursor != null) cursor.close();
    440         }
    441         return ret;
    442     }
    443 
    444     /**
    445      *  Delete all entries from the bookmarks/history table which are
    446      *  not bookmarks.  Also set all visited bookmarks to unvisited.
    447      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    448      *  @param cr   The ContentResolver used to access the database.
    449      */
    450     public static final void clearHistory(ContentResolver cr) {
    451         deleteHistoryWhere(cr, null);
    452     }
    453 
    454     /**
    455      * Helper function to delete all history items and release the icons for them in the
    456      * {@link WebIconDatabase}.
    457      *
    458      * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    459      * Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    460      *
    461      * @param cr   The ContentResolver used to access the database.
    462      * @param whereClause   String to limit the items affected.
    463      *                      null means all items.
    464      */
    465     private static final void deleteHistoryWhere(ContentResolver cr, String whereClause) {
    466         Cursor cursor = null;
    467         try {
    468             cursor = cr.query(History.CONTENT_URI, new String[] { History.URL }, whereClause,
    469                     null, null);
    470             if (cursor.moveToFirst()) {
    471                 cr.delete(History.CONTENT_URI, whereClause, null);
    472             }
    473         } catch (IllegalStateException e) {
    474             Log.e(LOGTAG, "deleteHistoryWhere", e);
    475             return;
    476         } finally {
    477             if (cursor != null) cursor.close();
    478         }
    479     }
    480 
    481     /**
    482      * Delete all history items from begin to end.
    483      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    484      * @param cr    The ContentResolver used to access the database.
    485      * @param begin First date to remove.  If -1, all dates before end.
    486      *              Inclusive.
    487      * @param end   Last date to remove. If -1, all dates after begin.
    488      *              Non-inclusive.
    489      */
    490     public static final void deleteHistoryTimeFrame(ContentResolver cr,
    491             long begin, long end) {
    492         String whereClause;
    493         String date = BookmarkColumns.DATE;
    494         if (-1 == begin) {
    495             if (-1 == end) {
    496                 clearHistory(cr);
    497                 return;
    498             }
    499             whereClause = date + " < " + Long.toString(end);
    500         } else if (-1 == end) {
    501             whereClause = date + " >= " + Long.toString(begin);
    502         } else {
    503             whereClause = date + " >= " + Long.toString(begin) + " AND " + date
    504                     + " < " + Long.toString(end);
    505         }
    506         deleteHistoryWhere(cr, whereClause);
    507     }
    508 
    509     /**
    510      * Remove a specific url from the history database.
    511      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    512      * @param cr    The ContentResolver used to access the database.
    513      * @param url   url to remove.
    514      */
    515     public static final void deleteFromHistory(ContentResolver cr,
    516                                                String url) {
    517         cr.delete(History.CONTENT_URI, History.URL + "=?", new String[] { url });
    518     }
    519 
    520     /**
    521      * Add a search string to the searches database.
    522      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    523      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    524      * @param cr   The ContentResolver used to access the database.
    525      * @param search    The string to add to the searches database.
    526      */
    527     public static final void addSearchUrl(ContentResolver cr, String search) {
    528         // The content provider will take care of updating existing searches instead of duplicating
    529         ContentValues values = new ContentValues();
    530         values.put(Searches.SEARCH, search);
    531         values.put(Searches.DATE, System.currentTimeMillis());
    532         cr.insert(Searches.CONTENT_URI, values);
    533     }
    534 
    535     /**
    536      * Remove all searches from the search database.
    537      *  Requires {@link android.Manifest.permission#WRITE_HISTORY_BOOKMARKS}
    538      * @param cr   The ContentResolver used to access the database.
    539      */
    540     public static final void clearSearches(ContentResolver cr) {
    541         // FIXME: Should this clear the urls to which these searches lead?
    542         // (i.e. remove google.com/query= blah blah blah)
    543         try {
    544             cr.delete(Searches.CONTENT_URI, null, null);
    545         } catch (IllegalStateException e) {
    546             Log.e(LOGTAG, "clearSearches", e);
    547         }
    548     }
    549 
    550     /**
    551      *  Request all icons from the database.  This call must either be called
    552      *  in the main thread or have had Looper.prepare() invoked in the calling
    553      *  thread.
    554      *  Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS}
    555      *  @param  cr The ContentResolver used to access the database.
    556      *  @param  where Clause to be used to limit the query from the database.
    557      *          Must be an allowable string to be passed into a database query.
    558      *  @param  listener IconListener that gets the icons once they are
    559      *          retrieved.
    560      */
    561     public static final void requestAllIcons(ContentResolver cr, String where,
    562             WebIconDatabase.IconListener listener) {
    563         // Do nothing: this is no longer used.
    564     }
    565 
    566     /**
    567      * Column definitions for the mixed bookmark and history items available
    568      * at {@link #BOOKMARKS_URI}.
    569      */
    570     public static class BookmarkColumns implements BaseColumns {
    571         /**
    572          * The URL of the bookmark or history item.
    573          * <p>Type: TEXT (URL)</p>
    574          */
    575         public static final String URL = "url";
    576 
    577         /**
    578          * The number of time the item has been visited.
    579          * <p>Type: NUMBER</p>
    580          */
    581         public static final String VISITS = "visits";
    582 
    583         /**
    584          * The date the item was last visited, in milliseconds since the epoch.
    585          * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p>
    586          */
    587         public static final String DATE = "date";
    588 
    589         /**
    590          * Flag indicating that an item is a bookmark. A value of 1 indicates a bookmark, a value
    591          * of 0 indicates a history item.
    592          * <p>Type: INTEGER (boolean)</p>
    593          */
    594         public static final String BOOKMARK = "bookmark";
    595 
    596         /**
    597          * The user visible title of the bookmark or history item.
    598          * <p>Type: TEXT</p>
    599          */
    600         public static final String TITLE = "title";
    601 
    602         /**
    603          * The date the item created, in milliseconds since the epoch.
    604          * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p>
    605          */
    606         public static final String CREATED = "created";
    607 
    608         /**
    609          * The favicon of the bookmark. Must decode via {@link BitmapFactory#decodeByteArray}.
    610          * <p>Type: BLOB (image)</p>
    611          */
    612         public static final String FAVICON = "favicon";
    613 
    614         /**
    615          * @hide
    616          */
    617         public static final String THUMBNAIL = "thumbnail";
    618 
    619         /**
    620          * @hide
    621          */
    622         public static final String TOUCH_ICON = "touch_icon";
    623 
    624         /**
    625          * @hide
    626          */
    627         public static final String USER_ENTERED = "user_entered";
    628     }
    629 
    630     /**
    631      * Column definitions for the search history table, available at {@link #SEARCHES_URI}.
    632      */
    633     public static class SearchColumns implements BaseColumns {
    634         /**
    635          * @deprecated Not used.
    636          */
    637         @Deprecated
    638         public static final String URL = "url";
    639 
    640         /**
    641          * The user entered search term.
    642          */
    643         public static final String SEARCH = "search";
    644 
    645         /**
    646          * The date the search was performed, in milliseconds since the epoch.
    647          * <p>Type: NUMBER (date in milliseconds since January 1, 1970)</p>
    648          */
    649         public static final String DATE = "date";
    650     }
    651 }
    652