chromium/chromecast/browser/mojom/cast_content_window.mojom

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module chromecast.mojom;

import "chromecast/ui/mojom/ui_service.mojom";
import "mojo/public/mojom/base/values.mojom";

// Describes visual context of the window within the UI.
enum VisibilityType {
  // Unknown visibility state.
  UNKNOWN = 0,

  // Window is occupying the entire screen and can be interacted with.
  FULL_SCREEN = 1,

  // Window occupies a portion of the screen, supporting user interaction.
  PARTIAL_OUT = 2,

  // Window is hidden after dismissal by back gesture, and cannot be interacted
  // with via touch.
  HIDDEN = 3,

  // Window is being displayed as a small visible tile.
  TILE = 4,

  // Window is covered by other activities and cannot be interacted with via
  // touch.
  TRANSIENTLY_HIDDEN = 5
};

// Represents requested activity windowing behavior. Behavior includes:
// 1. How long the activity should show
// 2. Whether the window should become immediately visible
// 3. How much screen space the window should occupy
// 4. What state to return to when the activity is completed
enum VisibilityPriority {
  // The window is destroyed and no longer in use. The window must be removed
  // from the layout. No subsequent requests will be made.
  DESTROYED = -1,

  // Default priority. It is up to system to decide how to show the activity.
  DEFAULT = 0,

  // The activity wants to occupy the full screen for some period of time and
  // then become hidden after a timeout. When timeout, it returns to the
  // previous activity.
  TRANSIENT_TIMEOUTABLE = 1,

  // A high priority interruption occupies half of the screen if a sticky
  // activity is showing on the screen. Otherwise, it occupies the full screen.
  HIGH_PRIORITY_INTERRUPTION = 2,

  // The activity takes place of other activity and won't be timeout.
  STICKY_ACTIVITY = 3,

  // The activity stays on top of others (transient) but won't be timeout.
  // When the activity finishes, it returns to the previous one.
  TRANSIENT_STICKY = 4,

  // The activity should not be visible.
  HIDDEN = 5,

  // The activity should not be visible, but the activity will consider itself
  // to be visible. This is useful for opaque overlays while the activity is
  // still active.
  HIDDEN_STICKY = 6,
};

// Observer for window visibility events.
interface CastContentWindowObserver {
  // Called after the visibility state of the window changes.
  OnVisibilityChange(VisibilityType visibility_type);

  // Notifies window destruction.
  OnWindowDestroyed();
};

// Represents a platform-agnostic window interface for content::WebContents.
interface CastContentWindow {
  // Creates a full-screen window and displays it if screen access has been
  // granted.|z_order| is provided so that windows which share the same parent
  // have a well-defined order.
  CreateWindow(ZOrder z_order, VisibilityPriority priority);

  // Add a window observer.
  AddObserver(pending_remote<CastContentWindowObserver> observer);

  // Allows the window to be shown on the screen. The window cannot be shown on
  // the screen until this is called.
  GrantScreenAccess();

  // Prevents the window from being shown on the screen until
  // GrantScreenAccess() is called.
  RevokeScreenAccess();

  // Cast activity or application calls it to request for a visibility priority
  // change.
  RequestVisibility(VisibilityPriority priority);

  // Enables touch input to be routed to the window's WebContents.
  EnableTouchInput(bool enabled);
};