chromium/chrome/browser/resources/settings/BUILD.gn

# 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.

import("//build/config/chromeos/ui_mode.gni")
import("//chrome/common/features.gni")
import("//crypto/features.gni")
import("//ui/webui/resources/tools/build_webui.gni")
import("./settings.gni")

assert(!is_android, "Android does not use these settings")

build_webui("build") {
  grd_prefix = "settings"

  static_files = [
    "images/ad_privacy_banner_dark.svg",
    "images/ad_privacy_banner.svg",
    "images/cookies_banner_dark.svg",
    "images/cookies_banner.svg",
    "images/cvc.svg",
    "images/cvc_amex.svg",
    "images/googleg_standard_clr_32px.svg",
    "images/iban.svg",
    "images/password_check_neutral_dark.svg",
    "images/password_check_neutral.svg",
    "images/password_check_positive_dark.svg",
    "images/password_check_positive.svg",
    "images/permissions_banner_dark.svg",
    "images/permissions_banner.svg",
    "images/privacy_guide/ad_topics_graphic.svg",
    "images/privacy_guide/ad_topics_graphic_dark.svg",
    "images/privacy_guide/clouds_graphic_dark.svg",
    "images/privacy_guide/clouds_graphic.svg",
    "images/privacy_guide/completion_banner_dark_v2.svg",
    "images/privacy_guide/completion_banner_v2.svg",
    "images/privacy_guide/cookies_graphic_dark_v2.svg",
    "images/privacy_guide/cookies_graphic_v2.svg",
    "images/privacy_guide/hills_graphic_dark.svg",
    "images/privacy_guide/hills_graphic.svg",
    "images/privacy_guide/history_sync_graphic_dark_v2.svg",
    "images/privacy_guide/history_sync_graphic_v2.svg",
    "images/privacy_guide/horizon_graphic_dark.svg",
    "images/privacy_guide/horizon_graphic.svg",
    "images/privacy_guide/msbb_graphic_dark_v2.svg",
    "images/privacy_guide/msbb_graphic_v2.svg",
    "images/privacy_guide/promo_banner_dark.svg",
    "images/privacy_guide/promo_banner.svg",
    "images/privacy_guide/safe_browsing_graphic_dark_v2.svg",
    "images/privacy_guide/safe_browsing_graphic_v2.svg",
    "images/privacy_guide/welcome_banner_dark.svg",
    "images/privacy_guide/welcome_banner.svg",
    "images/safe_browsing_banner_dark.svg",
    "images/safe_browsing_banner.svg",
    "images/sync_banner_dark.svg",
    "images/sync_banner.svg",
    "images/tracking_protection_banner_dark.svg",
    "images/tracking_protection_banner.svg",
    "settings.html",
  ]

  # -----------------web_component_files start ---------------------------------
  web_component_files = [
    "a11y_page/a11y_page.ts",
    "about_page/about_page.ts",
    "ai_page/ai_page.ts",
    "appearance_page/appearance_fonts_page.ts",
    "appearance_page/appearance_page.ts",
    "appearance_page/home_url_input.ts",
    "autofill_page/address_edit_dialog.ts",
    "autofill_page/address_remove_confirmation_dialog.ts",
    "autofill_page/autofill_page.ts",
    "autofill_page/autofill_section.ts",
    "autofill_page/credit_card_edit_dialog.ts",
    "autofill_page/credit_card_list_entry.ts",
    "autofill_page/iban_edit_dialog.ts",
    "autofill_page/iban_list_entry.ts",
    "autofill_page/payments_list.ts",
    "autofill_page/payments_section.ts",
    "autofill_page/virtual_card_unenroll_dialog.ts",
    "basic_page/basic_page.ts",
    "clear_browsing_data_dialog/clear_browsing_data_dialog.ts",
    "clear_browsing_data_dialog/history_deletion_dialog.ts",
    "clear_browsing_data_dialog/passwords_deletion_dialog.ts",
    "controls/controlled_button.ts",
    "controls/controlled_radio_button.ts",
    "controls/settings_checkbox_list_entry.ts",
    "controls/settings_checkbox.ts",
    "controls/settings_dropdown_menu.ts",
    "controls/settings_radio_group.ts",
    "controls/settings_slider.ts",
    "controls/settings_toggle_button.ts",
    "downloads_page/downloads_page.ts",
    "on_startup_page/on_startup_page.ts",
    "on_startup_page/startup_url_dialog.ts",
    "on_startup_page/startup_url_entry.ts",
    "on_startup_page/startup_urls_page.ts",
    "performance_page/battery_page.ts",
    "performance_page/memory_page.ts",
    "performance_page/performance_page.ts",
    "performance_page/speed_page.ts",
    "performance_page/tab_discard/exception_add_input.ts",
    "performance_page/tab_discard/exception_current_sites_list.ts",
    "performance_page/tab_discard/exception_edit_dialog.ts",
    "performance_page/tab_discard/exception_edit_input.ts",
    "performance_page/tab_discard/exception_entry.ts",
    "performance_page/tab_discard/exception_list.ts",
    "performance_page/tab_discard/exception_tabbed_add_dialog.ts",
    "people_page/history_search_page.ts",
    "people_page/page_content_page.ts",
    "people_page/people_page.ts",
    "people_page/signout_dialog.ts",
    "people_page/sync_controls.ts",
    "people_page/sync_encryption_options.ts",
    "people_page/sync_page.ts",
    "privacy_page/anti_abuse_page.ts",
    "privacy_page/collapse_radio_button.ts",
    "privacy_page/cookies_page.ts",
    "privacy_page/fingerprint_progress_arc.ts",
    "privacy_page/do_not_track_toggle.ts",
    "privacy_page/personalization_options.ts",
    "privacy_page/privacy_guide/privacy_guide_ad_topics_fragment.ts",
    "privacy_page/privacy_guide/privacy_guide_completion_fragment.ts",
    "privacy_page/privacy_guide/privacy_guide_cookies_fragment.ts",
    "privacy_page/privacy_guide/privacy_guide_description_item.ts",
    "privacy_page/privacy_guide/privacy_guide_dialog.ts",
    "privacy_page/privacy_guide/privacy_guide_history_sync_fragment.ts",
    "privacy_page/privacy_guide/privacy_guide_msbb_fragment.ts",
    "privacy_page/privacy_guide/privacy_guide_page.ts",
    "privacy_page/privacy_guide/privacy_guide_promo.ts",
    "privacy_page/privacy_guide/privacy_guide_safe_browsing_fragment.ts",
    "privacy_page/privacy_guide/privacy_guide_welcome_fragment.ts",
    "privacy_page/privacy_guide/step_indicator.ts",
    "privacy_page/privacy_page.ts",
    "privacy_page/secure_dns.ts",
    "privacy_page/secure_dns_input.ts",
    "privacy_page/security_keys_bio_enroll_dialog.ts",
    "privacy_page/security_keys_credential_management_dialog.ts",
    "privacy_page/security_keys_pin_field.ts",
    "privacy_page/security_keys_reset_dialog.ts",
    "privacy_page/security_keys_set_pin_dialog.ts",
    "privacy_page/security_keys_subpage.ts",
    "privacy_page/security_keys_phones_subpage.ts",
    "privacy_page/security_keys_phones_list.ts",
    "privacy_page/security_keys_phones_dialog.ts",
    "privacy_page/security_page.ts",
    "privacy_sandbox/privacy_sandbox_ad_measurement_subpage.ts",
    "privacy_sandbox/privacy_sandbox_fledge_subpage.ts",
    "privacy_sandbox/privacy_sandbox_interest_item.ts",
    "privacy_sandbox/privacy_sandbox_page.ts",
    "privacy_sandbox/privacy_sandbox_manage_topics_subpage.ts",
    "privacy_sandbox/privacy_sandbox_topics_subpage.ts",
    "reset_page/reset_page.ts",
    "reset_page/reset_profile_banner.ts",
    "reset_page/reset_profile_dialog.ts",
    "safety_check_page/safety_check_child.ts",
    "safety_check_page/safety_check_extensions.ts",
    "safety_check_page/safety_check_extensions_child.ts",
    "safety_check_page/safety_check_notification_permissions.ts",
    "safety_check_page/safety_check_page.ts",
    "safety_check_page/safety_check_passwords_child.ts",
    "safety_check_page/safety_check_safe_browsing_child.ts",
    "safety_check_page/safety_check_unused_site_permissions.ts",
    "safety_check_page/safety_check_updates_child.ts",
    "safety_hub/safety_hub_card.ts",
    "safety_hub/safety_hub_entry_point.ts",
    "safety_hub/safety_hub_module.ts",
    "safety_hub/extensions_module.ts",
    "safety_hub/safety_hub_page.ts",
    "safety_hub/notification_permissions_module.ts",
    "safety_hub/unused_site_permissions_module.ts",
    "search_engines_page/omnibox_extension_entry.ts",
    "search_engines_page/search_engine_edit_dialog.ts",
    "search_engines_page/search_engine_entry.ts",
    "search_engines_page/search_engines_list.ts",
    "search_engines_page/search_engines_page.ts",
    "search_page/search_engine_list_dialog.ts",
    "search_page/search_page.ts",
    "settings_main/settings_main.ts",
    "settings_menu/settings_menu.ts",
    "settings_page/settings_animated_pages.ts",
    "settings_page/settings_section.ts",
    "settings_page/settings_subpage.ts",
    "settings_ui/settings_ui.ts",
    "simple_confirmation_dialog.ts",
    "site_favicon.ts",
    "site_settings/add_site_dialog.ts",
    "site_settings/all_sites.ts",
    "site_settings/category_setting_exceptions.ts",
    "site_settings/chooser_exception_list_entry.ts",
    "site_settings/chooser_exception_list.ts",
    "site_settings/site_details_permission_device_entry.ts",
    "site_settings/edit_exception_dialog.ts",
    "site_settings/file_system_site_details.ts",
    "site_settings/file_system_site_entry.ts",
    "site_settings/file_system_site_entry_item.ts",
    "site_settings/file_system_site_list.ts",
    "site_settings/media_picker.ts",
    "site_settings/review_notification_permissions.ts",
    "site_settings_page/recent_site_permissions.ts",
    "site_settings_page/site_settings_list.ts",
    "site_settings_page/site_settings_page.ts",
    "site_settings_page/unused_site_permissions.ts",
    "site_settings/offer_writing_help_page.ts",
    "site_settings/pdf_documents.ts",
    "site_settings/protocol_handlers.ts",
    "site_settings/settings_category_default_radio_group.ts",
    "site_settings/site_data.ts",
    "site_settings/site_details_permission.ts",
    "site_settings/site_details.ts",
    "site_settings/site_entry.ts",
    "site_settings/site_list_entry.ts",
    "site_settings/site_list.ts",
    "site_settings/storage_access_static_site_list_entry.ts",
    "site_settings/storage_access_site_list_entry.ts",
    "site_settings/storage_access_site_list.ts",
    "site_settings/zoom_levels.ts",
  ]

  if (!is_chromeos_ash) {
    web_component_files += [
      "people_page/manage_profile.ts",
      "people_page/sync_account_control.ts",
      "relaunch_confirmation_dialog.ts",
      "languages_page/add_languages_dialog.ts",
      "languages_page/languages_page.ts",
      "languages_page/spell_check_page.ts",
      "languages_page/translate_page.ts",
      "system_page/system_page.ts",
    ]
  }

  if (!is_chromeos) {
    web_component_files += [
      "a11y_page/live_caption_section.ts",
      "a11y_page/live_translate_section.ts",
      "default_browser_page/default_browser_page.ts",
      "people_page/import_data_dialog.ts",
    ]
  }

  if (!is_chromeos_ash && !is_mac) {
    web_component_files += [ "languages_page/edit_dictionary_page.ts" ]
  }

  if (!is_chromeos && !is_mac) {
    web_component_files += [ "a11y_page/captions_subpage.ts" ]
  }

  if (is_mac) {
    web_component_files += [ "autofill_page/passkey_edit_dialog.ts" ]
  }

  if (is_win) {
    web_component_files += [
      "incompatible_applications_page/incompatible_application_item.ts",
      "incompatible_applications_page/incompatible_applications_page.ts",
    ]
  }
  if (is_win || is_mac) {
    web_component_files += [ "autofill_page/passkeys_subpage.ts" ]
  }
  if (is_win || is_mac || is_linux) {
    web_component_files += [ "a11y_page/ax_annotations_section.ts" ]
  }
  if (is_chrome_branded) {
    static_files += [
      "images/gtmooc_computer_dark.svg",
      "images/gtmooc_computer.svg",
      "images/gtmooc_cookie_dark.svg",
      "images/gtmooc_cookie.svg",
      "images/gtmooc_diagram_cookie_dark.svg",
      "images/gtmooc_diagram_cookie.svg",
      "images/gtmooc_diagram_history_dark.svg",
      "images/gtmooc_diagram_history.svg",
      "images/gtmooc_diagram_search_dark.svg",
      "images/gtmooc_diagram_search.svg",
      "images/gtmooc_search_dark.svg",
      "images/gtmooc_search.svg",
    ]
    web_component_files += [
      "about_page/get_most_chrome_section.ts",
      "get_most_chrome_page/get_most_chrome_page.ts",
    ]
  }

  # -----------------web_component_files end ----------------------------------

  # -----------------non_web_component_files start ----------------------------

  non_web_component_files = [
    "a11y_page/a11y_browser_proxy.ts",
    "about_page/about_page_browser_proxy.ts",
    "appearance_page/appearance_browser_proxy.ts",
    "autofill_page/address_edit_dialog_components.ts",
    "autofill_page/autofill_manager_proxy.ts",
    "autofill_page/password_manager_proxy.ts",
    "autofill_page/payments_manager_proxy.ts",
    "base_mixin.ts",
    "clear_browsing_data_dialog/clear_browsing_data_browser_proxy.ts",
    "controls/settings_idle_load.ts",
    "downloads_page/downloads_browser_proxy.ts",
    "ensure_lazy_loaded.ts",
    "focus_config.ts",
    "global_scroll_target_mixin.ts",
    "hats_browser_proxy.ts",
    "i18n_setup.ts",
    "lazy_load.ts",
    "metrics_browser_proxy.ts",
    "on_startup_page/on_startup_browser_proxy.ts",
    "on_startup_page/startup_urls_page_browser_proxy.ts",
    "page_visibility.ts",
    "performance_page/constants.ts",
    "performance_page/performance_browser_proxy.ts",
    "performance_page/performance_metrics_proxy.ts",
    "performance_page/tab_discard/exception_validation_mixin.ts",
    "privacy_page/privacy_guide/constants.ts",
    "privacy_page/privacy_guide/privacy_guide_availability_mixin.ts",
    "privacy_page/privacy_guide/privacy_guide_browser_proxy.ts",
    "privacy_sandbox/privacy_sandbox_browser_proxy.ts",
    "privacy_page/security_keys_browser_proxy.ts",
    "relaunch_mixin.ts",
    "reset_page/reset_browser_proxy.ts",
    "route.ts",
    "router.ts",
    "safety_check_page/safety_check_browser_proxy.ts",
    "safety_check_page/safety_check_extensions_browser_proxy.ts",
    "safety_hub/safety_hub_browser_proxy.ts",
    "scrollable_mixin.ts",
    "search_engines_page/search_engines_browser_proxy.ts",
    "search_settings.ts",
    "settings.ts",
    "settings_page/main_page_mixin.ts",
    "site_settings/constants.ts",
    "site_settings/site_settings_mixin.ts",
    "site_settings/site_settings_prefs_browser_proxy.ts",
    "site_settings/website_usage_browser_proxy.ts",
    "site_settings_page/site_settings_page_util.ts",
    "time.ts",
    "tooltip_mixin.ts",
  ]

  if (is_chromeos_ash) {
    web_component_files += [ "privacy_page/secure_dns_dialog.ts" ]
    non_web_component_files +=
        [ "people_page/account_manager_browser_proxy.ts" ]
  } else {
    if (!is_chromeos_lacros) {
      non_web_component_files += [
        "default_browser_page/default_browser_browser_proxy.ts",
        "people_page/import_data_browser_proxy.ts",
      ]
    }
    non_web_component_files += [
      "languages_page/languages.ts",
      "languages_page/languages_browser_proxy.ts",
      "languages_page/languages_settings_metrics_proxy.ts",
      "languages_page/languages_types.ts",
      "people_page/manage_profile_browser_proxy.ts",
      "system_page/system_page_browser_proxy.ts",
    ]
  }

  if (is_win) {
    non_web_component_files += [ "incompatible_applications_page/incompatible_applications_browser_proxy.ts" ]
  }
  if (is_win || is_mac) {
    non_web_component_files += [ "autofill_page/passkeys_browser_proxy.ts" ]
  }

  # -----------------non_web_component_files end -------------------------------

  icons_html_files = [
    "icons.html",
    "privacy_icons.html",
    "privacy_page/fingerprint_icons.html",
    "privacy_sandbox/privacy_sandbox_icons.html",
    "site_settings/all_sites_icons.html",
  ]

  if (is_chrome_branded) {
    icons_html_files += [ "internal/icons.html" ]
  }

  css_files = [
    "settings_columned_section.css",
    "settings_page_styles.css",
    "settings_shared.css",
    "settings_vars.css",

    # subfolder files
    "autofill_page/screen_reader_only.css",
    "autofill_page/passwords_shared.css",
    "privacy_page/privacy_guide/privacy_guide_fragment_shared.css",
    "search_engines_page/search_engine_entry.css",
    "site_settings/clear_storage_dialog_shared.css",
    "site_settings_page/site_review_shared.css",
  ]

  ts_composite = true
  ts_definitions = [
    "//tools/typescript/definitions/autofill_private.d.ts",
    "//tools/typescript/definitions/chrome_event.d.ts",
    "//tools/typescript/definitions/chrome_send.d.ts",
    "//tools/typescript/definitions/language_settings_private.d.ts",
    "//tools/typescript/definitions/management.d.ts",
    "//tools/typescript/definitions/metrics_private.d.ts",
    "//tools/typescript/definitions/passwords_private.d.ts",
    "//tools/typescript/definitions/pending.d.ts",
    "//tools/typescript/definitions/settings_private.d.ts",
  ]
  if (is_chromeos) {
    ts_definitions +=
        [ "//tools/typescript/definitions/quick_unlock_private.d.ts" ]
  }

  ts_deps = [
    "//chrome/browser/resources/settings_shared:build_ts",
    "//third_party/polymer/v3_0:library",
    "//ui/webui/resources/cr_components/customize_color_scheme_mode:build_ts",
    "//ui/webui/resources/cr_components/help_bubble:build_ts",
    "//ui/webui/resources/cr_components/localized_link:build_ts",
    "//ui/webui/resources/cr_components/managed_dialog:build_ts",
    "//ui/webui/resources/cr_components/managed_footnote:build_ts",
    "//ui/webui/resources/cr_elements:build_ts",
    "//ui/webui/resources/js:build_ts",
  ]

  if (!is_chromeos_ash) {
    ts_deps +=
        [ "//ui/webui/resources/cr_components/theme_color_picker:build_ts" ]
  } else {
    ts_deps += [ "//ash/webui/common/resources:build_ts" ]
  }

  if (use_nss_certs || chrome_root_store_cert_management_ui) {
    ts_deps +=
        [ "//ui/webui/resources/cr_components/certificate_manager:build_ts" ]
  }

  ts_path_mappings =
      [ "/shared/settings/*|" + rebase_path(
            "$root_gen_dir/chrome/browser/resources/settings_shared/tsc/*",
            target_gen_dir) ]

  if (is_chromeos_ash) {
    # TODO(crbug.com/1013466): Browser Settings should not depend on ash/webui/
    # code. The codepath needing this (in people_page.ts) should be removed when
    # the SplitSettings effort makes progress (unclear status as of this
    # writing, unfortunately).
    ts_extra_deps = [ "//ash/webui/common/resources:generate_definitions" ]
  }

  webui_context_type = "trusted"
  optimize = optimize_webui
  if (optimize) {
    optimize_webui_host = "settings"
    optimize_webui_in_files = [
      "settings.js",
      "lazy_load.js",
    ]
    optimize_webui_excludes =
        [ "chrome://resources/mojo/skia/public/mojom/skcolor.mojom-webui.js" ]
    optimize_webui_external_paths =
        [ "/shared/settings|" + rebase_path(
              "$root_gen_dir/chrome/browser/resources/settings_shared/tsc",
              root_build_dir) ]
  }
}