Open Bug 1291274 Opened 8 years ago Updated 9 months ago

Consider adding bookmarks API method to get ID of standard/common folders

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(Not tracked)

People

(Reporter: sheppy, Unassigned, Mentored)

Details

(Whiteboard: [bookmarks]triaged)

There are certain folders which are fairly common among browsers which would be helpful to be able to quickly get access to. This could be done with properties, such as: bookmarks.unfiledFolder or bookmarks.toolbarFolder, or using a method, like bookmarks.getToolbarFolder() or bookmarks.getStandardFolder(foldername) where foldername is a special identifier like "toolbar", "unfiled", or "recents".

If the identifiers of common folders are standardized in some way, this would allow extensions to find these special folders easily regardless of which browser they're on.

For example, I could then bookmark MDN into the bookmarks toolbar like this:

chrome.bookmarks.create({
  parentId: chrome.bookmarks.getToolbarFolder(),
  title: "MDN",
  "https://developer.mozilla.org/"
});

This provides for cleaner, simpler code in the extension than having to query for the folder, especially since you don't necessarily know its name. This code would "just work" (assuming we can convince others to go along with the addition of a feature like this).
Whiteboard: [bookmarks][design decision needed]
Assignee: nobody → kmaglione+bmo
FWIW, as someone who documents a lot of APIs, I feel like the most consistent solution would be a bookmarks.getStandardFolder() method which would then take a simple string ID to determine which folder to retrieve: "root", "toolbar", "menu", "unfiled", "remote", "local", and so forth. This would be the most flexible, probably, too, since it would be relatively quick to add more, and would discourage every browser outfit from adding new methods for all their unusual or special bookmark folders; they could just add them to the ones supported by getStandardFolder().
I was planning to just add constants.
Whiteboard: [bookmarks][design decision needed] → [bookmarks]triaged
This API discussed in this bug is, sadly, absent from Blink.  In my Chrome and Opera extensions, I get these folders from their position in the root tree, which I have reverse-engineered.

A proper API, such as proposed here, would be wonderful.
Severity: normal → enhancement
Priority: -- → P5
Product: Toolkit → WebExtensions
Bulk move of bugs per https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
Component: Untriaged → General
Assignee: kmaglione+bmo → nobody
Mentor: kmaglione+bmo
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.