chromium/third_party/blink/public/mojom/service_worker/service_worker_client.mojom

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

module blink.mojom;

import "mojo/public/mojom/base/time.mojom";
import "third_party/blink/public/mojom/loader/request_context_frame_type.mojom";
import "url/mojom/url.mojom";

// Indicates the service worker client type.
// See https://w3c.github.io/ServiceWorker/#service-worker-client-concept
// and https://w3c.github.io/ServiceWorker/#dom-clientqueryoptions-type.
enum ServiceWorkerClientType {
  kWindow,
  kDedicatedWorker,
  kSharedWorker,
  kAll,
};

// Indicates the service worker client lifecycle state.
// https://wicg.github.io/page-lifecycle/#serviceworker-client-dfn
enum ServiceWorkerClientLifecycleState {
  kActive,
  kFrozen,
};

// Indicates the options for the service worker clients matching operation.
// https://w3c.github.io/ServiceWorker/#dictdef-clientqueryoptions.
struct ServiceWorkerClientQueryOptions {
  // ClientQueryOptions#includeUncontrolled
  bool include_uncontrolled = false;

  // ClientQueryOptions#type
  ServiceWorkerClientType client_type = ServiceWorkerClientType.kWindow;
};

// Holds the information related to a service worker client.
// https://w3c.github.io/ServiceWorker/#client
//
// An invalid client info can be indicated by setting the |client_uuid| to the
// empty string. Sometimes this is needed when the browser process couldn't
// find a client.
struct ServiceWorkerClientInfo {
  // Client#url
  url.mojom.Url url;

  // Client#frameType.
  RequestContextFrameType frame_type = RequestContextFrameType.kNone;

  // Client#id
  string client_uuid;

  // Client#type
  ServiceWorkerClientType client_type;

  // WindowClient#visibilityState
  // Set to |true| if it's a non-window client.
  bool page_hidden = true;

  // WindowClient#focused
  // Set to |false| if it's a non-window client.
  bool is_focused = false;

  // Client#lifecycleState
  ServiceWorkerClientLifecycleState lifecycle_state = ServiceWorkerClientLifecycleState.kActive;

  // The time this window was last focused. Set to base::TimeTicks() if it's
  // a non-window client.
  mojo_base.mojom.TimeTicks last_focus_time;

  // The time this client was created.
  mojo_base.mojom.TimeTicks creation_time;
};