Merge "Import revised translations."
diff --git a/res/raw/favicon_amazon.ico b/res/raw/favicon_amazon.ico
new file mode 100644
index 0000000..20a959c
--- /dev/null
+++ b/res/raw/favicon_amazon.ico
Binary files differ
diff --git a/res/raw/favicon_bbc.ico b/res/raw/favicon_bbc.ico
new file mode 100644
index 0000000..8f62b07
--- /dev/null
+++ b/res/raw/favicon_bbc.ico
Binary files differ
diff --git a/res/raw/favicon_cnn.ico b/res/raw/favicon_cnn.ico
new file mode 100644
index 0000000..4a8421d
--- /dev/null
+++ b/res/raw/favicon_cnn.ico
Binary files differ
diff --git a/res/raw/favicon_ebay.ico b/res/raw/favicon_ebay.ico
new file mode 100644
index 0000000..d7c8a5e
--- /dev/null
+++ b/res/raw/favicon_ebay.ico
Binary files differ
diff --git a/res/raw/favicon_espn.ico b/res/raw/favicon_espn.ico
new file mode 100644
index 0000000..2dbe28a
--- /dev/null
+++ b/res/raw/favicon_espn.ico
Binary files differ
diff --git a/res/raw/favicon_facebook.ico b/res/raw/favicon_facebook.ico
new file mode 100644
index 0000000..ea0c6a3
--- /dev/null
+++ b/res/raw/favicon_facebook.ico
Binary files differ
diff --git a/res/raw/favicon_google.ico b/res/raw/favicon_google.ico
new file mode 100644
index 0000000..ee7c943
--- /dev/null
+++ b/res/raw/favicon_google.ico
Binary files differ
diff --git a/res/raw/favicon_msn.ico b/res/raw/favicon_msn.ico
new file mode 100644
index 0000000..b2279f5
--- /dev/null
+++ b/res/raw/favicon_msn.ico
Binary files differ
diff --git a/res/raw/favicon_myspace.ico b/res/raw/favicon_myspace.ico
new file mode 100644
index 0000000..22c46be
--- /dev/null
+++ b/res/raw/favicon_myspace.ico
Binary files differ
diff --git a/res/raw/favicon_nytimes.ico b/res/raw/favicon_nytimes.ico
new file mode 100644
index 0000000..fb4d000
--- /dev/null
+++ b/res/raw/favicon_nytimes.ico
Binary files differ
diff --git a/res/raw/favicon_picasa.ico b/res/raw/favicon_picasa.ico
new file mode 100644
index 0000000..22133b8
--- /dev/null
+++ b/res/raw/favicon_picasa.ico
Binary files differ
diff --git a/res/raw/favicon_weatherchannel.ico b/res/raw/favicon_weatherchannel.ico
new file mode 100644
index 0000000..5a56818
--- /dev/null
+++ b/res/raw/favicon_weatherchannel.ico
Binary files differ
diff --git a/res/raw/favicon_wikipedia.ico b/res/raw/favicon_wikipedia.ico
new file mode 100644
index 0000000..31b0e38
--- /dev/null
+++ b/res/raw/favicon_wikipedia.ico
Binary files differ
diff --git a/res/raw/favicon_yahoo.ico b/res/raw/favicon_yahoo.ico
new file mode 100644
index 0000000..d7761e5
--- /dev/null
+++ b/res/raw/favicon_yahoo.ico
Binary files differ
diff --git a/res/raw/thumb_amazon.png b/res/raw/thumb_amazon.png
new file mode 100644
index 0000000..eec1d77
--- /dev/null
+++ b/res/raw/thumb_amazon.png
Binary files differ
diff --git a/res/raw/thumb_bbc.png b/res/raw/thumb_bbc.png
new file mode 100644
index 0000000..9cdd902
--- /dev/null
+++ b/res/raw/thumb_bbc.png
Binary files differ
diff --git a/res/raw/thumb_cnn.png b/res/raw/thumb_cnn.png
new file mode 100644
index 0000000..70b7ea2
--- /dev/null
+++ b/res/raw/thumb_cnn.png
Binary files differ
diff --git a/res/raw/thumb_ebay.png b/res/raw/thumb_ebay.png
new file mode 100644
index 0000000..070fa6c
--- /dev/null
+++ b/res/raw/thumb_ebay.png
Binary files differ
diff --git a/res/raw/thumb_espn.png b/res/raw/thumb_espn.png
new file mode 100644
index 0000000..94918e2
--- /dev/null
+++ b/res/raw/thumb_espn.png
Binary files differ
diff --git a/res/raw/thumb_facebook.png b/res/raw/thumb_facebook.png
new file mode 100644
index 0000000..6e295b1
--- /dev/null
+++ b/res/raw/thumb_facebook.png
Binary files differ
diff --git a/res/raw/thumb_google.png b/res/raw/thumb_google.png
new file mode 100644
index 0000000..1753788
--- /dev/null
+++ b/res/raw/thumb_google.png
Binary files differ
diff --git a/res/raw/thumb_msn.png b/res/raw/thumb_msn.png
new file mode 100644
index 0000000..2240e12
--- /dev/null
+++ b/res/raw/thumb_msn.png
Binary files differ
diff --git a/res/raw/thumb_myspace.png b/res/raw/thumb_myspace.png
new file mode 100644
index 0000000..3f39ac5
--- /dev/null
+++ b/res/raw/thumb_myspace.png
Binary files differ
diff --git a/res/raw/thumb_nytimes.png b/res/raw/thumb_nytimes.png
new file mode 100644
index 0000000..d6849c3
--- /dev/null
+++ b/res/raw/thumb_nytimes.png
Binary files differ
diff --git a/res/raw/thumb_picasa.png b/res/raw/thumb_picasa.png
new file mode 100644
index 0000000..dca6a7d
--- /dev/null
+++ b/res/raw/thumb_picasa.png
Binary files differ
diff --git a/res/raw/thumb_weatherchannel.png b/res/raw/thumb_weatherchannel.png
new file mode 100644
index 0000000..c91e54c
--- /dev/null
+++ b/res/raw/thumb_weatherchannel.png
Binary files differ
diff --git a/res/raw/thumb_wikipedia.png b/res/raw/thumb_wikipedia.png
new file mode 100644
index 0000000..7929468
--- /dev/null
+++ b/res/raw/thumb_wikipedia.png
Binary files differ
diff --git a/res/raw/thumb_yahoo.png b/res/raw/thumb_yahoo.png
new file mode 100644
index 0000000..115d8bb
--- /dev/null
+++ b/res/raw/thumb_yahoo.png
Binary files differ
diff --git a/res/values/bookmarks_icons.xml b/res/values/bookmarks_icons.xml
new file mode 100644
index 0000000..3f1b5d6
--- /dev/null
+++ b/res/values/bookmarks_icons.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <array name="bookmark_preloads">
+        <item>@raw/favicon_google</item>
+        <item>@raw/thumb_google</item>
+        <item>@raw/favicon_picasa</item>
+        <item>@raw/thumb_picasa</item>
+        <item>@raw/favicon_yahoo</item>
+        <item>@raw/thumb_yahoo</item>
+        <item>@raw/favicon_msn</item>
+        <item>@raw/thumb_msn</item>
+        <item>@raw/favicon_myspace</item>
+        <item>@raw/thumb_myspace</item>
+        <item>@raw/favicon_facebook</item>
+        <item>@raw/thumb_facebook</item>
+        <item>@raw/favicon_wikipedia</item>
+        <item>@raw/thumb_wikipedia</item>
+        <item>@raw/favicon_ebay</item>
+        <item>@raw/thumb_ebay</item>
+        <item>@raw/favicon_cnn</item>
+        <item>@raw/thumb_cnn</item>
+        <item>@raw/favicon_nytimes</item>
+        <item>@raw/thumb_nytimes</item>
+        <item>@raw/favicon_espn</item>
+        <item>@raw/thumb_espn</item>
+        <item>@raw/favicon_amazon</item>
+        <item>@raw/thumb_amazon</item>
+        <item>@raw/favicon_weatherchannel</item>
+        <item>@raw/thumb_weatherchannel</item>
+        <item>@raw/favicon_bbc</item>
+        <item>@raw/thumb_bbc</item>
+    </array>
+</resources>
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 03f0557..5b87d0f 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -25,6 +25,8 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.UriMatcher;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
 import android.database.Cursor;
 import android.database.DatabaseUtils;
 import android.database.sqlite.SQLiteDatabase;
@@ -45,6 +47,9 @@
 import android.provider.SyncStateContract;
 import android.text.TextUtils;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashMap;
 
 public class BrowserProvider2 extends SQLiteContentProvider {
@@ -275,8 +280,6 @@
 
             // TODO indices
 
-            createDefaultBookmarks(db);
-
             db.execSQL("CREATE TABLE " + TABLE_HISTORY + "(" +
                     History._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
                     History.TITLE + " TEXT," +
@@ -339,6 +342,8 @@
                 "FROM bookmarks LEFT OUTER JOIN images ON bookmarks.url = images.url_key WHERE url NOT IN (SELECT url FROM history)");
 
             mSyncHelper.createDatabase(db);
+
+            createDefaultBookmarks(db);
         }
 
         @Override
@@ -377,9 +382,11 @@
         }
 
         private void addDefaultBookmarks(SQLiteDatabase db, long parentId) {
-            final CharSequence[] bookmarks = getContext().getResources().getTextArray(
+            Resources res = getContext().getResources();
+            final CharSequence[] bookmarks = res.getTextArray(
                     R.array.bookmarks);
             int size = bookmarks.length;
+            TypedArray preloads = res.obtainTypedArray(R.array.bookmark_preloads);
             try {
                 String parent = Long.toString(parentId);
                 String now = Long.toString(System.currentTimeMillis());
@@ -401,11 +408,50 @@
                             Integer.toString(i) + "," +
                             now +
                             ");");
+
+                    int faviconId = preloads.getResourceId(i, 0);
+                    int thumbId = preloads.getResourceId(i + 1, 0);
+                    byte[] thumb = null, favicon = null;
+                    try {
+                        thumb = readRaw(res, thumbId);
+                    } catch (IOException e) {
+                    }
+                    try {
+                        favicon = readRaw(res, faviconId);
+                    } catch (IOException e) {
+                    }
+                    if (thumb != null || favicon != null) {
+                        ContentValues imageValues = new ContentValues();
+                        imageValues.put(Images.URL, bookmarkDestination.toString());
+                        if (favicon != null) {
+                            imageValues.put(Images.FAVICON, favicon);
+                        }
+                        if (thumb != null) {
+                            imageValues.put(Images.THUMBNAIL, thumb);
+                        }
+                        db.insert(TABLE_IMAGES, Images.FAVICON, imageValues);
+                    }
                 }
             } catch (ArrayIndexOutOfBoundsException e) {
             }
         }
 
+        private byte[] readRaw(Resources res, int id) throws IOException {
+            InputStream is = res.openRawResource(id);
+            try {
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                byte[] buf = new byte[4096];
+                int read;
+                while ((read = is.read(buf)) > 0) {
+                    bos.write(buf, 0, read);
+                }
+                bos.flush();
+                return bos.toByteArray();
+            } finally {
+                is.close();
+            }
+        }
+
         // XXX: This is a major hack to remove our dependency on gsf constants and
         // its content provider. http://b/issue?id=2425179
         private String getClientId(ContentResolver cr) {
@@ -844,7 +890,7 @@
                 insertSettingsInTransaction(db, values);
                 break;
             }
-            
+
             default: {
                 throw new UnsupportedOperationException("Unknown insert URI " + uri);
             }