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

# This file contains Chrome-feature-related build flags (see ui.gni for
# UI-related ones). These should theoretically be moved to the build files of
# the features themselves.
#
# However, today we have many "bad" dependencies on some of these flags from,
# e.g. base, so they need to be global to match the GYP configuration. Also,
# anything that needs a grit define must be in either this file or ui.gni.
#
# PLEASE TRY TO AVOID ADDING FLAGS TO THIS FILE in cases where grit isn't
# required. See the declare_args block of BUILDCONFIG.gn for advice on how
# to set up feature flags.

import("//build/config/chrome_build.gni")
if (is_android) {
  import("//build/config/android/config.gni")
}

declare_args() {
  # Multicast DNS.
  enable_mdns = is_win || is_linux

  enable_plugins = !is_android && !is_ios

  # Enables Native Client support.
  # TODO(GYP): Get NaCl linking on other platforms.
  # Also, see if we can always get rid of enable_nacl_untrusted and
  # enable_pnacl and always build them if enable_nacl is true.
  # The "is_nacl" part of the condition is needed to ensure that
  # the untrusted code is built properly; arguably it should be
  # guarded by "is_nacl" directly rather than enable_nacl_untrusted, but
  # this will go away when Mac and Win are working and we can just use
  # the commented out logic.
  # Eventually we want this to be:
  #   enable_nacl = !is_ios && !is_android
  enable_nacl = (is_linux && !is_chromeos && current_cpu == "x64") || is_nacl
  enable_nacl_untrusted = enable_nacl
  enable_pnacl = enable_nacl_untrusted

  # If debug_devtools is set to true, JavaScript files for DevTools are stored
  # as is and loaded from disk. Otherwise, a concatenated file is stored in
  # resources.pak. It is still possible to load JS files from disk by passing
  # --debug-devtools cmdline switch.
  debug_devtools = false

  # Enables WebRTC.
  # TODO(GYP) make mac and android work.
  enable_webrtc = !is_ios && !is_mac && !is_android

  # Enables the Media Router.
  enable_media_router = !is_ios && !is_android

  # Enables proprietary codecs and demuxers; e.g. H264, MOV, AAC, and MP3.
  # Android OS includes support for proprietary codecs regardless of building
  # Chromium or Google Chrome. We also ship Google Chrome and Chromecast with
  # proprietary codecs.
  # TODO(GYP) The GYP build has || chromecast==1 for this:
  proprietary_codecs = is_android || is_chrome_branded

  enable_configuration_policy = true

  # Enables support for background apps.
  enable_background = !is_ios && !is_android

  enable_captive_portal_detection = !is_android && !is_ios

  # Enables use of the session service, which is enabled by default.
  # Android stores them separately on the Java side.
  enable_session_service = !is_android && !is_ios

  enable_plugin_installation = is_win || is_mac

  enable_app_list = !is_ios && !is_android

  enable_supervised_users = !is_ios

  enable_autofill_dialog = !is_ios

  enable_google_now = !is_ios && !is_android

  enable_one_click_signin = is_win || is_mac || (is_linux && !is_chromeos)

  enable_remoting = !is_ios && !is_android

  # Enable hole punching for the protected video.
  enable_video_hole = is_android

  # Enables browser side Content Decryption Modules. Required for embedders
  # (e.g. Android and ChromeCast) that use a browser side CDM.
  enable_browser_cdms = is_android

  # Variable safe_browsing is used to control the build time configuration
  # for safe browsing feature. Safe browsing can be compiled in 4 different
  # levels: 0 disables it, 1 enables it fully, and 2 enables only UI and
  # reporting features for use with Data Saver on Mobile, and 3 enables
  # extended mobile protection via an external API.  When 3 is fully deployed,
  # it will replace 2.
  if (is_android) {
    safe_browsing_mode = 2
  } else if (is_ios) {
    safe_browsing_mode = 0
  } else {
    safe_browsing_mode = 1
  }
}

# Additional dependent variables -----------------------------------------------

# Set the version of CLD.
#   0: Don't specify the version. This option is for the Finch testing.
#   1: Use only CLD1.
#   2: Use only CLD2.
if (is_android) {
  cld_version = 1
} else {
  cld_version = 2
}

# libudev usage. This currently only affects the content layer.
use_udev = is_linux

# Enable the spell checker.
enable_spellcheck = !is_android

# Use the operating system's spellchecker rather than hunspell.
use_platform_spellchecker = is_android || is_mac

enable_pepper_cdms = enable_plugins && (is_linux || is_mac || is_win)

# Enable basic printing support and UI.
enable_basic_printing = !is_chromeos

# Enable printing with print preview. It does not imply
# enable_basic_printing. It's possible to build Chrome with preview only.
enable_print_preview = !is_android

# The seccomp-bpf sandbox is only supported on three architectures
# currently.
# Do not disable seccomp_bpf anywhere without talking to
# security@chromium.org!
use_seccomp_bpf = (is_linux || is_android) &&
                  (current_cpu == "x86" || current_cpu == "x64" ||
                   current_cpu == "arm" || current_cpu == "mipsel")

# Enable notifications everywhere except iOS.
enable_notifications = !is_ios

# TODO(brettw) this should be moved to net and only dependents get this define.
disable_ftp_support = is_ios

enable_web_speech = !is_android && !is_ios

use_dbus = is_linux

enable_extensions = !is_android && !is_ios

enable_task_manager = !is_ios && !is_android

use_cups = is_desktop_linux || is_mac

enable_themes = !is_android && !is_ios

# TODO(scottmg) remove this when we've fixed printing.
win_pdf_metafile_for_printing = true

# Whether we are using the rlz library or not.  Platforms like Android send
# rlz codes for searches but do not use the library.
enable_rlz_support = is_win || is_mac || is_ios || is_chromeos
enable_rlz = is_chrome_branded && enable_rlz_support

enable_settings_app = enable_app_list && !is_chromeos

enable_service_discovery = enable_mdns || is_mac

enable_wifi_bootstrapping = is_win || is_mac

# Image loader extension is enabled on ChromeOS only.
enable_image_loader_extension = is_chromeos

# Chrome OS: whether to also build the upcoming version of
# ChromeVox, which can then be enabled via a command-line switch.
enable_chromevox_next = false

# Use brlapi from brltty for braille display support.
use_brlapi = is_chromeos

# Option controlling the use of GConf (the classic GNOME configuration
# system).
# TODO(GYP) also require !embedded to enable.
use_gconf = is_linux && !is_chromeos

# Hangout services is an extension that adds extra features to Hangouts.
# For official GYP builds, this flag is set, it will likely need to be
# parameterized in the future for a similar use.
enable_hangout_services_extension = false

# Whether to back up data before sync.
enable_pre_sync_backup = is_win || is_mac || (is_linux && !is_chromeos)

# WebVR support disabled until platform implementations have been added
enable_webvr = false
