chromium/components/content_settings/core/common/content_settings.mojom

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

module content_settings.mojom;

import "components/content_settings/core/common/content_settings_enums.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/values.mojom";

// This mirrors the C++ type in content_settings_pattern.h.
struct PatternParts {
  // Lowercase string of the URL scheme to match. This string is empty if the
  // |is_scheme_wildcard| flag is set.
  string scheme;

  // True if the scheme wildcard is set.
  bool is_scheme_wildcard;

  // Normalized string that is either of the following:
  // - IPv4 or IPv6
  // - hostname
  // - domain
  // - empty string if the |is_host_wildcard flag is set.
  string host;

  // True if the domain wildcard is set.
  bool has_domain_wildcard;

  // String with the port to match. This string is empty if the
  // |is_port_wildcard| flag is set.
  string port;

  // True if the port wildcard is set.
  bool is_port_wildcard;

  // TODO(markusheintz): Needed for legacy reasons. Remove. Path
  // specification. Only used for content settings pattern with a "file"
  // scheme part.
  string path;

  // True if the path wildcard is set.
  bool is_path_wildcard;
};

// This mirrors the C++ type in content_settings_pattern.h.
struct ContentSettingsPattern {
  PatternParts parts;
  bool is_valid;
};

// This mirrors the C++ type in content_settings.h.
enum ContentSetting {
  DEFAULT = 0,
  ALLOW,
  BLOCK,
  ASK,
  SESSION_ONLY,
  DETECT_IMPORTANT_CONTENT,
};

// This mirrors the C++ type in content_settings_metadata.h.
struct RuleMetaData {
  mojo_base.mojom.Time last_modified;
  mojo_base.mojom.Time last_used;
  mojo_base.mojom.Time last_visited;
  mojo_base.mojom.Time expiration;
  SessionModel session_model;
  mojo_base.mojom.TimeDelta lifetime;
  // TODO(https://crbug.com/356148020): Migrate RWS-related metadata.
  TpcdMetadataRuleSource tpcd_metadata_rule_source;
  TpcdMetadataCohort tpcd_metadata_cohort;
  bool decided_by_related_website_sets;
};

// This mirrors the C++ type in content_settings.h.
struct ContentSettingPatternSource {
  ContentSettingsPattern primary_pattern;
  ContentSettingsPattern secondary_pattern;
  mojo_base.mojom.Value setting_value;
  RuleMetaData metadata;
  ProviderType source;
  bool incognito;
};

// This mirrors the C++ type in content_settings.h.
// TODO(crbug.com/40282541): This should be removed.
struct RendererContentSettingRules {
  array<ContentSettingPatternSource> mixed_content_rules;
};