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