3030import android .util .Pair ;
3131
3232/**
33+ * <p>
34+ * The contract between the browser provider and applications. Contains the definition
35+ * for the supported URIS and columns.
36+ * </p>
37+ * <h3>Overview</h3>
38+ * <p>
39+ * BrowserContract defines an database of browser-related information which are bookmarks,
40+ * history, images and the mapping between the image and URL.
41+ * </p>
3342 * @hide
3443 */
3544public class BrowserContract {
@@ -45,19 +54,23 @@ public class BrowserContract {
4554 * the dirty flag is not automatically set and the "syncToNetwork" parameter
4655 * is set to false when calling
4756 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
57+ * @hide
4858 */
4959 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter" ;
5060
5161 /**
5262 * A parameter for use when querying any table that allows specifying a limit on the number
5363 * of rows returned.
64+ * @hide
5465 */
5566 public static final String PARAM_LIMIT = "limit" ;
5667
5768 /**
5869 * Generic columns for use by sync adapters. The specific functions of
5970 * these columns are private to the sync adapter. Other clients of the API
6071 * should not attempt to either read or write these columns.
72+ *
73+ * @hide
6174 */
6275 interface BaseSyncColumns {
6376 /** Generic column for use by sync adapters. */
@@ -74,6 +87,7 @@ interface BaseSyncColumns {
7487
7588 /**
7689 * Convenience definitions for use in implementing chrome bookmarks sync in the Bookmarks table.
90+ * @hide
7791 */
7892 public static final class ChromeSyncColumns {
7993 private ChromeSyncColumns () {}
@@ -93,6 +107,7 @@ private ChromeSyncColumns() {}
93107 /**
94108 * Columns that appear when each row of a table belongs to a specific
95109 * account, including sync information that an account may need.
110+ * @hide
96111 */
97112 interface SyncColumns extends BaseSyncColumns {
98113 /**
@@ -144,13 +159,14 @@ interface CommonColumns {
144159 public static final String _ID = "_id" ;
145160
146161 /**
147- * The URL of the bookmark.
162+ * This column is valid when the row is a URL. The history table's URL
163+ * can not be updated.
148164 * <P>Type: TEXT (URL)</P>
149165 */
150166 public static final String URL = "url" ;
151167
152168 /**
153- * The user visible title of the bookmark .
169+ * The user visible title.
154170 * <P>Type: TEXT</P>
155171 */
156172 public static final String TITLE = "title" ;
@@ -159,10 +175,14 @@ interface CommonColumns {
159175 * The time that this row was created on its originating client (msecs
160176 * since the epoch).
161177 * <P>Type: INTEGER</P>
178+ * @hide
162179 */
163180 public static final String DATE_CREATED = "created" ;
164181 }
165182
183+ /**
184+ * @hide
185+ */
166186 interface ImageColumns {
167187 /**
168188 * The favicon of the bookmark, may be NULL.
@@ -182,7 +202,6 @@ interface ImageColumns {
182202 * The touch icon for the web page, may be NULL.
183203 * Must decode via {@link BitmapFactory#decodeByteArray}.
184204 * <p>Type: BLOB (image)</p>
185- * @hide
186205 */
187206 public static final String TOUCH_ICON = "touch_icon" ;
188207 }
@@ -200,9 +219,26 @@ interface HistoryColumns {
200219 */
201220 public static final String VISITS = "visits" ;
202221
222+ /**
223+ * @hide
224+ */
203225 public static final String USER_ENTERED = "user_entered" ;
204226 }
205227
228+ interface ImageMappingColumns {
229+ /**
230+ * The ID of the image in Images. One image can map onto the multiple URLs.
231+ * <P>Type: INTEGER (long)</P>
232+ */
233+ public static final String IMAGE_ID = "image_id" ;
234+
235+ /**
236+ * The URL. The URL can map onto the different type of images.
237+ * <P>Type: TEXT (URL)</P>
238+ */
239+ public static final String URL = "url" ;
240+ }
241+
206242 /**
207243 * The bookmarks table, which holds the user's browser bookmarks.
208244 */
@@ -217,25 +253,72 @@ private Bookmarks() {}
217253 */
218254 public static final Uri CONTENT_URI = Uri .withAppendedPath (AUTHORITY_URI , "bookmarks" );
219255
256+ /**
257+ * Used in {@link Bookmarks#TYPE} column and indicats the row is a bookmark.
258+ */
259+ public static final int BOOKMARK_TYPE_BOOKMARK = 1 ;
260+
261+ /**
262+ * Used in {@link Bookmarks#TYPE} column and indicats the row is a folder.
263+ */
264+ public static final int BOOKMARK_TYPE_FOLDER = 2 ;
265+
266+ /**
267+ * Used in {@link Bookmarks#TYPE} column and indicats the row is the bookmark bar folder.
268+ */
269+ public static final int BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER = 3 ;
270+
271+ /**
272+ * Used in {@link Bookmarks#TYPE} column and indicats the row is other folder and
273+ */
274+ public static final int BOOKMARK_TYPE_OTHER_FOLDER = 4 ;
275+
276+ /**
277+ * Used in {@link Bookmarks#TYPE} column and indicats the row is other folder, .
278+ */
279+ public static final int BOOKMARK_TYPE_MOBILE_FOLDER = 5 ;
280+
281+ /**
282+ * The type of the item.
283+ * <P>Type: INTEGER</P>
284+ * <p>Allowed values are:</p>
285+ * <p>
286+ * <ul>
287+ * <li>{@link #BOOKMARK_TYPE_BOOKMARK}</li>
288+ * <li>{@link #BOOKMARK_TYPE_FOLDER}</li>
289+ * <li>{@link #BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER}</li>
290+ * <li>{@link #BOOKMARK_TYPE_OTHER_FOLDER}</li>
291+ * <li>{@link #BOOKMARK_TYPE_MOBILE_FOLDER}</li>
292+ * </ul>
293+ * </p>
294+ * <p> The TYPE_BOOKMARK_BAR_FOLDER, TYPE_OTHER_FOLDER and TYPE_MOBILE_FOLDER
295+ * can not be updated or deleted.</p>
296+ */
297+ public static final String TYPE = "type" ;
298+
220299 /**
221300 * The content:// style URI for the default folder
301+ * @hide
222302 */
223303 public static final Uri CONTENT_URI_DEFAULT_FOLDER =
224304 Uri .withAppendedPath (CONTENT_URI , "folder" );
225305
226306 /**
227307 * Query parameter used to specify an account name
308+ * @hide
228309 */
229310 public static final String PARAM_ACCOUNT_NAME = "acct_name" ;
230311
231312 /**
232313 * Query parameter used to specify an account type
314+ * @hide
233315 */
234316 public static final String PARAM_ACCOUNT_TYPE = "acct_type" ;
235317
236318 /**
237319 * Builds a URI that points to a specific folder.
238320 * @param folderId the ID of the folder to point to
321+ * @hide
239322 */
240323 public static final Uri buildFolderUri (long folderId ) {
241324 return ContentUris .withAppendedId (CONTENT_URI_DEFAULT_FOLDER , folderId );
@@ -255,13 +338,15 @@ public static final Uri buildFolderUri(long folderId) {
255338 * Query parameter to use if you want to see deleted bookmarks that are still
256339 * around on the device and haven't been synced yet.
257340 * @see #IS_DELETED
341+ * @hide
258342 */
259343 public static final String QUERY_PARAMETER_SHOW_DELETED = "show_deleted" ;
260344
261345 /**
262346 * Flag indicating if an item is a folder or bookmark. Non-zero values indicate
263347 * a folder and zero indicates a bookmark.
264348 * <P>Type: INTEGER (boolean)</P>
349+ * @hide
265350 */
266351 public static final String IS_FOLDER = "folder" ;
267352
@@ -274,20 +359,23 @@ public static final Uri buildFolderUri(long folderId) {
274359 /**
275360 * The source ID for an item's parent. Read-only.
276361 * @see #PARENT
362+ * @hide
277363 */
278364 public static final String PARENT_SOURCE_ID = "parent_source" ;
279365
280366 /**
281367 * The position of the bookmark in relation to it's siblings that share the same
282368 * {@link #PARENT}. May be negative.
283369 * <P>Type: INTEGER</P>
370+ * @hide
284371 */
285372 public static final String POSITION = "position" ;
286373
287374 /**
288375 * The item that the bookmark should be inserted after.
289376 * May be negative.
290377 * <P>Type: INTEGER</P>
378+ * @hide
291379 */
292380 public static final String INSERT_AFTER = "insert_after" ;
293381
@@ -296,6 +384,7 @@ public static final Uri buildFolderUri(long folderId) {
296384 * May be negative.
297385 * <P>Type: INTEGER</P>
298386 * @see #INSERT_AFTER
387+ * @hide
299388 */
300389 public static final String INSERT_AFTER_SOURCE_ID = "insert_after_source" ;
301390
@@ -305,12 +394,14 @@ public static final Uri buildFolderUri(long folderId) {
305394 * to the URI when performing your query.
306395 * <p>Type: INTEGER (non-zero if the item has been deleted, zero if it hasn't)
307396 * @see #QUERY_PARAMETER_SHOW_DELETED
397+ * @hide
308398 */
309399 public static final String IS_DELETED = "deleted" ;
310400 }
311401
312402 /**
313403 * Read-only table that lists all the accounts that are used to provide bookmarks.
404+ * @hide
314405 */
315406 public static final class Accounts {
316407 /**
@@ -410,6 +501,7 @@ private Searches() {}
410501 * A table provided for sync adapters to use for storing private sync state data.
411502 *
412503 * @see SyncStateContract
504+ * @hide
413505 */
414506 public static final class SyncState implements SyncStateContract .Columns {
415507 /**
@@ -459,8 +551,18 @@ public static ContentProviderOperation newSetOperation(Account account, byte[] d
459551 }
460552
461553 /**
462- * Stores images for URLs. Only support query() and update().
463- * @hide
554+ * <p>
555+ * Stores images for URLs.
556+ * </p>
557+ * <p>
558+ * The rows in this table can not be updated since there might have multiple URLs mapping onto
559+ * the same image. If you want to update a URL's image, you need to add the new image in this
560+ * table, then update the mapping onto the added image.
561+ * </p>
562+ * <p>
563+ * Every image should be at least associated with one URL, otherwise it will be removed after a
564+ * while.
565+ * </p>
464566 */
465567 public static final class Images implements ImageColumns {
466568 /**
@@ -473,16 +575,94 @@ private Images() {}
473575 */
474576 public static final Uri CONTENT_URI = Uri .withAppendedPath (AUTHORITY_URI , "images" );
475577
578+ /**
579+ * The MIME type of {@link #CONTENT_URI} providing a directory of images.
580+ */
581+ public static final String CONTENT_TYPE = "vnd.android.cursor.dir/images" ;
582+
583+ /**
584+ * The MIME type of a {@link #CONTENT_URI} of a single image.
585+ */
586+ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/images" ;
587+
588+ /**
589+ * Used in {@link Images#TYPE} column and indicats the row is a favicon.
590+ */
591+ public static final int IMAGE_TYPE_FAVICON = 1 ;
592+
593+ /**
594+ * Used in {@link Images#TYPE} column and indicats the row is a precomposed touch icon.
595+ */
596+ public static final int IMAGE_TYPE_PRECOMPOSED_TOUCH_ICON = 2 ;
597+
598+ /**
599+ * Used in {@link Images#TYPE} column and indicats the row is a touch icon.
600+ */
601+ public static final int IMAGE_TYPE_TOUCH_ICON = 4 ;
602+
603+ /**
604+ * The type of item in the table.
605+ * <P>Type: INTEGER</P>
606+ * <p>Allowed values are:</p>
607+ * <p>
608+ * <ul>
609+ * <li>{@link #IMAGE_TYPE_FAVICON}</li>
610+ * <li>{@link #IMAGE_TYPE_PRECOMPOSED_TOUCH_ICON}</li>
611+ * <li>{@link #IMAGE_TYPE_TOUCH_ICON}</li>
612+ * </ul>
613+ * </p>
614+ */
615+ public static final String TYPE = "type" ;
616+
617+ /**
618+ * The image data.
619+ * <p>Type: BLOB (image)</p>
620+ */
621+ public static final String DATA = "data" ;
622+
476623 /**
477624 * The URL the images came from.
478625 * <P>Type: TEXT (URL)</P>
626+ * @hide
479627 */
480628 public static final String URL = "url_key" ;
481629 }
482630
631+ /**
632+ * <p>
633+ * A table that stores the mappings between the image and the URL.
634+ * </p>
635+ * <p>
636+ * Deleting or Updating a mapping might also deletes the mapped image if there is no other URL
637+ * maps onto it.
638+ * </p>
639+ */
640+ public static final class ImageMappings implements ImageMappingColumns {
641+ /**
642+ * This utility class cannot be instantiated
643+ */
644+ private ImageMappings () {}
645+
646+ /**
647+ * The content:// style URI for this table
648+ */
649+ public static final Uri CONTENT_URI = Uri .withAppendedPath (AUTHORITY_URI , "image_mappings" );
650+
651+ /**
652+ * The MIME type of {@link #CONTENT_URI} providing a directory of image mappings.
653+ */
654+ public static final String CONTENT_TYPE = "vnd.android.cursor.dir/image_mappings" ;
655+
656+ /**
657+ * The MIME type of a {@link #CONTENT_URI} of a single image mapping.
658+ */
659+ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/image_mappings" ;
660+ }
661+
483662 /**
484663 * A combined view of bookmarks and history. All bookmarks in all folders are included and
485664 * no folders are included.
665+ * @hide
486666 */
487667 public static final class Combined implements CommonColumns , HistoryColumns , ImageColumns {
488668 /**
@@ -505,6 +685,7 @@ private Combined() {}
505685
506686 /**
507687 * A table that stores settings specific to the browser. Only support query and insert.
688+ * @hide
508689 */
509690 public static final class Settings {
510691 /**
0 commit comments