WebAPI/DeviceIndexedDB: Difference between revisions

Line 47: Line 47:
*** A chooser UI is showed between the request and returning the list.
*** A chooser UI is showed between the request and returning the list.
** With access control defined in the manifest, an app can request for predefined intents. (in the list of index keys)
** With access control defined in the manifest, an app can request for predefined intents. (in the list of index keys)
=== Application Chooser ===
Following is an example of finding Apps providing DataCloudStorage services with DeviceIndexedDB as the application chooser.
var request = window.deviceIndexedDB.open("[SystemService]");
request.onsuccess = function () {
  var db = request.result;
  var tx = db.transaction("Applications");
  var store = tx.objectStore("Applications");
  var chooserByIntent = store.index("chooserByIntent");
  var chooserrequest = chooserByIntent.get("DataCloudStorage");
  chooserrequest.onsuccess = function () {
    var app = chooserrequest.result;
    talkToDataCloudStorage(app.id);
  }
}
The "[SystemService]" database is not necessary a real persistent data storage, it is implemented by the platform (Gecko) to provide the service.  The line, chooserByIntent.get("DataCloudStorage"), would launch a application chooser by the platform.  It return a list of applications once the user finish his selection.
Confirmed users
398

edits