chromium/components/site_isolation/BUILD.gn

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

import("//build/buildflag_header.gni")
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")

assert(use_blink)

declare_args() {
  # Normally, only Google Chrome Android and some Fuchsia WebEngine builds will
  # use a Google-internal list of isolated origins defined below.
  # If other Fuchsia embedders are added, the associated logic may need to be
  # updated. See crbug.com/1179087.
  #
  # You can set the variable 'use_internal_isolated_origins' to true to use this
  # Google-internal list of isolated origins even in a developer build.  Setting
  # this variable explicitly to true will cause your build to fail if the
  # internal file is missing.
  use_internal_isolated_origins = false

  if (is_chrome_branded && is_android) {
    use_internal_isolated_origins = true
  }
}

buildflag_header("buildflags") {
  header = "buildflags.h"
  flags = [ "USE_INTERNAL_ISOLATED_ORIGINS=$use_internal_isolated_origins" ]
}

source_set("site_isolation") {
  sources = [
    "features.cc",
    "features.h",
    "pref_names.cc",
    "pref_names.h",
    "preloaded_isolated_origins.cc",
    "preloaded_isolated_origins.h",
    "site_isolation_policy.cc",
    "site_isolation_policy.h",
  ]

  if (use_internal_isolated_origins) {
    sources += [
      "internal/google_chrome_isolated_origins.cc",
      "internal/google_chrome_isolated_origins.h",
    ]
  }

  deps = [
    ":buildflags",
    "//base",
    "//components/prefs",
    "//components/user_prefs",
    "//content/public/browser",
    "//url",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [ "site_isolation_policy_unittest.cc" ]
  deps = [
    ":site_isolation",
    "//base",
    "//base/test:test_support",
    "//build:branding_buildflags",
    "//components/prefs",
    "//components/prefs:test_support",
    "//components/user_prefs",
    "//components/variations",
    "//content/public/browser",
    "//content/test:test_support",
    "//testing/gtest",
  ]
}