Commit bc95a976 authored by Noah Rose Ledesma's avatar Noah Rose Ledesma Committed by Commit Bot

GMC: Create class for redesigned UI

This change adds MediaNotificationViewModernImpl which will be used in
place of MediaNotificationViewImpl when the off-by-default "Global
Media Controls Modern UI" flag is enabled. This change also adds the
logic to switch impls based on this flag.

Bug: 1124401
Change-Id: I85893609cc8e6c072d37cd1df878498441a0044a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398950
Commit-Queue: Noah Rose Ledesma <noahrose@google.com>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805938}
parent 356c95d9
......@@ -79,6 +79,7 @@ class MockMediaNotificationView
MOCK_METHOD1(UpdateWithMediaArtwork, void(const gfx::ImageSkia&));
MOCK_METHOD1(UpdateWithFavicon, void(const gfx::ImageSkia&));
MOCK_METHOD1(UpdateWithVectorIcon, void(const gfx::VectorIcon& vector_icon));
MOCK_METHOD1(UpdateDeviceSelectorAvailability, void(bool availability));
};
class MockSessionController : public CastMediaSessionController {
......
......@@ -61,6 +61,7 @@ class MockMediaNotificationView
MOCK_METHOD1(UpdateWithMediaArtwork, void(const gfx::ImageSkia&));
MOCK_METHOD1(UpdateWithFavicon, void(const gfx::ImageSkia&));
MOCK_METHOD1(UpdateWithVectorIcon, void(const gfx::VectorIcon& vector_icon));
MOCK_METHOD1(UpdateDeviceSelectorAvailability, void(bool availability));
};
class MockClosure {
......
......@@ -12,9 +12,9 @@
#include "chrome/browser/ui/views/global_media_controls/media_dialog_view.h"
#include "chrome/browser/ui/views/global_media_controls/media_notification_device_selector_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/media_message_center/media_notification_view_modern_impl.h"
#include "components/vector_icons/vector_icons.h"
#include "media/audio/audio_device_description.h"
#include "media/base/media_switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/canvas_painter.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
......@@ -115,9 +115,16 @@ MediaNotificationContainerImplView::MediaNotificationContainerImplView(
UpdateDismissButtonIcon();
bool is_cast_notification = item ? item->SourceIsCast() : false;
auto view = std::make_unique<media_message_center::MediaNotificationViewImpl>(
this, std::move(item), std::move(dismiss_button_placeholder),
base::string16(), kWidth, /*should_show_icon=*/false);
std::unique_ptr<media_message_center::MediaNotificationView> view;
if (base::FeatureList::IsEnabled(media::kGlobalMediaControlsModernUI)) {
view = std::make_unique<
media_message_center::MediaNotificationViewModernImpl>();
} else {
view = std::make_unique<media_message_center::MediaNotificationViewImpl>(
this, std::move(item), std::move(dismiss_button_placeholder),
base::string16(), kWidth, /*should_show_icon=*/false);
}
view_ = swipeable_container_->AddChildView(std::move(view));
if (base::FeatureList::IsEnabled(
......
......@@ -15,6 +15,7 @@
#include "components/media_message_center/media_notification_container.h"
#include "components/media_message_center/media_notification_view_impl.h"
#include "media/audio/audio_device_description.h"
#include "media/base/media_switches.h"
#include "ui/views/animation/slide_out_controller_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/focus/focus_manager.h"
......@@ -117,7 +118,8 @@ class MediaNotificationContainerImplView
views::ImageButton* GetDismissButtonForTesting();
media_message_center::MediaNotificationViewImpl* view_for_testing() {
return view_;
DCHECK(!base::FeatureList::IsEnabled(media::kGlobalMediaControlsModernUI));
return static_cast<media_message_center::MediaNotificationViewImpl*>(view_);
}
bool is_playing_for_testing() { return is_playing_; }
......@@ -166,7 +168,7 @@ class MediaNotificationContainerImplView
views::View* dismiss_button_container_ = nullptr;
DismissButton* dismiss_button_ = nullptr;
media_message_center::MediaNotificationViewImpl* view_ = nullptr;
media_message_center::MediaNotificationView* view_ = nullptr;
MediaNotificationDeviceSelectorView* audio_device_selector_view_ = nullptr;
SkColor foreground_color_;
......
......@@ -19,6 +19,8 @@ component("media_message_center") {
"media_notification_view.h",
"media_notification_view_impl.cc",
"media_notification_view_impl.h",
"media_notification_view_modern_impl.cc",
"media_notification_view_modern_impl.h",
"media_session_notification_item.cc",
"media_session_notification_item.h",
]
......
......@@ -45,6 +45,7 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationView
// Sets the icon to be displayed in the notification's header section.
// |vector_icon| must outlive the MediaNotificationView.
virtual void UpdateWithVectorIcon(const gfx::VectorIcon& vector_icon) = 0;
virtual void UpdateDeviceSelectorAvailability(bool availability) = 0;
};
} // namespace media_message_center
......
......@@ -470,17 +470,17 @@ void MediaNotificationViewImpl::UpdateWithVectorIcon(
kIconMediaNotificationHeaderInsets);
}
void MediaNotificationViewImpl::OnThemeChanged() {
MediaNotificationView::OnThemeChanged();
UpdateForegroundColor();
}
void MediaNotificationViewImpl::UpdateDeviceSelectorAvailability(
bool availability) {
GetMediaNotificationBackground()->UpdateDeviceSelectorAvailability(
availability);
}
void MediaNotificationViewImpl::OnThemeChanged() {
MediaNotificationView::OnThemeChanged();
UpdateForegroundColor();
}
views::Button* MediaNotificationViewImpl::GetHeaderRowForTesting() const {
return header_row_;
}
......
......@@ -81,9 +81,9 @@ class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewImpl
void UpdateWithMediaArtwork(const gfx::ImageSkia& image) override;
void UpdateWithFavicon(const gfx::ImageSkia& icon) override;
void UpdateWithVectorIcon(const gfx::VectorIcon& vector_icon) override;
void OnThemeChanged() override;
void UpdateDeviceSelectorAvailability(bool availability) override;
void UpdateDeviceSelectorAvailability(bool availability);
void OnThemeChanged() override;
const views::Label* title_label_for_testing() const { return title_label_; }
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/media_message_center/media_notification_view_modern_impl.h"
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MEDIA_MESSAGE_CENTER_MEDIA_NOTIFICATION_VIEW_MODERN_IMPL_H_
#define COMPONENTS_MEDIA_MESSAGE_CENTER_MEDIA_NOTIFICATION_VIEW_MODERN_IMPL_H_
#include "components/media_message_center/media_notification_view.h"
namespace media_message_center {
class COMPONENT_EXPORT(MEDIA_MESSAGE_CENTER) MediaNotificationViewModernImpl
: public MediaNotificationView {
public:
MediaNotificationViewModernImpl() = default;
// MediaNotificationView
void SetForcedExpandedState(bool* forced_expanded_state) override {}
void SetExpanded(bool expanded) override {}
void UpdateCornerRadius(int top_radius, int bottom_radius) override {}
void UpdateWithMediaSessionInfo(
const media_session::mojom::MediaSessionInfoPtr& session_info) override {}
void UpdateWithMediaMetadata(
const media_session::MediaMetadata& metadata) override {}
void UpdateWithMediaActions(
const base::flat_set<media_session::mojom::MediaSessionAction>& actions)
override {}
void UpdateWithMediaArtwork(const gfx::ImageSkia& image) override {}
void UpdateWithFavicon(const gfx::ImageSkia& icon) override {}
void UpdateWithVectorIcon(const gfx::VectorIcon& vector_icon) override {}
void UpdateDeviceSelectorAvailability(bool availability) override {}
};
} // namespace media_message_center
#endif // COMPONENTS_MEDIA_MESSAGE_CENTER_MEDIA_NOTIFICATION_VIEW_MODERN_IMPL_H_
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