chromium/ios/web/js_messaging/BUILD.gn

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

import("//ios/build/config.gni")
import("//ios/web/javascript_flags.gni")
import("//ios/web/public/js_messaging/optimize_ts.gni")

source_set("js_messaging") {
  deps = [
    ":frame_listeners_js",
    ":java_script_content_world_header",
    ":java_script_content_world_util",
    ":java_script_feature_manager_header",
    ":scoped_wk_script_message_handler",
    ":setup_frame_js",
    ":web_view_js_utils",
    "//base",
    "//ios/web/common:features",
    "//ios/web/navigation:wk_navigation_util",
    "//ios/web/public",
    "//ios/web/public/deprecated",
    "//ios/web/public/js_messaging",
    "//ios/web/public/js_messaging:web_view_js_utils",
    "//ios/web/web_state:web_state_impl_header",
    "//ios/web/web_state/ui:web_controller_header",
    "//ios/web/web_view:util",
    "//url",
  ]

  sources = [
    "page_script_util.h",
    "page_script_util.mm",
    "web_frame_impl.h",
    "web_frame_impl.mm",
    "web_frame_internal.h",
    "web_frames_manager_impl.h",
    "web_frames_manager_impl.mm",
    "web_frames_manager_java_script_feature.h",
    "web_frames_manager_java_script_feature.mm",
    "web_frames_manager_observer_bridge.mm",
    "web_view_web_state_map.h",
    "web_view_web_state_map.mm",
  ]
}

source_set("java_script_feature") {
  public_deps = [
    ":java_script_content_world_header",
    ":java_script_feature_manager_header",
  ]
  deps = [
    ":js_messaging",
    ":scoped_wk_script_message_handler",
    ":web_view_js_utils",
    "//base",
    "//ios/web:features",
    "//ios/web/public",
    "//ios/web/public/js_messaging",
    "//ios/web/public/js_messaging:web_view_js_utils",
    "//ios/web/web_state:web_state_impl_header",
    "//ios/web/web_state/ui:web_controller_header",
    "//ios/web/web_state/ui:wk_web_view_configuration_provider_header",
  ]

  if (ios_enable_javascript_flags) {
    deps += [ "//ios/web:flags" ]
  }

  sources = [
    "java_script_content_world.mm",
    "java_script_feature.mm",
    "java_script_feature_manager.mm",
    "script_message.mm",
  ]
}

source_set("java_script_content_world_header") {
  deps = [
    ":scoped_wk_script_message_handler",
    "//base",
    "//ios/web/public/js_messaging",
  ]

  sources = [ "java_script_content_world.h" ]
}

source_set("java_script_content_world_util") {
  deps = [
    "//base",
    "//ios/web/public/js_messaging:content_world_header",
  ]

  sources = [
    "java_script_content_world_util.h",
    "java_script_content_world_util.mm",
  ]
}

source_set("java_script_feature_manager_header") {
  deps = [
    ":java_script_content_world_header",
    "//base",
  ]

  sources = [ "java_script_feature_manager.h" ]
}

source_set("java_script_feature_util") {
  deps = [
    ":js_messaging",
    "//base",
    "//ios/web/annotations",
    "//ios/web/common",
    "//ios/web/favicon",
    "//ios/web/find_in_page",
    "//ios/web/js_features/context_menu",
    "//ios/web/js_features/error_page",
    "//ios/web/js_features/fullscreen",
    "//ios/web/js_features/scroll_helper",
    "//ios/web/js_features/window_error",
    "//ios/web/navigation:navigation_feature",
    "//ios/web/navigation:session_restore_feature",
    "//ios/web/public",
    "//ios/web/public/js_messaging",
    "//ios/web/text_fragments",
    "//ios/web/webui",
  ]

  sources = [
    "java_script_feature_util_impl.h",
    "java_script_feature_util_impl.mm",
  ]
}

source_set("scoped_wk_script_message_handler") {
  deps = [
    ":web_view_js_utils",
    "//base",
  ]

  sources = [
    "scoped_wk_script_message_handler.h",
    "scoped_wk_script_message_handler.mm",
  ]
}

source_set("web_view_js_utils") {
  deps = [
    "//base",
    "//ios/web/public/js_messaging:web_view_js_utils",
  ]

  sources = [
    "web_view_js_utils.h",
    "web_view_js_utils.mm",
  ]
}

optimize_ts("setup_frame_js") {
  visibility = [ ":js_messaging" ]

  sources = [ "resources/setup_frame.ts" ]

  deps = [
    "//ios/web/public/js_messaging:frame_id",
    "//ios/web/public/js_messaging:gcrweb",
    "//ios/web/public/js_messaging:util_scripts",
  ]
}

optimize_ts("frame_listeners_js") {
  visibility = [ ":js_messaging" ]

  sources = [ "resources/frame_listeners.ts" ]

  deps = [
    "//ios/web/public/js_messaging:frame_id",
    "//ios/web/public/js_messaging:gcrweb",
    "//ios/web/public/js_messaging:util_scripts",
  ]
}

source_set("unittests") {
  testonly = true
  deps = [
    ":java_script_content_world_util",
    ":java_script_feature",
    ":java_script_feature_util",
    ":js_messaging",
    ":scoped_wk_script_message_handler",
    ":web_view_js_utils",
    "//base",
    "//base/test:test_support",
    "//ios/web/common:web_view_creation_util",
    "//ios/web/public/js_messaging",
    "//ios/web/public/test",
    "//ios/web/public/test:test_fixture",
    "//ios/web/public/test/fakes",
    "//ios/web/test:js_test_util_internal",
    "//ios/web/test/fakes",
    "//ios/web/web_state:web_state_impl_header",
    "//ios/web/web_state/ui:web_controller_header",
    "//ios/web/web_state/ui:wk_web_view_configuration_provider",
    "//testing/gtest",
    "//third_party/ocmock",
  ]

  sources = [
    "java_script_content_world_unittest.mm",
    "java_script_content_world_util_unittest.mm",
    "java_script_feature_manager_unittest.mm",
    "java_script_feature_unittest.mm",
    "page_script_util_unittest.mm",
    "scoped_wk_script_message_handler_unittest.mm",
    "web_frame_impl_unittest.mm",
    "web_frames_manager_impl_unittest.mm",
    "web_frames_manager_java_script_feature_unittest.mm",
    "web_frames_manager_observer_bridge_unittest.mm",
    "web_view_js_utils_unittest.mm",
    "web_view_web_state_map_unittest.mm",
  ]
}

source_set("inttests") {
  testonly = true
  deps = [
    ":java_script_content_world_header",
    ":java_script_feature",
    ":js_messaging",
    "//base",
    "//base/test:test_support",
    "//ios/testing:embedded_test_server_support",
    "//ios/web/common",
    "//ios/web/js_messaging:java_script_feature",
    "//ios/web/public",
    "//ios/web/public/js_messaging",
    "//ios/web/public/test",
    "//ios/web/public/test:test_fixture",
    "//ios/web/public/test:util",
    "//ios/web/public/test/fakes",
    "//ios/web/test:js_test_util_internal",
    "//ios/web/test:test_support",
    "//ios/web/test/fakes",
    "//ios/web/web_state/ui:web_controller_header",
    "//ios/web/web_state/ui:wk_web_view_configuration_provider_header",
    "//net:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/ocmock",
  ]
  sources = [
    "java_script_feature_inttest.mm",
    "java_script_feature_manager_inttest.mm",
    "web_frame_impl_inttest.mm",
    "web_frames_manager_inttest.mm",
  ]
}