diff --git a/browser/ui/brave_ads/BUILD.gn b/browser/ui/brave_ads/BUILD.gn index 5a683f1d789a..2daab8f9625c 100644 --- a/browser/ui/brave_ads/BUILD.gn +++ b/browser/ui/brave_ads/BUILD.gn @@ -21,6 +21,7 @@ source_set("brave_ads") { "//brave/app:brave_generated_resources_grit", "//brave/app/vector_icons", "//brave/browser/profiles:util", + "//brave/browser/themes", "//brave/components/brave_ads/browser", "//brave/components/brave_ads/common", "//components/prefs", @@ -30,7 +31,6 @@ source_set("brave_ads") { "//ui/compositor", "//ui/display", "//ui/gfx", - "//ui/native_theme", "//ui/views", ] @@ -67,6 +67,8 @@ source_set("brave_ads") { "spacer_view.h", "text_ad_notification_view.cc", "text_ad_notification_view.h", + "window_util.cc", + "window_util.h", ] if (is_mac) { diff --git a/browser/ui/brave_ads/ad_notification_control_buttons_view.cc b/browser/ui/brave_ads/ad_notification_control_buttons_view.cc index c56e005a1252..cb907bc47f40 100644 --- a/browser/ui/brave_ads/ad_notification_control_buttons_view.cc +++ b/browser/ui/brave_ads/ad_notification_control_buttons_view.cc @@ -12,13 +12,13 @@ #include "brave/browser/ui/brave_ads/ad_notification_view.h" #include "brave/browser/ui/brave_ads/padded_image_button.h" #include "brave/browser/ui/brave_ads/padded_image_view.h" +#include "brave/browser/ui/brave_ads/window_util.h" #include "brave/grit/brave_generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/layer.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/paint_vector_icon.h" -#include "ui/native_theme/native_theme.h" #include "ui/views/background.h" #include "ui/views/layout/box_layout.h" @@ -82,7 +82,7 @@ void AdNotificationControlButtonsView::CreateInfoButton() { } void AdNotificationControlButtonsView::UpdateInfoButton() { - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); const gfx::ImageSkia image_skia = gfx::CreateVectorIcon( should_use_dark_colors ? kBraveAdsDarkModeInfoButtonIcon @@ -106,7 +106,7 @@ void AdNotificationControlButtonsView::CreateCloseButton() { void AdNotificationControlButtonsView::UpdateCloseButton() { DCHECK(close_button_); - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); const gfx::ImageSkia image_skia = gfx::CreateVectorIcon( kBraveAdsCloseButtonIcon, kCloseButtonIconDipSize, diff --git a/browser/ui/brave_ads/ad_notification_header_view.cc b/browser/ui/brave_ads/ad_notification_header_view.cc index e34dcee595d1..319514081281 100644 --- a/browser/ui/brave_ads/ad_notification_header_view.cc +++ b/browser/ui/brave_ads/ad_notification_header_view.cc @@ -10,6 +10,7 @@ #include "base/strings/utf_string_conversions.h" #include "brave/browser/ui/brave_ads/insets_util.h" #include "brave/browser/ui/brave_ads/spacer_view.h" +#include "brave/browser/ui/brave_ads/window_util.h" #include "brave/grit/brave_generated_resources.h" #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" @@ -19,7 +20,6 @@ #include "ui/gfx/font_list.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/size.h" -#include "ui/native_theme/native_theme.h" #include "ui/views/border.h" #include "ui/views/controls/label.h" #include "ui/views/layout/flex_layout.h" @@ -126,7 +126,7 @@ void AdNotificationHeaderView::CreateView(const int width) { } views::Label* AdNotificationHeaderView::CreateTitleLabel() { - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); views::Label* label = new views::Label(); @@ -159,7 +159,7 @@ views::Label* AdNotificationHeaderView::CreateTitleLabel() { } void AdNotificationHeaderView::UpdateTitleLabel() { - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); DCHECK(title_label_); title_label_->SetEnabledColor(should_use_dark_colors ? kDarkModeTitleColor diff --git a/browser/ui/brave_ads/ad_notification_popup.cc b/browser/ui/brave_ads/ad_notification_popup.cc index 6ce49c27ba69..6f0493071ee8 100644 --- a/browser/ui/brave_ads/ad_notification_popup.cc +++ b/browser/ui/brave_ads/ad_notification_popup.cc @@ -13,6 +13,7 @@ #include "brave/browser/ui/brave_ads/ad_notification_view.h" #include "brave/browser/ui/brave_ads/ad_notification_view_factory.h" #include "brave/browser/ui/brave_ads/bounds_util.h" +#include "brave/browser/ui/brave_ads/window_util.h" #include "brave/components/brave_ads/browser/features.h" #include "brave/components/brave_ads/common/pref_names.h" #include "brave/grit/brave_generated_resources.h" @@ -36,7 +37,6 @@ #include "ui/gfx/shadow_util.h" #include "ui/gfx/shadow_value.h" #include "ui/gfx/skia_paint_util.h" -#include "ui/native_theme/native_theme.h" #include "ui/views/layout/box_layout.h" #include "ui/views/widget/widget.h" @@ -212,7 +212,7 @@ void AdNotificationPopup::OnPaintBackground(gfx::Canvas* canvas) { gfx::Rect bounds(GetWidget()->GetLayer()->bounds()); bounds.Inset(-GetShadowMargin()); - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); // Draw border with drop shadow cc::PaintFlags border_flags; diff --git a/browser/ui/brave_ads/ad_notification_view.cc b/browser/ui/brave_ads/ad_notification_view.cc index b5604d47866b..3ed2f65294c4 100644 --- a/browser/ui/brave_ads/ad_notification_view.cc +++ b/browser/ui/brave_ads/ad_notification_view.cc @@ -17,7 +17,6 @@ #include "ui/compositor/layer.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/vector2d.h" -#include "ui/native_theme/native_theme.h" #include "ui/views/view.h" namespace brave_ads { diff --git a/browser/ui/brave_ads/text_ad_notification_view.cc b/browser/ui/brave_ads/text_ad_notification_view.cc index 9344e2a89f83..d5f79ed58287 100644 --- a/browser/ui/brave_ads/text_ad_notification_view.cc +++ b/browser/ui/brave_ads/text_ad_notification_view.cc @@ -12,6 +12,7 @@ #include "brave/browser/ui/brave_ads/ad_notification_control_buttons_view.h" #include "brave/browser/ui/brave_ads/ad_notification_header_view.h" #include "brave/browser/ui/brave_ads/insets_util.h" +#include "brave/browser/ui/brave_ads/window_util.h" #include "build/build_config.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/font.h" @@ -19,7 +20,6 @@ #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/text_constants.h" -#include "ui/native_theme/native_theme.h" #include "ui/views/border.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" @@ -155,7 +155,7 @@ views::View* TextAdNotificationView::CreateBodyView( views::Label* TextAdNotificationView::CreateBodyLabel( const AdNotification& ad_notification) { - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); const std::u16string body = ad_notification.body(); @@ -194,7 +194,7 @@ views::Label* TextAdNotificationView::CreateBodyLabel( } void TextAdNotificationView::UpdateBodyLabel() { - const bool should_use_dark_colors = GetNativeTheme()->ShouldUseDarkColors(); + const bool should_use_dark_colors = ShouldUseDarkModeTheme(); DCHECK(body_label_); body_label_->SetEnabledColor(should_use_dark_colors ? kDarkModeBodyColor diff --git a/browser/ui/brave_ads/window_util.cc b/browser/ui/brave_ads/window_util.cc new file mode 100644 index 000000000000..239ed2172af9 --- /dev/null +++ b/browser/ui/brave_ads/window_util.cc @@ -0,0 +1,17 @@ +/* Copyright (c) 2021 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/browser/ui/brave_ads/window_util.h" + +#include "brave/browser/themes/brave_dark_mode_utils.h" + +namespace brave_ads { + +bool ShouldUseDarkModeTheme() { + return dark_mode::GetActiveBraveDarkModeType() == + dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK; +} + +} // namespace brave_ads diff --git a/browser/ui/brave_ads/window_util.h b/browser/ui/brave_ads/window_util.h new file mode 100644 index 000000000000..238aae49088f --- /dev/null +++ b/browser/ui/brave_ads/window_util.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2021 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_BROWSER_UI_BRAVE_ADS_WINDOW_UTIL_H_ +#define BRAVE_BROWSER_UI_BRAVE_ADS_WINDOW_UTIL_H_ + +namespace brave_ads { + +bool ShouldUseDarkModeTheme(); + +} // namespace brave_ads + +#endif // BRAVE_BROWSER_UI_BRAVE_ADS_WINDOW_UTIL_H_