chromium/ui/message_center/BUILD.gn

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

import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//components/vector_icons/vector_icons.gni")
import("//testing/test.gni")
import("//ui/base/ui_features.gni")

aggregate_vector_icons("message_center_vector_icons") {
  icon_directory = "vector_icons"

  sources = [
    "notification_close_button.icon",
    "notification_expand_less.icon",
    "notification_expand_more.icon",
    "notification_inline_reply.icon",
    "notification_settings_button.icon",
    "notification_snooze_button.icon",
    "product.icon",
  ]
}

# TODO(msw|mukai|dewittj): Move ash-specific files: crbug.com/585175
component("message_center") {
  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//ui/base",
    "//ui/strings",
    "//url",
  ]

  public_deps = [ "//ui/message_center/public/cpp" ]

  defines = [ "MESSAGE_CENTER_IMPLEMENTATION" ]

  if (enable_message_center) {
    deps += [
      ":message_center_vector_icons",
      "//base:i18n",
      "//components/url_formatter",
      "//skia",
      "//ui/accessibility",
      "//ui/display",
      "//ui/events",
      "//ui/events:gesture_detection",
      "//ui/gfx",
      "//ui/gfx/geometry",
      "//ui/native_theme",
      "//ui/resources",
    ]

    configs += [ "//build/config:precompiled_headers" ]
    sources = [
      "lock_screen/empty_lock_screen_controller.cc",
      "lock_screen/empty_lock_screen_controller.h",
      "lock_screen/lock_screen_controller.h",
      "message_center.cc",
      "message_center.h",
      "message_center_export.h",
      "message_center_impl.cc",
      "message_center_impl.h",
      "message_center_observer.h",
      "message_center_stats_collector.cc",
      "message_center_stats_collector.h",
      "message_center_style.cc",
      "message_center_style.h",
      "message_center_types.h",
      "notification_blocker.cc",
      "notification_blocker.h",
      "notification_list.cc",
      "notification_list.h",
      "notification_view_controller.h",
      "popup_timer.cc",
      "popup_timer.h",
      "popup_timers_controller.cc",
      "popup_timers_controller.h",
    ]

    sources += get_target_outputs(":message_center_vector_icons")

    if (is_win) {
      deps += [
        "//ui/aura",
        "//ui/wm/public",
      ]
    }

    if (toolkit_views) {
      # TODO(b/257291597): Skip the sources that are unused on is_chromeos_ash
      # (e.g. notification_view.cc). This will require refactoring to break
      # dependencies (e.g. MessagePopupCollection must become an interface).
      sources += [
        "views/desktop_message_popup_collection.cc",
        "views/desktop_message_popup_collection.h",
        "views/large_image_view.cc",
        "views/large_image_view.h",
        "views/message_popup_collection.cc",
        "views/message_popup_collection.h",
        "views/message_popup_view.cc",
        "views/message_popup_view.h",
        "views/message_view.cc",
        "views/message_view.h",
        "views/notification_background_painter.cc",
        "views/notification_background_painter.h",
        "views/notification_control_button_factory.cc",
        "views/notification_control_button_factory.h",
        "views/notification_control_buttons_view.cc",
        "views/notification_control_buttons_view.h",
        "views/notification_header_view.cc",
        "views/notification_header_view.h",
        "views/notification_input_container.cc",
        "views/notification_input_container.h",
        "views/notification_view.cc",
        "views/notification_view.h",
        "views/notification_view_base.cc",
        "views/notification_view_base.h",
        "views/notification_view_util.cc",
        "views/notification_view_util.h",
        "views/padded_button.cc",
        "views/padded_button.h",
        "views/proportional_image_view.cc",
        "views/proportional_image_view.h",
        "views/relative_time_formatter.cc",
        "views/relative_time_formatter.h",
      ]
      if (is_mac) {
        sources += [ "views/message_popup_view_mac.mm" ]
      }
      deps += [
        "//ui/color",
        "//ui/compositor",
        "//ui/events",
        "//ui/views",
      ]
      if (is_mac) {
        frameworks = [ "Foundation.framework" ]
      }
      if (is_chromeos) {
        deps += [ "//chromeos/constants:constants" ]
      }
    }
    if (is_chromeos_ash) {
      deps += [ "//ash/constants" ]
    }
  } else {
    # Notification service disabled.
    sources = [ "dummy_message_center.cc" ]
  }
}

if (enable_message_center) {
  static_library("test_support") {
    testonly = true

    sources = [
      "fake_message_center.cc",
      "fake_message_center.h",
      "lock_screen/fake_lock_screen_controller.cc",
      "lock_screen/fake_lock_screen_controller.h",
    ]

    deps = [
      "//base",
      "//base/test:test_support",
      "//skia",
      "//ui/gfx",
      "//ui/gfx/geometry",
    ]

    public_deps = [
      ":message_center",
      "//ui/message_center/public/cpp",
    ]
  }

  test("message_center_unittests") {
    use_xvfb = use_xvfb_in_this_config

    sources = [
      "message_center_impl_unittest.cc",
      "notification_blocker_unittest.cc",
      "notification_list_unittest.cc",
      "public/cpp/notification_delegate_unittest.cc",
      "test/run_all_unittests.cc",
    ]

    deps = [
      ":message_center",
      ":test_support",
      "//base",
      "//base/test:test_support",
      "//build:chromeos_buildflags",
      "//mojo/core/embedder",
      "//skia",
      "//testing/gmock",
      "//testing/gtest",
      "//ui/accessibility:test_support",
      "//ui/base",
      "//ui/base:test_support",
      "//ui/events",
      "//ui/events:test_support",
      "//ui/gfx",
      "//ui/gfx:test_support",
      "//ui/gfx/geometry",
      "//ui/gl",
      "//ui/gl:test_support",
      "//ui/message_center/public/cpp",
      "//ui/native_theme",
      "//ui/resources",
      "//ui/resources:ui_test_pak",
      "//url",
    ]

    data_deps = [
      "//third_party/angle:includes",
      "//ui/resources:ui_test_pak_data",
    ]

    if (is_chromeos_ash) {
      deps += [ "//ash/constants" ]
    }

    if (toolkit_views) {
      sources += [
        "views/large_image_view_unittest.cc",
        "views/message_popup_collection_unittest.cc",
        "views/message_popup_view_unittest.cc",
        "views/message_view_unittest.cc",
        "views/notification_control_buttons_unittest.cc",
        "views/notification_header_view_unittest.cc",
        "views/notification_view_base_unittest.cc",
        "views/relative_time_formatter_unittest.cc",
      ]

      # ChromeOS/Ash uses AshNotificationView, not NotificationView.
      if (!is_chromeos_ash) {
        sources += [ "views/notification_view_unittest.cc" ]
      }

      deps += [
        "//ui/color",
        "//ui/display",
        "//ui/strings",
        "//ui/views",
        "//ui/views:test_support",
      ]

      if (is_chromeos) {
        deps += [ "//chromeos/constants:constants" ]
      }
    }

    if (is_fuchsia) {
      additional_manifest_fragments = [
        "//build/config/fuchsia/test/fonts.shard.test-cml",
        "//build/config/fuchsia/test/present_view.shard.test-cml",
        "//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
      ]
    }
  }
}