chromium/chrome/common/available_offline_content.mojom

// Copyright 2018 The Chromium Authors
// 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;
  // Data URI containing thumbnail image data.
  url.mojom.Url thumbnail_data_uri;
  // Data URI containing favicon image data.
  url.mojom.Url favicon_data_uri;
  // Type of this content.
  AvailableContentType content_type;
};

// 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);
  // 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);
};