Commit ac3c3d07 authored by Jazz Xu's avatar Jazz Xu Committed by Commit Bot

CrOS GMC: Let notification use ash style color if necessary.

This CL makes CrOS GMC compatible with CrOS light/dark mode feature.

Bug: 1135656

Change-Id: Idd4955fd8676d2171bd323c1282198dc57345981
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451316
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814815}
parent c2363c43
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#include "ash/public/cpp/ash_public_export.h" #include "ash/public/cpp/ash_public_export.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
namespace media_message_center {
struct NotificationTheme;
} // namespace media_message_center
namespace views { namespace views {
class View; class View;
} // namespace views } // namespace views
...@@ -40,7 +44,6 @@ class ASH_PUBLIC_EXPORT MediaNotificationProvider { ...@@ -40,7 +44,6 @@ class ASH_PUBLIC_EXPORT MediaNotificationProvider {
// MediaNotificationContainerImpls. Used to populate the dialog on the Ash // MediaNotificationContainerImpls. Used to populate the dialog on the Ash
// shelf. // shelf.
virtual std::unique_ptr<views::View> GetMediaNotificationListView( virtual std::unique_ptr<views::View> GetMediaNotificationListView(
SkColor separator_color,
int separator_thickness) = 0; int separator_thickness) = 0;
// Returns a MediaNotificationContainerimplView for the active MediaSession. // Returns a MediaNotificationContainerimplView for the active MediaSession.
...@@ -50,6 +53,10 @@ class ASH_PUBLIC_EXPORT MediaNotificationProvider { ...@@ -50,6 +53,10 @@ class ASH_PUBLIC_EXPORT MediaNotificationProvider {
// Used for ash to notify the bubble is closing. // Used for ash to notify the bubble is closing.
virtual void OnBubbleClosing() = 0; virtual void OnBubbleClosing() = 0;
// Set the color theme of media notification view.
virtual void SetColorTheme(
const media_message_center::NotificationTheme& color_theme) = 0;
protected: protected:
virtual ~MediaNotificationProvider() = default; virtual ~MediaNotificationProvider() = default;
}; };
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ash/system/tray/tray_container.h" #include "ash/system/tray/tray_container.h"
#include "ash/system/tray/tray_utils.h" #include "ash/system/tray/tray_utils.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "components/media_message_center/media_notification_view_impl.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -175,6 +176,7 @@ void MediaTray::PinButton::ButtonPressed(views::Button* sender, ...@@ -175,6 +176,7 @@ void MediaTray::PinButton::ButtonPressed(views::Button* sender,
MediaTray::MediaTray(Shelf* shelf) : TrayBackgroundView(shelf) { MediaTray::MediaTray(Shelf* shelf) : TrayBackgroundView(shelf) {
if (MediaNotificationProvider::Get()) if (MediaNotificationProvider::Get())
MediaNotificationProvider::Get()->AddObserver(this); MediaNotificationProvider::Get()->AddObserver(this);
SetNotificationColorTheme();
Shell::Get()->session_controller()->AddObserver(this); Shell::Get()->session_controller()->AddObserver(this);
...@@ -261,8 +263,6 @@ void MediaTray::ShowBubble(bool show_by_click) { ...@@ -261,8 +263,6 @@ void MediaTray::ShowBubble(bool show_by_click) {
content_view_ = bubble_view->AddChildView( content_view_ = bubble_view->AddChildView(
MediaNotificationProvider::Get()->GetMediaNotificationListView( MediaNotificationProvider::Get()->GetMediaNotificationListView(
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSeparatorColor),
kMenuSeparatorWidth)); kMenuSeparatorWidth));
bubble_ = std::make_unique<TrayBubbleWrapper>(this, bubble_view, bubble_ = std::make_unique<TrayBubbleWrapper>(this, bubble_view,
...@@ -323,6 +323,24 @@ void MediaTray::UpdateDisplayState() { ...@@ -323,6 +323,24 @@ void MediaTray::UpdateDisplayState() {
SetVisiblePreferred(should_show); SetVisiblePreferred(should_show);
} }
void MediaTray::SetNotificationColorTheme() {
if (!MediaNotificationProvider::Get())
return;
media_message_center::NotificationTheme theme;
theme.primary_text_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorPrimary);
theme.secondary_text_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kTextColorSecondary);
theme.enabled_icon_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorPrimary);
theme.disabled_icon_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorSecondary);
theme.separator_color = AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSeparatorColor);
MediaNotificationProvider::Get()->SetColorTheme(theme);
}
void MediaTray::OnGlobalMediaControlsPinPrefChanged() { void MediaTray::OnGlobalMediaControlsPinPrefChanged() {
UpdateDisplayState(); UpdateDisplayState();
} }
......
...@@ -79,6 +79,9 @@ class ASH_EXPORT MediaTray : public MediaNotificationProviderObserver, ...@@ -79,6 +79,9 @@ class ASH_EXPORT MediaTray : public MediaNotificationProviderObserver,
private: private:
friend class MediaTrayTest; friend class MediaTrayTest;
// Called when theme change, set colors for media notification view.
void SetNotificationColorTheme();
// Called when global media controls pin pref is changed. // Called when global media controls pin pref is changed.
void OnGlobalMediaControlsPinPrefChanged(); void OnGlobalMediaControlsPinPrefChanged();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/system/status_area_widget_test_helper.h" #include "ash/system/status_area_widget_test_helper.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "components/media_message_center/media_notification_view_impl.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "ui/events/event.h" #include "ui/events/event.h"
...@@ -23,9 +24,9 @@ class MockMediaNotificationProvider : public MediaNotificationProvider { ...@@ -23,9 +24,9 @@ class MockMediaNotificationProvider : public MediaNotificationProvider {
MockMediaNotificationProvider() { MockMediaNotificationProvider() {
MediaNotificationProvider::Set(this); MediaNotificationProvider::Set(this);
ON_CALL(*this, GetMediaNotificationListView(_, _)) ON_CALL(*this, GetMediaNotificationListView(_)).WillByDefault([](auto) {
.WillByDefault( return std::make_unique<views::View>();
[](auto, auto) { return std::make_unique<views::View>(); }); });
} }
~MockMediaNotificationProvider() override { ~MockMediaNotificationProvider() override {
...@@ -33,14 +34,15 @@ class MockMediaNotificationProvider : public MediaNotificationProvider { ...@@ -33,14 +34,15 @@ class MockMediaNotificationProvider : public MediaNotificationProvider {
} }
// Medianotificationprovider implementations. // Medianotificationprovider implementations.
MOCK_METHOD2(GetMediaNotificationListView, MOCK_METHOD1(GetMediaNotificationListView, std::unique_ptr<views::View>(int));
std::unique_ptr<views::View>(SkColor, int));
MOCK_METHOD0(GetActiveMediaNotificationView, std::unique_ptr<views::View>()); MOCK_METHOD0(GetActiveMediaNotificationView, std::unique_ptr<views::View>());
MOCK_METHOD0(OnBubbleClosing, void()); MOCK_METHOD0(OnBubbleClosing, void());
void AddObserver(MediaNotificationProviderObserver* observer) override {} void AddObserver(MediaNotificationProviderObserver* observer) override {}
void RemoveObserver(MediaNotificationProviderObserver* observer) override {} void RemoveObserver(MediaNotificationProviderObserver* observer) override {}
bool HasActiveNotifications() override { return has_active_notifications_; } bool HasActiveNotifications() override { return has_active_notifications_; }
bool HasFrozenNotifications() override { return has_frozen_notifications_; } bool HasFrozenNotifications() override { return has_frozen_notifications_; }
void SetColorTheme(
const media_message_center::NotificationTheme& color_theme) override {}
void SetHasActiveNotifications(bool has_active_notifications) { void SetHasActiveNotifications(bool has_active_notifications) {
has_active_notifications_ = has_active_notifications; has_active_notifications_ = has_active_notifications;
...@@ -157,7 +159,7 @@ TEST_F(MediaTrayTest, ShowAndHideBubbleTest) { ...@@ -157,7 +159,7 @@ TEST_F(MediaTrayTest, ShowAndHideBubbleTest) {
// Tap the media tray should show the bubble, and media tray should // Tap the media tray should show the bubble, and media tray should
// be active. GetMediaNotificationlistview also should be called for // be active. GetMediaNotificationlistview also should be called for
// getting active notifications. // getting active notifications.
EXPECT_CALL(*provider(), GetMediaNotificationListView(_, _)); EXPECT_CALL(*provider(), GetMediaNotificationListView(_));
SimulateTapOnMediaTray(); SimulateTapOnMediaTray();
EXPECT_NE(GetBubbleWrapper(), nullptr); EXPECT_NE(GetBubbleWrapper(), nullptr);
EXPECT_TRUE(media_tray()->is_active()); EXPECT_TRUE(media_tray()->is_active());
......
...@@ -33,8 +33,6 @@ views::View* UnifiedMediaControlsDetailedViewController::CreateView() { ...@@ -33,8 +33,6 @@ views::View* UnifiedMediaControlsDetailedViewController::CreateView() {
return new UnifiedMediaControlsDetailedView( return new UnifiedMediaControlsDetailedView(
detailed_view_delegate_.get(), detailed_view_delegate_.get(),
MediaNotificationProvider::Get()->GetMediaNotificationListView( MediaNotificationProvider::Get()->GetMediaNotificationListView(
AshColorProvider::Get()->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSeparatorColor),
kMenuSeparatorWidth)); kMenuSeparatorWidth));
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "ash/system/unified/unified_system_tray_bubble.h" #include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_controller.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "components/media_message_center/media_notification_view_impl.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
using ::testing::_; using ::testing::_;
...@@ -26,9 +27,9 @@ class MockMediaNotificationProvider : MediaNotificationProvider { ...@@ -26,9 +27,9 @@ class MockMediaNotificationProvider : MediaNotificationProvider {
MockMediaNotificationProvider() { MockMediaNotificationProvider() {
MediaNotificationProvider::Set(this); MediaNotificationProvider::Set(this);
ON_CALL(*this, GetMediaNotificationListView(_, _)) ON_CALL(*this, GetMediaNotificationListView(_)).WillByDefault([](auto) {
.WillByDefault( return std::make_unique<views::View>();
[](auto, auto) { return std::make_unique<views::View>(); }); });
} }
~MockMediaNotificationProvider() override { ~MockMediaNotificationProvider() override {
...@@ -36,8 +37,7 @@ class MockMediaNotificationProvider : MediaNotificationProvider { ...@@ -36,8 +37,7 @@ class MockMediaNotificationProvider : MediaNotificationProvider {
} }
// MediaNotificationProvider implementations. // MediaNotificationProvider implementations.
MOCK_METHOD2(GetMediaNotificationListView, MOCK_METHOD1(GetMediaNotificationListView, std::unique_ptr<views::View>(int));
std::unique_ptr<views::View>(SkColor, int));
MOCK_METHOD0(OnBubbleClosing, void()); MOCK_METHOD0(OnBubbleClosing, void());
std::unique_ptr<views::View> GetActiveMediaNotificationView() override { std::unique_ptr<views::View> GetActiveMediaNotificationView() override {
return std::make_unique<views::View>(); return std::make_unique<views::View>();
...@@ -46,6 +46,8 @@ class MockMediaNotificationProvider : MediaNotificationProvider { ...@@ -46,6 +46,8 @@ class MockMediaNotificationProvider : MediaNotificationProvider {
void RemoveObserver(MediaNotificationProviderObserver* observer) override {} void RemoveObserver(MediaNotificationProviderObserver* observer) override {}
bool HasActiveNotifications() override { return true; } bool HasActiveNotifications() override { return true; }
bool HasFrozenNotifications() override { return true; } bool HasFrozenNotifications() override { return true; }
void SetColorTheme(
const media_message_center::NotificationTheme& color_theme) override {}
}; };
} // namespace } // namespace
......
...@@ -52,11 +52,11 @@ bool MediaNotificationProviderImpl::HasFrozenNotifications() { ...@@ -52,11 +52,11 @@ bool MediaNotificationProviderImpl::HasFrozenNotifications() {
std::unique_ptr<views::View> std::unique_ptr<views::View>
MediaNotificationProviderImpl::GetMediaNotificationListView( MediaNotificationProviderImpl::GetMediaNotificationListView(
SkColor separator_color,
int separator_thickness) { int separator_thickness) {
DCHECK(service_); DCHECK(service_);
DCHECK(color_theme_);
auto notification_list_view = std::make_unique<MediaNotificationListView>( auto notification_list_view = std::make_unique<MediaNotificationListView>(
MediaNotificationListView::SeparatorStyle(separator_color, MediaNotificationListView::SeparatorStyle(color_theme_->separator_color,
separator_thickness)); separator_thickness));
active_session_view_ = notification_list_view.get(); active_session_view_ = notification_list_view.get();
service_->SetDialogDelegate(this); service_->SetDialogDelegate(this);
...@@ -72,6 +72,11 @@ void MediaNotificationProviderImpl::OnBubbleClosing() { ...@@ -72,6 +72,11 @@ void MediaNotificationProviderImpl::OnBubbleClosing() {
service_->SetDialogDelegate(nullptr); service_->SetDialogDelegate(nullptr);
} }
void MediaNotificationProviderImpl::SetColorTheme(
const media_message_center::NotificationTheme& color_theme) {
color_theme_ = color_theme;
}
MediaNotificationContainerImpl* MediaNotificationProviderImpl::ShowMediaSession( MediaNotificationContainerImpl* MediaNotificationProviderImpl::ShowMediaSession(
const std::string& id, const std::string& id,
base::WeakPtr<media_message_center::MediaNotificationItem> item) { base::WeakPtr<media_message_center::MediaNotificationItem> item) {
...@@ -79,9 +84,7 @@ MediaNotificationContainerImpl* MediaNotificationProviderImpl::ShowMediaSession( ...@@ -79,9 +84,7 @@ MediaNotificationContainerImpl* MediaNotificationProviderImpl::ShowMediaSession(
return nullptr; return nullptr;
auto container = std::make_unique<MediaNotificationContainerImplView>( auto container = std::make_unique<MediaNotificationContainerImplView>(
id, item, service_, id, item, service_, color_theme_);
media_message_center::MediaNotificationViewImpl::BackgroundStyle::
kAshStyle);
MediaNotificationContainerImplView* container_ptr = container.get(); MediaNotificationContainerImplView* container_ptr = container.get();
container_ptr->AddObserver(this); container_ptr->AddObserver(this);
observed_containers_[id] = container_ptr; observed_containers_[id] = container_ptr;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/ui/global_media_controls/media_dialog_delegate.h" #include "chrome/browser/ui/global_media_controls/media_dialog_delegate.h"
#include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h" #include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h"
#include "chrome/browser/ui/global_media_controls/media_notification_service_observer.h" #include "chrome/browser/ui/global_media_controls/media_notification_service_observer.h"
#include "components/media_message_center/media_notification_view_impl.h"
#include "components/session_manager/core/session_manager_observer.h" #include "components/session_manager/core/session_manager_observer.h"
class MediaNotificationService; class MediaNotificationService;
...@@ -33,10 +34,11 @@ class MediaNotificationProviderImpl ...@@ -33,10 +34,11 @@ class MediaNotificationProviderImpl
bool HasActiveNotifications() override; bool HasActiveNotifications() override;
bool HasFrozenNotifications() override; bool HasFrozenNotifications() override;
std::unique_ptr<views::View> GetMediaNotificationListView( std::unique_ptr<views::View> GetMediaNotificationListView(
SkColor separator_color,
int separator_thickness) override; int separator_thickness) override;
std::unique_ptr<views::View> GetActiveMediaNotificationView() override; std::unique_ptr<views::View> GetActiveMediaNotificationView() override;
void OnBubbleClosing() override; void OnBubbleClosing() override;
void SetColorTheme(
const media_message_center::NotificationTheme& color_theme) override;
// MediaDialogDelegate implementations. // MediaDialogDelegate implementations.
MediaNotificationContainerImpl* ShowMediaSession( MediaNotificationContainerImpl* ShowMediaSession(
...@@ -78,6 +80,8 @@ class MediaNotificationProviderImpl ...@@ -78,6 +80,8 @@ class MediaNotificationProviderImpl
std::map<const std::string, MediaNotificationContainerImplView*> std::map<const std::string, MediaNotificationContainerImplView*>
observed_containers_; observed_containers_;
base::Optional<media_message_center::NotificationTheme> color_theme_;
}; };
#endif // CHROME_BROWSER_UI_ASH_MEDIA_NOTIFICATION_PROVIDER_IMPL_H_ #endif // CHROME_BROWSER_UI_ASH_MEDIA_NOTIFICATION_PROVIDER_IMPL_H_
...@@ -128,8 +128,9 @@ TEST_F(MediaNotificationProviderImplTest, NotificationListTest) { ...@@ -128,8 +128,9 @@ TEST_F(MediaNotificationProviderImplTest, NotificationListTest) {
EXPECT_CALL(*observer(), OnNotificationListViewSizeChanged).Times(2); EXPECT_CALL(*observer(), OnNotificationListViewSizeChanged).Times(2);
SimulateShowNotification(id_1); SimulateShowNotification(id_1);
SimulateShowNotification(id_2); SimulateShowNotification(id_2);
provider()->SetColorTheme(media_message_center::NotificationTheme());
std::unique_ptr<views::View> view = std::unique_ptr<views::View> view =
provider()->GetMediaNotificationListView(SK_ColorBLACK, 1); provider()->GetMediaNotificationListView(1);
auto* notification_list_view = auto* notification_list_view =
static_cast<MediaNotificationListView*>(view.get()); static_cast<MediaNotificationListView*>(view.get());
......
...@@ -80,8 +80,7 @@ MediaNotificationContainerImplView::MediaNotificationContainerImplView( ...@@ -80,8 +80,7 @@ MediaNotificationContainerImplView::MediaNotificationContainerImplView(
const std::string& id, const std::string& id,
base::WeakPtr<media_message_center::MediaNotificationItem> item, base::WeakPtr<media_message_center::MediaNotificationItem> item,
MediaNotificationService* service, MediaNotificationService* service,
media_message_center::MediaNotificationViewImpl::BackgroundStyle base::Optional<media_message_center::NotificationTheme> theme)
background_style)
: views::Button(this), : views::Button(this),
id_(id), id_(id),
foreground_color_(kDefaultForegroundColor), foreground_color_(kDefaultForegroundColor),
...@@ -139,7 +138,7 @@ MediaNotificationContainerImplView::MediaNotificationContainerImplView( ...@@ -139,7 +138,7 @@ MediaNotificationContainerImplView::MediaNotificationContainerImplView(
} else { } else {
view = std::make_unique<media_message_center::MediaNotificationViewImpl>( view = std::make_unique<media_message_center::MediaNotificationViewImpl>(
this, std::move(item), std::move(dismiss_button_placeholder), this, std::move(item), std::move(dismiss_button_placeholder),
base::string16(), kWidth, /*should_show_icon=*/false, background_style); base::string16(), kWidth, /*should_show_icon=*/false, theme);
SetPreferredSize(kNormalSize); SetPreferredSize(kNormalSize);
} }
......
...@@ -52,9 +52,8 @@ class MediaNotificationContainerImplView ...@@ -52,9 +52,8 @@ class MediaNotificationContainerImplView
const std::string& id, const std::string& id,
base::WeakPtr<media_message_center::MediaNotificationItem> item, base::WeakPtr<media_message_center::MediaNotificationItem> item,
MediaNotificationService* service, MediaNotificationService* service,
media_message_center::MediaNotificationViewImpl::BackgroundStyle base::Optional<media_message_center::NotificationTheme> theme =
background_style = media_message_center::MediaNotificationViewImpl:: base::nullopt);
BackgroundStyle::kDefault);
~MediaNotificationContainerImplView() override; ~MediaNotificationContainerImplView() override;
// views::Button: // views::Button:
......
...@@ -112,11 +112,12 @@ MediaNotificationViewImpl::MediaNotificationViewImpl( ...@@ -112,11 +112,12 @@ MediaNotificationViewImpl::MediaNotificationViewImpl(
const base::string16& default_app_name, const base::string16& default_app_name,
int notification_width, int notification_width,
bool should_show_icon, bool should_show_icon,
BackgroundStyle background_style) base::Optional<NotificationTheme> theme)
: container_(container), : container_(container),
item_(std::move(item)), item_(std::move(item)),
default_app_name_(default_app_name), default_app_name_(default_app_name),
notification_width_(notification_width) { notification_width_(notification_width),
theme_(theme) {
DCHECK(container_); DCHECK(container_);
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
...@@ -267,7 +268,8 @@ MediaNotificationViewImpl::MediaNotificationViewImpl( ...@@ -267,7 +268,8 @@ MediaNotificationViewImpl::MediaNotificationViewImpl(
picture_in_picture_button_ = picture_in_picture_button_ =
button_row_->AddChildView(std::move(picture_in_picture_button)); button_row_->AddChildView(std::move(picture_in_picture_button));
if (background_style == BackgroundStyle::kAshStyle) { // Use ash style background if we do have a theme.
if (theme_.has_value()) {
SetBackground(std::make_unique<MediaNotificationBackgroundAshImpl>()); SetBackground(std::make_unique<MediaNotificationBackgroundAshImpl>());
} else { } else {
SetBackground(std::make_unique<MediaNotificationBackgroundImpl>( SetBackground(std::make_unique<MediaNotificationBackgroundImpl>(
...@@ -624,16 +626,26 @@ void MediaNotificationViewImpl::UpdateForegroundColor() { ...@@ -624,16 +626,26 @@ void MediaNotificationViewImpl::UpdateForegroundColor() {
GetMediaNotificationBackground()->GetBackgroundColor(*this); GetMediaNotificationBackground()->GetBackgroundColor(*this);
const SkColor foreground = const SkColor foreground =
GetMediaNotificationBackground()->GetForegroundColor(*this); GetMediaNotificationBackground()->GetForegroundColor(*this);
const SkColor separator_color = SkColorSetA(foreground, 0x1F);
const SkColor disabled_icon_color =
SkColorSetA(foreground, gfx::kDisabledControlAlpha);
title_label_->SetEnabledColor(foreground); NotificationTheme theme;
artist_label_->SetEnabledColor(foreground); if (theme_.has_value()) {
header_row_->SetAccentColor(foreground); theme = *theme_;
} else {
theme.primary_text_color = foreground;
theme.secondary_text_color = foreground;
theme.enabled_icon_color = foreground;
theme.disabled_icon_color =
SkColorSetA(foreground, gfx::kDisabledControlAlpha);
theme.separator_color = SkColorSetA(foreground, 0x1F);
}
title_label_->SetEnabledColor(theme.primary_text_color);
artist_label_->SetEnabledColor(theme.secondary_text_color);
header_row_->SetAccentColor(theme.primary_text_color);
if (vector_header_icon_) { if (vector_header_icon_) {
header_row_->SetAppIcon(gfx::CreateVectorIcon( header_row_->SetAppIcon(gfx::CreateVectorIcon(
*vector_header_icon_, message_center::kSmallImageSizeMD, foreground)); *vector_header_icon_, message_center::kSmallImageSizeMD,
theme.enabled_icon_color));
} }
title_label_->SetBackgroundColor(background); title_label_->SetBackgroundColor(background);
...@@ -641,26 +653,28 @@ void MediaNotificationViewImpl::UpdateForegroundColor() { ...@@ -641,26 +653,28 @@ void MediaNotificationViewImpl::UpdateForegroundColor() {
header_row_->SetBackgroundColor(background); header_row_->SetBackgroundColor(background);
pip_button_separator_view_->children().front()->SetBackground( pip_button_separator_view_->children().front()->SetBackground(
views::CreateSolidBackground(separator_color)); views::CreateSolidBackground(theme.separator_color));
// Update play/pause button images. // Update play/pause button images.
views::SetImageFromVectorIconWithColor( views::SetImageFromVectorIconWithColor(
play_pause_button_, play_pause_button_,
*GetVectorIconForMediaAction(MediaSessionAction::kPlay), *GetVectorIconForMediaAction(MediaSessionAction::kPlay),
kMediaButtonIconSize, foreground); kMediaButtonIconSize, theme.enabled_icon_color);
views::SetToggledImageFromVectorIconWithColor( views::SetToggledImageFromVectorIconWithColor(
play_pause_button_, play_pause_button_,
*GetVectorIconForMediaAction(MediaSessionAction::kPause), *GetVectorIconForMediaAction(MediaSessionAction::kPause),
kMediaButtonIconSize, foreground, disabled_icon_color); kMediaButtonIconSize, theme.enabled_icon_color,
theme.disabled_icon_color);
views::SetImageFromVectorIconWithColor( views::SetImageFromVectorIconWithColor(
picture_in_picture_button_, picture_in_picture_button_,
*GetVectorIconForMediaAction(MediaSessionAction::kEnterPictureInPicture), *GetVectorIconForMediaAction(MediaSessionAction::kEnterPictureInPicture),
kMediaButtonIconSize, foreground); kMediaButtonIconSize, theme.enabled_icon_color);
views::SetToggledImageFromVectorIconWithColor( views::SetToggledImageFromVectorIconWithColor(
picture_in_picture_button_, picture_in_picture_button_,
*GetVectorIconForMediaAction(MediaSessionAction::kExitPictureInPicture), *GetVectorIconForMediaAction(MediaSessionAction::kExitPictureInPicture),
kMediaButtonIconSize, foreground, disabled_icon_color); kMediaButtonIconSize, theme.enabled_icon_color,
theme.disabled_icon_color);
// Update action buttons. // Update action buttons.
for (views::View* child : playback_button_container_->children()) { for (views::View* child : playback_button_container_->children()) {
...@@ -672,12 +686,12 @@ void MediaNotificationViewImpl::UpdateForegroundColor() { ...@@ -672,12 +686,12 @@ void MediaNotificationViewImpl::UpdateForegroundColor() {
views::SetImageFromVectorIconWithColor( views::SetImageFromVectorIconWithColor(
button, *GetVectorIconForMediaAction(GetActionFromButtonTag(*button)), button, *GetVectorIconForMediaAction(GetActionFromButtonTag(*button)),
kMediaButtonIconSize, foreground); kMediaButtonIconSize, theme.enabled_icon_color);
button->SchedulePaint(); button->SchedulePaint();
} }
container_->OnColorsChanged(foreground, background); container_->OnColorsChanged(theme.enabled_icon_color, background);
} }
std::vector<views::View*> MediaNotificationViewImpl::GetButtons() { std::vector<views::View*> MediaNotificationViewImpl::GetButtons() {
......
...@@ -29,6 +29,14 @@ class MediaNotificationBackground; ...@@ -29,6 +29,14 @@ class MediaNotificationBackground;
class MediaNotificationContainer; class MediaNotificationContainer;
class MediaNotificationItem; class MediaNotificationItem;
struct COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) NotificationTheme {
SkColor primary_text_color = 0;
SkColor secondary_text_color = 0;
SkColor enabled_icon_color = 0;
SkColor disabled_icon_color = 0;
SkColor separator_color = 0;
};
class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl
: public MediaNotificationView, : public MediaNotificationView,
public views::ButtonListener { public views::ButtonListener {
...@@ -52,12 +60,6 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl ...@@ -52,12 +60,6 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl
kMaxValue = kSource, kMaxValue = kSource,
}; };
// Allow MediaNotificationViewImpl show different styled background.
enum class BackgroundStyle {
kDefault,
kAshStyle,
};
MediaNotificationViewImpl( MediaNotificationViewImpl(
MediaNotificationContainer* container, MediaNotificationContainer* container,
base::WeakPtr<MediaNotificationItem> item, base::WeakPtr<MediaNotificationItem> item,
...@@ -65,7 +67,7 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl ...@@ -65,7 +67,7 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl
const base::string16& default_app_name, const base::string16& default_app_name,
int notification_width, int notification_width,
bool should_show_icon, bool should_show_icon,
BackgroundStyle background_style = BackgroundStyle::kDefault); base::Optional<NotificationTheme> theme = base::nullopt);
~MediaNotificationViewImpl() override; ~MediaNotificationViewImpl() override;
// views::View: // views::View:
...@@ -181,6 +183,8 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl ...@@ -181,6 +183,8 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl
views::BoxLayout* title_artist_row_layout_ = nullptr; views::BoxLayout* title_artist_row_layout_ = nullptr;
const gfx::VectorIcon* vector_header_icon_ = nullptr; const gfx::VectorIcon* vector_header_icon_ = nullptr;
base::Optional<NotificationTheme> theme_;
DISALLOW_COPY_AND_ASSIGN(MediaNotificationViewImpl); DISALLOW_COPY_AND_ASSIGN(MediaNotificationViewImpl);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment