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

assert(is_win || is_mac || is_linux || is_chromeos || is_android)

source_set("icon_type") {
  sources = [ "page_action_icon_type.h" ]

  deps = [
    "//base",
    "//chrome/common:channel_info",
  ]
}

if (!is_android) {
  source_set("page_action") {
    friend = [
      ":page_action_impl",
      ":unit_tests",
      ":test_support",
    ]

    public = [
      "action_ids.h",
      "page_action_controller.h",
      "page_action_enums.h",
      "page_action_model.h",
      "page_action_model_observer.h",
      "page_action_observer.h",
      "page_action_pass_key.h",
      "page_action_properties_provider.h",
      "page_action_triggers.h",
    ]

    sources = [
      "chip_selector.h",
      "page_action_metrics_recorder.h",
      "page_action_metrics_recorder_interface.h",
    ]

    public_deps = [
      ":icon_type",
      "//base",
      "//chrome/browser/ui/actions:actions_headers",
      "//chrome/browser/ui/toolbar/pinned_toolbar",
      "//components/browser_apis/ui_controllers/toolbar:mojom_data_model",
      "//components/tabs:public",
      "//ui/actions:actions_headers",
      "//ui/base",
    ]
  }

  source_set("page_action_impl") {
    sources = [
      "chip_selector.cc",
      "page_action_controller.cc",
      "page_action_metrics_recorder.cc",
      "page_action_model.cc",
      "page_action_observer.cc",
      "page_action_properties_provider.cc",
      "page_action_triggers.cc",
    ]

    deps = [
      ":page_action",
      "//chrome/browser:primitives",
      "//chrome/browser/ui:browser_actions",
      "//chrome/browser/ui:browser_element_identifiers",
      "//chrome/browser/ui:ui_features",
      "//content/public/browser",
      "//ui/gfx",
    ]

    # TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
    # enable the diagnostic by removing this line.
    configs += [ "//build/config/compiler:no_exit_time_destructors" ]
  }

  source_set("test_support") {
    testonly = true

    sources = [
      "test_support/fake_tab_interface.cc",
      "test_support/fake_tab_interface.h",
      "test_support/mock_page_action_controller.cc",
      "test_support/mock_page_action_controller.h",
      "test_support/mock_page_action_model.cc",
      "test_support/mock_page_action_model.h",
      "test_support/noop_page_action_metrics_recorder.cc",
      "test_support/noop_page_action_metrics_recorder.h",
      "test_support/test_page_action_properties_provider.cc",
      "test_support/test_page_action_properties_provider.h",
    ]

    public_deps = [
      ":page_action",
      "//ui/actions:actions_headers",
    ]

    deps = [
      "//chrome/test:test_support",
      "//components/tabs:test_support",
      "//testing/gmock",
    ]
  }

  source_set("unit_tests") {
    testonly = true

    sources = [
      "chip_selector_unittest.cc",
      "page_action_controller_unittest.cc",
      "page_action_metrics_recorder_unittest.cc",
      "page_action_model_unittest.cc",
      "page_action_observer_unittest.cc",
    ]

    deps = [
      ":page_action",
      ":test_support",
      "//chrome/browser/ui:ui_features",
      "//chrome/test:test_support",
      "//components/tabs:test_support",
      "//ui/events:test_support",
    ]

    # TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
    # enable the diagnostic by removing this line.
    configs += [ "//build/config/compiler:no_exit_time_destructors" ]
  }
}
