mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 722184 - Add bookmark keywords support to databases. r=mfinkle f=wesj
This commit is contained in:
parent
4b271d2d17
commit
fb49b48bc4
@ -244,6 +244,10 @@ public class AndroidBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
return (count == 1);
|
||||
}
|
||||
|
||||
public String getUrlForKeyword(ContentResolver cr, String keyword) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addBookmarkPre11(ContentResolver cr, String title, String uri) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Browser.BookmarkColumns.BOOKMARK, "1");
|
||||
@ -281,6 +285,35 @@ public class AndroidBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
addBookmarkPre11(cr, title, uri);
|
||||
}
|
||||
|
||||
public void updateBookmarkPre11(ContentResolver cr, String oldUri, String uri, String title) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Browser.BookmarkColumns.TITLE, title);
|
||||
values.put(Browser.BookmarkColumns.URL, uri);
|
||||
|
||||
cr.update(Browser.BOOKMARKS_URI,
|
||||
values,
|
||||
Browser.BookmarkColumns.URL + " = ?",
|
||||
new String[] { oldUri });
|
||||
}
|
||||
|
||||
public void updateBookmarkPost11(ContentResolver cr, String oldUri, String uri, String title) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Browser.BookmarkColumns.TITLE, title);
|
||||
values.put(Browser.BookmarkColumns.URL, uri);
|
||||
|
||||
cr.update(BOOKMARKS_CONTENT_URI_POST_11,
|
||||
values,
|
||||
Browser.BookmarkColumns.URL + " = ?",
|
||||
new String[] { oldUri });
|
||||
}
|
||||
|
||||
public void updateBookmark(ContentResolver cr, String oldUri, String uri, String title, String keyword) {
|
||||
if (Build.VERSION.SDK_INT >= 11)
|
||||
updateBookmarkPost11(cr, oldUri, uri, title);
|
||||
else
|
||||
updateBookmarkPre11(cr, oldUri, uri, title);
|
||||
}
|
||||
|
||||
public void removeBookmarkPre11(ContentResolver cr, String uri) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Browser.BookmarkColumns.BOOKMARK, "0");
|
||||
|
@ -51,6 +51,7 @@ public class BrowserDB {
|
||||
public static String THUMBNAIL = "thumbnail";
|
||||
public static String DATE_LAST_VISITED = "date-last-visited";
|
||||
public static String VISITS = "visits";
|
||||
public static String KEYWORD = "keyword";
|
||||
}
|
||||
|
||||
private static BrowserDBIface sDb;
|
||||
@ -83,10 +84,14 @@ public class BrowserDB {
|
||||
|
||||
public boolean isBookmark(ContentResolver cr, String uri);
|
||||
|
||||
public String getUrlForKeyword(ContentResolver cr, String keyword);
|
||||
|
||||
public void addBookmark(ContentResolver cr, String title, String uri);
|
||||
|
||||
public void removeBookmark(ContentResolver cr, String uri);
|
||||
|
||||
public void updateBookmark(ContentResolver cr, String oldUri, String uri, String title, String keyword);
|
||||
|
||||
public BitmapDrawable getFaviconForUrl(ContentResolver cr, String uri);
|
||||
|
||||
public void updateFaviconForUrl(ContentResolver cr, String uri, BitmapDrawable favicon);
|
||||
@ -150,6 +155,10 @@ public class BrowserDB {
|
||||
return sDb.getDesktopBookmarks(cr);
|
||||
}
|
||||
|
||||
public static String getUrlForKeyword(ContentResolver cr, String keyword) {
|
||||
return sDb.getUrlForKeyword(cr, keyword);
|
||||
}
|
||||
|
||||
public static boolean isBookmark(ContentResolver cr, String uri) {
|
||||
return sDb.isBookmark(cr, uri);
|
||||
}
|
||||
@ -162,6 +171,10 @@ public class BrowserDB {
|
||||
sDb.removeBookmark(cr, uri);
|
||||
}
|
||||
|
||||
public static void updateBookmark(ContentResolver cr, String oldUri, String uri, String title, String keyword) {
|
||||
sDb.updateBookmark(cr, oldUri, uri, title, keyword);
|
||||
}
|
||||
|
||||
public static BitmapDrawable getFaviconForUrl(ContentResolver cr, String uri) {
|
||||
return sDb.getFaviconForUrl(cr, uri);
|
||||
}
|
||||
|
@ -271,7 +271,8 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
new String[] { Bookmarks._ID,
|
||||
Bookmarks.URL,
|
||||
Bookmarks.TITLE,
|
||||
Bookmarks.FAVICON },
|
||||
Bookmarks.FAVICON,
|
||||
Bookmarks.KEYWORD },
|
||||
Bookmarks.IS_FOLDER + " = 0",
|
||||
null,
|
||||
Bookmarks.TITLE + " ASC");
|
||||
@ -316,6 +317,24 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
return (count == 1);
|
||||
}
|
||||
|
||||
public String getUrlForKeyword(ContentResolver cr, String keyword) {
|
||||
Cursor cursor = cr.query(appendProfile(Bookmarks.CONTENT_URI),
|
||||
new String[] { Bookmarks.URL },
|
||||
Bookmarks.KEYWORD + " = ?",
|
||||
new String[] { keyword },
|
||||
null);
|
||||
|
||||
if (!cursor.moveToFirst()) {
|
||||
cursor.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
String url = cursor.getString(cursor.getColumnIndexOrThrow(Bookmarks.URL));
|
||||
cursor.close();
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
private long getMobileBookmarksFolderId(ContentResolver cr) {
|
||||
if (mMobileFolderId >= 0)
|
||||
return mMobileFolderId;
|
||||
@ -367,6 +386,18 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
new String[] { uri });
|
||||
}
|
||||
|
||||
public void updateBookmark(ContentResolver cr, String oldUri, String uri, String title, String keyword) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Browser.BookmarkColumns.TITLE, title);
|
||||
values.put(Bookmarks.URL, uri);
|
||||
values.put(Bookmarks.KEYWORD, keyword);
|
||||
|
||||
int updated = cr.update(appendProfile(Bookmarks.CONTENT_URI),
|
||||
values,
|
||||
Bookmarks.URL + " = ?",
|
||||
new String[] { oldUri });
|
||||
}
|
||||
|
||||
public BitmapDrawable getFaviconForUrl(ContentResolver cr, String uri) {
|
||||
Cursor c = cr.query(appendProfile(Images.CONTENT_URI),
|
||||
new String[] { Images.FAVICON },
|
||||
|
Loading…
Reference in New Issue
Block a user