// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.readingList</code> API to read from and modify
// the items in the
// <a href="https://support.google.com/chrome/answer/7343019">Reading List</a>.
namespace readingList{
dictionary ReadingListEntry {
// The url of the entry.
DOMString url;
// The title of the entry.
DOMString title;
// Will be <code>true</code> if the entry has been read.
boolean hasBeenRead;
// The last time the entry was updated.
// This value is in milliseconds since Jan 1, 1970.
double lastUpdateTime;
// The time the entry was created.
// Recorded in milliseconds since Jan 1, 1970.
double creationTime;
};
dictionary AddEntryOptions {
// The url of the entry.
DOMString url;
// The title of the entry.
DOMString title;
// Will be <code>true</code> if the entry has been read.
boolean hasBeenRead;
};
dictionary RemoveOptions {
// The url to remove.
DOMString url;
};
dictionary UpdateEntryOptions {
// The url that will be updated.
DOMString url;
// The new title. The existing tile remains if a value isn't provided.
DOMString? title;
// The updated read status. The existing status remains if a value
// isn't provided.
boolean? hasBeenRead;
};
dictionary QueryInfo {
// A url to search for.
DOMString? url;
// A title to search for.
DOMString? title;
// Indicates whether to search for read (<code>true</code>) or unread
// (<code>false</code>) items.
boolean? hasBeenRead;
};
callback AddEntryCallback = void ();
callback RemoveEntryCallback = void();
callback UpdateEntryCallback = void();
callback QueryCallback = void(ReadingListEntry[] entries);
interface Functions {
// Adds an entry to the reading list if it does not exist.
// |entry|: The entry to add to the reading list.
// |callback|: Invoked once the entry has been added.
static void addEntry(
AddEntryOptions entry,
optional AddEntryCallback callback);
// Removes an entry from the reading list if it exists.
// |info|: The entry to remove from the reading list.
// |callback|: Invoked once the entry has been removed.
static void removeEntry(
RemoveOptions info,
optional RemoveEntryCallback callback);
// Updates a reading list entry if it exists.
// |info|: The entry to update.
// |callback|: Invoked once the matched entries have been updated.
static void updateEntry(
UpdateEntryOptions info,
optional UpdateEntryCallback callback);
// Retrieves all entries that match the <code>QueryInfo</code> properties.
// Properties that are not provided will not be matched.
// |info|: The properties to search for.
// |callback|: Invoked once the entries have been matched.
static void query(
QueryInfo info,
QueryCallback callback);
};
interface Events {
// Triggered when a <code>ReadingListEntry</code> is added to the reading list.
// |entry|: The entry that was added.
static void onEntryAdded(ReadingListEntry entry);
// Triggered when a <code>ReadingListEntry</code> is removed from the reading list.
// |entry|: The entry that was removed.
static void onEntryRemoved(ReadingListEntry entry);
// Triggered when a <code>ReadingListEntry</code> is updated in the reading list.
// |entry|: The entry that was updated.
static void onEntryUpdated(ReadingListEntry entry);
};
};