blob: d14cd7f67bdadd266e53f868052cc395d4daa6c4 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module chrome.mojom;
import "url/mojom/url.mojom";
// Categorizes suggested content for metrics reporting.
// This enum duplicates the values from the NetErrorOfflineSuggestionType
// metrics enum in enums.xml therefore its entries should not be deleted
// or re-ordered and new ones should only be appended. Furthermore, changes
// to this enum might effect the presentation logic in
// components/neterror/resources/neterror.js.
enum AvailableContentType {
// The offline page is prefetched suggested content.
kPrefetchedPage = 0,
kVideo = 1,
kAudio = 2,
// The offline page was downloaded in some other way.
kOtherPage = 3,
kUninteresting = 4,
};
// A single piece of content that is available offline.
// Note: Some of the data stored in this struct is web content and must be
// properly handled for securing their presentation on the net error page:
// * Textual content must be set into the page using the |textContent| property
// of the respective DOM elements.
// * Images must be safely decoded and re-encoded to eliminate any potential
// malicious content.
struct AvailableOfflineContent {
// Together id and name_space define a unique ID for this item.
string id;
string name_space;
// A brief title for the item.
string title;
// Descriptive text about the item.
string snippet;
// A user-friendly description of the modified date.
string date_modified;
// A brief description of the source. May be empty.
string attribution;
// A data URI for a thumbnail that is related to the content.
url.mojom.Url thumbnail_data_uri;
// Type of this content.
AvailableContentType content_type;
};
// A summary of available offline content.
struct AvailableOfflineContentSummary {
// Total number of offline content items (not limited to the categories listed
// below).
uint32 total_items;
// True if at least one prefetched article (Articles For You) is available.
bool has_prefetched_page;
// True if at least one offline page is available.
bool has_offline_page;
// True if at least one video file is available.
bool has_video;
// True if at least one audio file is available.
bool has_audio;
};
// Provides access to items available while offline.
interface AvailableOfflineContentProvider {
// Returns some available pieces of content from downloads. If not there's not
// enough available content deemed interesting, the returned array will be
// empty.
List() => (bool list_visible_by_prefs, array<AvailableOfflineContent> out);
// Returns a summary of available offline content. If not there's not enough
// available content deemed interesting, the returned summary will be empty.
Summarize() => (AvailableOfflineContentSummary out);
// Opens one of the items returned by List().
LaunchItem(string item_id, string name_space);
// Opens the downloads page to view all offline content.
LaunchDownloadsPage(bool open_prefetched_articles_tab);
// Communicates to the browser the user changed the visibility of the
// offline content list.
ListVisibilityChanged(bool is_visible);
};