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

import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/locales.gni")

template("system_webview_apk_tmpl") {
  android_apk(target_name) {
    forward_variables_from(invoker, "*")

    deps += [
      "//android_webview:assets",
      "//android_webview/apk:webview_license_activity_java",
      "//android_webview/apk:webview_license_provider_java",
      "//base:base_java",
    ]

    if (!defined(alternative_android_sdk_dep)) {
      alternative_android_sdk_dep = webview_framework_dep
    }

    shared_resources = true
    shared_libraries = [ "//android_webview:libwebviewchromium" ]
    native_lib_version_rule = "//build/util:chrome_version_json"
    _native_lib_file =
        rebase_path("$root_gen_dir/CHROME_VERSION.json", root_out_dir)
    native_lib_version_arg = "@FileArg($_native_lib_file:full-quoted)"
    if (build_apk_secondary_abi && android_64bit_target_cpu) {
      secondary_abi_shared_libraries = [ "//android_webview:libwebviewchromium($android_secondary_abi_toolchain)" ]
    }
    aapt_locale_whitelist = locales

    # Whitelist rationale in https://crbug.com/691733.
    exclude_xxxhdpi = true
    xxxhdpi_whitelist = [
      "*shadow*",  # Combination of gradient & transparency cause pixelation.
      "*.9.*",  # Most nine-patches contain shadows.
    ]

    # Used as an additional apk in test scripts.
    never_incremental = true

    if (is_java_debug) {
      enable_multidex = true
    } else {
      proguard_enabled = true
      if (!defined(proguard_configs)) {
        proguard_configs = []
      }
      proguard_configs += [
        "//android_webview/apk/java/proguard.flags",
        "//base/android/proguard/chromium_apk.flags",
        "//base/android/proguard/chromium_code.flags",
        "//base/android/proguard/disable_all_obfuscation.flags",
      ]
      png_to_webp = true
    }
    command_line_flags_file = "webview-command-line"
  }
}
