Bug 708485 - Create "mobile" special bookmarks folder on DB creation (r=blassey, a=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 13 Dec 2011 19:47:40 +0000
changeset 84153 096f185e573dd7339ee445a04499d05bcadc3bbb
parent 84152 50b3a3a55715fd952f783b1ec811f7dfb5d7e1c2
child 84154 0e227df7b536a0d8c48404e1f70f9efcc9c839df
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, mfinkle
bugs708485
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 708485 - Create "mobile" special bookmarks folder on DB creation (r=blassey, a=mfinkle)
mobile/android/base/db/BrowserContract.java
mobile/android/base/db/BrowserProvider.java
--- a/mobile/android/base/db/BrowserContract.java
+++ b/mobile/android/base/db/BrowserContract.java
@@ -88,16 +88,23 @@ public class BrowserContract {
         public static final String URL = "url_key";
 
         public static final String FAVICON_URL = "favicon_url";
     }
 
     public static final class Bookmarks implements CommonColumns, URLColumns, ImageColumns, SyncColumns {
         private Bookmarks() {}
 
+        public static final String MOBILE_FOLDER_GUID = "mobile";
+        public static final String PLACES_FOLDER_GUID = "places";
+        public static final String MENU_FOLDER_GUID = "menu";
+        public static final String TAGS_FOLDER_GUID = "tags";
+        public static final String TOOLBAR_FOLDER_GUID = "toolbar";
+        public static final String UNFILED_FOLDER_GUID = "unfiled";
+
         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "bookmarks");
 
         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/bookmark";
 
         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/bookmark";
 
         public static final String IS_FOLDER = "folder";
 
@@ -128,9 +135,9 @@ public class BrowserContract {
 
     public static final class Schema {
         private Schema() {}
 
         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "schema");
 
         public static final String VERSION = "version";
     }
-}
+}
\ No newline at end of file
--- a/mobile/android/base/db/BrowserProvider.java
+++ b/mobile/android/base/db/BrowserProvider.java
@@ -336,19 +336,34 @@ public class BrowserProvider extends Con
                     ", " + Images.FAVICON + ", " + Images.THUMBNAIL + " FROM " +
                     TABLE_BOOKMARKS_JOIN_IMAGES);
 
             db.execSQL("CREATE VIEW IF NOT EXISTS " + VIEW_HISTORY_WITH_IMAGES + " AS " +
                     "SELECT " + qualifyColumn(TABLE_HISTORY, "*") +
                     ", " + Images.FAVICON + ", " + Images.THUMBNAIL + " FROM " +
                     TABLE_HISTORY_JOIN_IMAGES);
 
+            createMobileBookmarksFolder(db);
+
             // FIXME: Create default bookmarks here
         }
 
+        private void createMobileBookmarksFolder(SQLiteDatabase db) {
+            ContentValues values = new ContentValues();
+            values.put(Bookmarks.GUID, Bookmarks.MOBILE_FOLDER_GUID);
+            values.put(Bookmarks.IS_FOLDER, 1);
+            values.put(Bookmarks.POSITION, 0);
+
+            long now = System.currentTimeMillis();
+            values.put(Bookmarks.DATE_CREATED, now);
+            values.put(Bookmarks.DATE_MODIFIED, now);
+
+            db.insertOrThrow(TABLE_BOOKMARKS, Bookmarks.GUID, values);
+        }
+
         @Override
         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
             Log.d(LOGTAG, "Upgrading browser.db: " + db.getPath() + " from " +
                     oldVersion + " to " + newVersion);
 
             // Do nothing for now
         }