New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add and expose a getBookmarkURLForKeyword
API.
#1345
Conversation
@@ -889,6 +889,10 @@ impl<'de> Deserialize<'de> for BookmarkTreeNode { | |||
} | |||
} | |||
|
|||
pub fn bookmarks_get_url_for_keyword(db: &PlacesDb, keyword: &str) -> Result<Option<Url>> { | |||
Ok(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@linacambridge I'm assuming you just never got to this?
@tinoism If you're interested in finishing this up, this function will need to be completed. (also check with Lina first!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We chatted a bit on Slack! 😄 Thanks for taking this over, @tinoism!
getBookmarkURLForKeyword
API.
d2a4d92
to
04035f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great @tinoism, thanks so much for taking it over the finish line! 🏁 I wouldn't mind seeing your patch again with rustCallForOptString
, but feel free to file a follow-up if you prefer!
components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
Outdated
Show resolved
Hide resolved
.expect("should work"); | ||
let place_id = conn.last_insert_rowid(); | ||
|
||
// create a bookmark with keyword 'donut' pointing at it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍩
components/places/android/src/main/java/mozilla/appservices/places/Bookmarks.kt
Outdated
Show resolved
Hide resolved
Rust Places doesn't support setting keywords for URLs, and it's unclear if we'll ever port keywords as they exist on Desktop today. However, we do sync and round-trip keywords set on Desktop, so we can read them directly from the `moz_bookmarks_synced` table. Closes mozilla#953.
components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
Outdated
Show resolved
Hide resolved
Thanks @tinoism! 🎊 |
Before this patch, we stored keywords for incoming bookmarks in the `moz_bookmarks_synced` table, and read them back out from that table when we uploaded outgoing records. This was done for a few reasons: * In the beginning, Rust Places didn't support search keywords at all. There are plans to unify keywords and custom search engines, since they solve the same problem, but it's not currently a priority. https://bugzilla.mozilla.org/show_bug.cgi?id=648398 has more context. * However, keyword searches were a very popular feature in Firefox for iOS, so we added an API to read them out of `moz_bookmarks_synced` in #1345. * This was still fine, since the only way to get keywords into Fenix and iOS was via Sync. (Though there were some gotchas; for instance, disconnecting Sync would lose all keywords). * But the Fennec to Fenix migration meant that there are now two ways to get keywords into Fenix, since Fennec supported setting them on bookmarks. To make things more interesting, keywords are handled differently across our products. Desktop exposes keywords as bookmark properties, but, internally, associates them with (URL, POST data) tuples. (This is also why they're closer to custom search engines than bookmarks). But Sync, Fennec, and the old (before a-s) Firefox for iOS associated them with individual bookmarks. This patch takes a middle ground. Keywords are associated with URLs, like Desktop, and we store those associations in a separate `moz_keywords` table. This means keywords imported from Fennec should be migrated, and signing out of Sync in Firefox for iOS no longer loses keywords. Like Fennec and iOS, we don't support POST data, since we don't sync it, and there's no UI for setting it. The keyword syncing code is the same as Desktop's: we remove all synced keywords from all local URLs, and all local keywords from old and new synced URLs, then apply incoming items with new keywords and URLs. We also flag items with the same keyword and different URLs, as well as items with different keywords and the same URL, for reupload, to enforce the "1 keyword per URL" association.
Before this patch, we stored keywords for incoming bookmarks in the `moz_bookmarks_synced` table, and read them back out from that table when we uploaded outgoing records. This was done for a few reasons: * In the beginning, Rust Places didn't support search keywords at all. There are plans to unify keywords and custom search engines, since they solve the same problem, but it's not currently a priority. https://bugzilla.mozilla.org/show_bug.cgi?id=648398 has more context. * However, keyword searches were a very popular feature in Firefox for iOS, so we added an API to read them out of `moz_bookmarks_synced` in #1345. * This was still fine, since the only way to get keywords into Fenix and iOS was via Sync. (Though there were some gotchas; for instance, disconnecting Sync would lose all keywords). * But the Fennec to Fenix migration meant that there are now two ways to get keywords into Fenix, since Fennec supported setting them on bookmarks. To make things more interesting, keywords are handled differently across our products. Desktop exposes keywords as bookmark properties, but, internally, associates them with (URL, POST data) tuples. (This is also why they're closer to custom search engines than bookmarks). But Sync, Fennec, and the old (before a-s) Firefox for iOS associated them with individual bookmarks. This patch takes a middle ground. Keywords are associated with URLs, like Desktop, and we store those associations in a separate `moz_keywords` table. This means keywords imported from Fennec should be migrated, and signing out of Sync in Firefox for iOS no longer loses keywords. Like Fennec and iOS, we don't support POST data, since we don't sync it, and there's no UI for setting it. The keyword syncing code is the same as Desktop's: we remove all synced keywords from all local URLs, and all local keywords from old and new synced URLs, then apply incoming items with new keywords and URLs. We also flag items with the same keyword and different URLs, as well as items with different keywords and the same URL, for reupload, to enforce the "1 keyword per URL" association. Finally, we prepopulate the `moz_keywords` table with existing synced keywords, so that they can be accessed via `bookmarks_get_url_for_keyword` without triggering a full sync.
Before this patch, we stored keywords for incoming bookmarks in the `moz_bookmarks_synced` table, and read them back out from that table when we uploaded outgoing records. This was done for a few reasons: * In the beginning, Rust Places didn't support search keywords at all. There are plans to unify keywords and custom search engines, since they solve the same problem, but it's not currently a priority. https://bugzilla.mozilla.org/show_bug.cgi?id=648398 has more context. * However, keyword searches were a very popular feature in Firefox for iOS, so we added an API to read them out of `moz_bookmarks_synced` in #1345. * This was still fine, since the only way to get keywords into Fenix and iOS was via Sync. (Though there were some gotchas; for instance, disconnecting Sync would lose all keywords). * But the Fennec to Fenix migration meant that there are now two ways to get keywords into Fenix, since Fennec supported setting them on bookmarks. To make things more interesting, keywords are handled differently across our products. Desktop exposes keywords as bookmark properties, but, internally, associates them with (URL, POST data) tuples. (This is also why they're closer to custom search engines than bookmarks). But Sync, Fennec, and the old (before a-s) Firefox for iOS associated them with individual bookmarks. This patch takes a middle ground. Keywords are associated with URLs, like Desktop, and we store those associations in a separate `moz_keywords` table. This means keywords imported from Fennec should be migrated, and signing out of Sync in Firefox for iOS no longer loses keywords. Like Fennec and iOS, we don't support POST data, since we don't sync it, and there's no UI for setting it. The keyword syncing code is the same as Desktop's: we remove all synced keywords from all local URLs, and all local keywords from old and new synced URLs, then apply incoming items with new keywords and URLs. We also flag items with the same keyword and different URLs, as well as items with different keywords and the same URL, for reupload, to enforce the "1 keyword per URL" association. Finally, we prepopulate the `moz_keywords` table with existing synced keywords, so that they can be accessed via `bookmarks_get_url_for_keyword` without triggering a full sync.
Before this patch, we stored keywords for incoming bookmarks in the `moz_bookmarks_synced` table, and read them back out from that table when we uploaded outgoing records. This was done for a few reasons: * In the beginning, Rust Places didn't support search keywords at all. There are plans to unify keywords and custom search engines, since they solve the same problem, but it's not currently a priority. https://bugzilla.mozilla.org/show_bug.cgi?id=648398 has more context. * However, keyword searches were a very popular feature in Firefox for iOS, so we added an API to read them out of `moz_bookmarks_synced` in #1345. * This was still fine, since the only way to get keywords into Fenix and iOS was via Sync. (Though there were some gotchas; for instance, disconnecting Sync would lose all keywords). * But the Fennec to Fenix migration meant that there are now two ways to get keywords into Fenix, since Fennec supported setting them on bookmarks. To make things more interesting, keywords are handled differently across our products. Desktop exposes keywords as bookmark properties, but, internally, associates them with (URL, POST data) tuples. (This is also why they're closer to custom search engines than bookmarks). But Sync, Fennec, and the old (before a-s) Firefox for iOS associated them with individual bookmarks. This patch takes a middle ground. Keywords are associated with URLs, like Desktop, and we store those associations in a separate `moz_keywords` table. This means keywords imported from Fennec should be migrated, and signing out of Sync in Firefox for iOS no longer loses keywords. Like Fennec and iOS, we don't support POST data, since we don't sync it, and there's no UI for setting it. The keyword syncing code is the same as Desktop's: we remove all synced keywords from all local URLs, and all local keywords from old and new synced URLs, then apply incoming items with new keywords and URLs. We also flag items with the same keyword and different URLs, as well as items with different keywords and the same URL, for reupload, to enforce the "1 keyword per URL" association. Finally, we prepopulate the `moz_keywords` table with existing synced keywords, so that they can be accessed via `bookmarks_get_url_for_keyword` without triggering a full sync.
Closes #953.