Fix a class cast exception.

If we are in grid mode, the target view will not be
a history item.  Find out the information using the
BookmarksAdapter instead.
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index caadfdd..f070546 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -134,15 +134,25 @@
             break;
         // Only for the Most visited page
         case R.id.save_to_bookmarks_menu_id:
-            HistoryItem historyItem = ((HistoryItem) i.targetView);
+            boolean isBookmark;
+            String name;
+            String url;
+            if (mGridMode) {
+                isBookmark = mBookmarksAdapter.getIsBookmark(i.position);
+                name = mBookmarksAdapter.getTitle(i.position);
+                url = mBookmarksAdapter.getUrl(i.position);
+            } else {
+                HistoryItem historyItem = ((HistoryItem) i.targetView);
+                isBookmark = historyItem.isBookmark();
+                name = historyItem.getName();
+                url = historyItem.getUrl();
+            }
             // If the site is bookmarked, the item becomes remove from
             // bookmarks.
-            if (historyItem.isBookmark()) {
-                Bookmarks.removeFromBookmarks(this, getContentResolver(),
-                            historyItem.getUrl());
+            if (isBookmark) {
+                Bookmarks.removeFromBookmarks(this, getContentResolver(), url);
             } else {
-                Browser.saveBookmark(this, historyItem.getName(),
-                        historyItem.getUrl());
+                Browser.saveBookmark(this, name, url);
             }
             break;
         default: