// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module reading_list.mojom;
import "ui/base/mojom/window_open_disposition.mojom";
import "url/mojom/url.mojom";
// Read later entries grouped by read/unread status.
struct ReadLaterEntriesByStatus {
array<ReadLaterEntry> unread_entries;
array<ReadLaterEntry> read_entries;
};
// Information about a read later entry.
struct ReadLaterEntry {
string title;
url.mojom.Url url;
string display_url;
int64 update_time;
// Whether the entry has been read.
bool read;
string display_time_since_update;
};
// Used by the WebUI page to bootstrap bidirectional communication.
interface PageHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreatePageHandler(pending_remote<Page> page,
pending_receiver<PageHandler> handler);
};
// Browser-side handler for requests from WebUI page.
interface PageHandler {
// Get unread and read read later entries.
GetReadLaterEntries() => (ReadLaterEntriesByStatus entries);
// Open a saved read later entry and mark as read if needed. Reading list
// items are marked as read when opened, while Bookmark links do not need to
// be mark as read when opened.
OpenURL(url.mojom.Url url, bool mark_as_read,
ui.mojom.ClickModifiers click_modifiers);
// Updates a read later entry's read status.
UpdateReadStatus(url.mojom.Url url, bool read);
// Marks the current tab as read in the reading list.
MarkCurrentTabAsRead();
// Adds the current tab to the reading list.
AddCurrentTab();
// Removes a read later entry.
RemoveEntry(url.mojom.Url url);
// Shows a context menu for a read later entry.
ShowContextMenuForURL(url.mojom.Url url, int32 x, int32 y);
// Updates the reading list current page action button state.
UpdateCurrentPageActionButtonState();
// Notify the backend that the UI is ready to be shown.
ShowUI();
// Notify the backend that the dialog should be closed.
CloseUI();
};
enum CurrentPageActionButtonState {
kAdd,
kDisabled,
kMarkAsRead,
};
// WebUI-side handler for requests from the browser.
interface Page {
// Callback when any item in read later is changed/removed. `entries` is a
// collection of all read later entries by read/unread status. This data
// structure is always present, even if the read/unread lists are empty.
ItemsChanged(ReadLaterEntriesByStatus entries);
// Callback when active tab or reading list model changes trigger the need
// to update the state of the current page action button to `state`.
CurrentPageActionButtonStateChanged(CurrentPageActionButtonState state);
};