chromium/chrome/browser/ui/webui/feed_internals/feed_internals.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 feed_internals.mojom;

import "mojo/public/mojom/base/time.mojom";
import "url/mojom/url.mojom";

// Feed sorting order options.
enum FeedOrder {
  kUnspecified = 0,
  kGrouped,
  kReverseChron
};

// General properties of Feed suggestions.
struct Properties {
  // Whether the Feed feature flag is enabled.
  bool is_feed_enabled;

  // Whether suggested articles section is expanded.
  bool is_feed_visible;

  // Whether suggested articles are allowed. Typically set by policy.
  bool is_feed_allowed;

  // Whether prefetching for offline availability is enabled.
  bool is_prefetching_enabled;

  // Whether debugging the WebFeed follow intro is enabled.
  bool is_web_feed_follow_intro_debug_enabled;

  // Whether the legacy feed endpoint should be used.
  bool use_feed_query_requests;

  // Last load stream status, human readable.
  string load_stream_status;

  // Feed fetch URL.
  url.mojom.Url feed_fetch_url;

  // Feed upload actions URL.
  url.mojom.Url feed_actions_url;

  // Following feed order.
  FeedOrder following_feed_order;
};

struct LastFetchProperties {
  // Last fetch status.
  int32 last_fetch_status;

  // Reason for the last fetch.
  string last_fetch_trigger;

  // Last fetch time. Zero if there was no last fetch.
  mojo_base.mojom.TimeDelta last_fetch_time;

  // Time until which the scheduler will stop requesting refreshes.
  // Zero if there is direct user interaction.
  mojo_base.mojom.TimeDelta refresh_suppress_time;

  // For test server authentication.
  string last_bless_nonce;

  // Last net status for actions upload.
  int32 last_action_upload_status;

  // Last action upload time.
  mojo_base.mojom.TimeDelta last_action_upload_time;
};

// Browser interface for the page. Consists of calls for data and hooks for
// interactivity.
interface PageHandler {
  // Get general property values.
  GetGeneralProperties() => (Properties properties);

  // Get last fetch data.
  GetLastFetchProperties() => (LastFetchProperties properties);

  // Trigger a refresh of the For-you Feed.
  RefreshForYouFeed();

  // Trigger a refresh of the Following Feed.
  RefreshFollowingFeed();

  // Trigger a refresh of the Web Feed suggestions.
  RefreshWebFeedSuggestions();

  // Internal state dump of the Feed library's process scope. Human-readable.
  GetFeedProcessScopeDump() => (string dump);

  // Record all Feed metrics into a human-readable log.
  GetFeedHistograms() => (string log);

  // Overrides the scheme, host, and port used to make Feed Query requests.
  // Other URL components, like the path, are ignored.
  // Empty to clear override.
  // This allows for testing the Feed against a development server.
  OverrideFeedHost(url.mojom.Url host);

  // Overrides the scheme, host, and port used to make Discover API requests.
  // Other URL components, like the path, are ignored.
  // Empty to clear override.
  // This allows for testing the Feed against a development server.
  OverrideDiscoverApiEndpoint(url.mojom.Url endpoint_url);

  // Overrides the feed stream data with the payload inside a feedui::Slice for
  // testing purpose. See go/feed-stream-data-testing for more details.
  OverrideFeedStreamData(array<uint8> data);

  // Sets whether debugging the WebFeed follow intro is enabled.
  SetWebFeedFollowIntroDebugEnabled(bool enabled);

  // Sets whether the legacy feed endpoint should be used for Web Feed content
  // fetches.
  SetUseFeedQueryRequests(bool use_legacy);

  // Sets the Following feed order in local preferences.
  SetFollowingFeedOrder(FeedOrder order);
};