# Copyright (c) 2023-2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/ohos.gni")
import("//plugins/web/webview/web_webview.gni")

java_library("android_asset_android_java") {
  java_files = [
    "src/ohos/ace/plugin/webviewplugin/androidasset/AndroidAssetPlugin.java",
  ]
  subsystem_name = "plugins"
  part_name = "web_webview"
}

java_library("cookie_manager_android_java") {
  java_files =
      [ "src/ohos/ace/plugin/webviewplugin/webcookie/WebCookiePlugin.java" ]
  subsystem_name = "plugins"
  part_name = "web_webview"
}

java_library("web_storage_android_java") {
  java_files =
      [ "src/ohos/ace/plugin/webviewplugin/webstorage/WebStoragePlugin.java" ]
  subsystem_name = "plugins"
  part_name = "web_webview"
}

ohos_combine_jars("web_webview_java") {
  deps = [
    ":android_asset_android_java",
    ":cookie_manager_android_java",
    ":web_storage_android_java",
  ]
  subsystem_name = "plugins"
  part_name = "web_webview"
  jar_path = "${root_out_dir}/plugins/web/ace_web_webview_android.jar"
}

ohos_source_set("web_webview_android_jni") {
  sources = [
    "jni/android_asset_helper_jni.cpp",
    "jni/geolocation_permissions_android.cpp",
    "jni/geolocation_permissions_jni.cpp",
    "jni/web_cookie_manager_android.cpp",
    "jni/web_cookie_manager_jni.cpp",
    "jni/web_data_base_android.cpp",
    "jni/web_data_base_jni.cpp",
    "jni/web_download_delegate_jni.cpp",
    "jni/web_download_item_jni.cpp",
    "jni/web_download_manager_android.cpp",
    "jni/web_message_port_android.cpp",
    "jni/web_scheme_handler_jni.cpp",
    "jni/web_storage_android.cpp",
    "jni/web_storage_jni.cpp",
    "jni/webview_controller_android.cpp",
    "jni/webview_controller_jni.cpp",
  ]

  include_dirs = web_include
  include_dirs += [ "${WEB_PLUGIN_ROOT_DIR}" ]

  defines = [ "ANDROID_PLATFORM" ]

  deps = [
    ":web_webview_java",
    "//plugins/interfaces/native:ace_plugin_util_android",
  ]

  subsystem_name = "plugins"
  part_name = "web_webview"
}