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

CrOS GMC: Add media tray to status area.

This CL adds a media tray containing a media icon to CrOS status area
next to system tray.

Bug: 1114901

Change-Id: Ic363d925efbf8dac260dc48e950972e30a96283c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347378Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801592}
parent f160a626
...@@ -943,6 +943,8 @@ component("ash") { ...@@ -943,6 +943,8 @@ component("ash") {
"system/locale/unified_locale_detailed_view_controller.h", "system/locale/unified_locale_detailed_view_controller.h",
"system/machine_learning/user_settings_event_logger.cc", "system/machine_learning/user_settings_event_logger.cc",
"system/machine_learning/user_settings_event_logger.h", "system/machine_learning/user_settings_event_logger.h",
"system/media/media_tray.cc",
"system/media/media_tray.h",
"system/message_center/arc_notification_manager_delegate_impl.cc", "system/message_center/arc_notification_manager_delegate_impl.cc",
"system/message_center/arc_notification_manager_delegate_impl.h", "system/message_center/arc_notification_manager_delegate_impl.h",
"system/message_center/ash_message_center_lock_screen_controller.cc", "system/message_center/ash_message_center_lock_screen_controller.cc",
......
...@@ -2342,6 +2342,11 @@ This file contains the strings for ash. ...@@ -2342,6 +2342,11 @@ This file contains the strings for ash.
Don't show again Don't show again
</message> </message>
<!-- Media Tray -->
<message name="IDS_ASH_GLOBAL_MEDIA_CONTROLS_BUTTON_TOOLTIP_TEXT" desc="Tooltip for the Global Media Controls icon, which appears in the toolbar. The tooltip appears on mouseover of the icon.">
Control your music, videos, and more
</message>
<!-- Power off menu --> <!-- Power off menu -->
<message name="IDS_ASH_POWER_BUTTON_MENU_POWER_OFF_BUTTON" desc="Text shown on power off button in power button menu."> <message name="IDS_ASH_POWER_BUTTON_MENU_POWER_OFF_BUTTON" desc="Text shown on power off button in power button menu.">
Power off Power off
......
e44408d259df841b2444eb2484e3ef7995e18af5
\ No newline at end of file
...@@ -49,6 +49,7 @@ aggregate_vector_icons("ash_vector_icons") { ...@@ -49,6 +49,7 @@ aggregate_vector_icons("ash_vector_icons") {
"dictation_on.icon", "dictation_on.icon",
"dictation_on_newui.icon", "dictation_on_newui.icon",
"dogfood.icon", "dogfood.icon",
"global_media_controls.icon",
"hollow_check_circle.icon", "hollow_check_circle.icon",
"html.icon", "html.icon",
"ime_menu_emoticon.icon", "ime_menu_emoticon.icon",
......
// 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.
CANVAS_DIMENSIONS, 16,
MOVE_TO, 15.25f, 2,
R_CUBIC_TO, 0.41f, 0, 0.75f, 0.34f, 0.75f, 0.75f,
R_CUBIC_TO, 0, 0.41f, -0.34f, 0.75f, -0.75f, 0.75f,
H_LINE_TO, 13.5f,
R_LINE_TO, 0, 7.98f,
CUBIC_TO, 13.47f, 12.99f, 12.38f, 14, 11, 14,
R_CUBIC_TO, -1.38f, 0, -2.5f, -1.12f, -2.5f, -2.5f,
CUBIC_TO, 8.5f, 10.12f, 9.62f, 9, 11, 9,
R_CUBIC_TO, 0.36f, 0, 0.69f, 0.07f, 1, 0.21f,
LINE_TO, 12, 2.75f,
R_CUBIC_TO, 0, -0.41f, 0.34f, -0.75f, 0.75f, -0.75f,
R_H_LINE_TO, 2.5f,
CLOSE,
MOVE_TO, 6.89f, 10,
CUBIC_TO, 6.64f, 10.45f, 6.5f, 10.96f, 6.5f, 11.5f,
H_LINE_TO, 0.75f,
CUBIC_TO, 0.34f, 11.5f, 0, 11.16f, 0, 10.75f,
CUBIC_TO_SHORTHAND, 0.34f, 10, 0.75f, 10,
R_LINE_TO, 6.14f, 0,
CLOSE,
MOVE_TO, 9.25f, 6,
R_CUBIC_TO, 0.41f, 0, 0.75f, 0.34f, 0.75f, 0.75f,
R_CUBIC_TO, 0, 0.41f, -0.34f, 0.75f, -0.75f, 0.75f,
H_LINE_TO, 0.75f,
CUBIC_TO, 0.34f, 7.5f, 0, 7.16f, 0, 6.75f,
CUBIC_TO_SHORTHAND, 0.34f, 6, 0.75f, 6,
R_H_LINE_TO, 8.5f,
CLOSE,
R_MOVE_TO, 0, -4,
R_CUBIC_TO, 0.41f, 0, 0.75f, 0.34f, 0.75f, 0.75f,
R_CUBIC_TO, 0, 0.41f, -0.34f, 0.75f, -0.75f, 0.75f,
H_LINE_TO, 0.75f,
CUBIC_TO, 0.34f, 3.5f, 0, 3.16f, 0, 2.75f,
CUBIC_TO_SHORTHAND, 0.34f, 2, 0.75f, 2,
R_H_LINE_TO, 8.5f,
CLOSE
// 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 "ash/system/media/media_tray.h"
#include "ash/public/cpp/media_notification_provider.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_container.h"
#include "ash/system/tray/tray_utils.h"
#include "base/strings/string_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
namespace ash {
MediaTray::MediaTray(Shelf* shelf) : TrayBackgroundView(shelf) {
DCHECK(MediaNotificationProvider::Get());
MediaNotificationProvider::Get()->AddObserver(this);
auto icon = std::make_unique<views::ImageView>();
icon->set_tooltip_text(l10n_util::GetStringUTF16(
IDS_ASH_GLOBAL_MEDIA_CONTROLS_BUTTON_TOOLTIP_TEXT));
icon->SetImage(gfx::CreateVectorIcon(
kGlobalMediaControlsIcon,
TrayIconColor(Shell::Get()->session_controller()->GetSessionState())));
tray_container()->SetMargin(kMediaTrayPadding, 0);
icon_ = tray_container()->AddChildView(std::move(icon));
}
MediaTray::~MediaTray() {
if (MediaNotificationProvider::Get())
MediaNotificationProvider::Get()->RemoveObserver(this);
}
void MediaTray::OnNotificationListChanged() {
UpdateDisplayState();
}
void MediaTray::OnNotificationListViewSizeChanged() {}
base::string16 MediaTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(
IDS_ASH_GLOBAL_MEDIA_CONTROLS_BUTTON_TOOLTIP_TEXT);
}
void MediaTray::UpdateAfterLoginStatusChange() {
UpdateDisplayState();
PreferredSizeChanged();
}
void MediaTray::HandleLocaleChange() {
icon_->set_tooltip_text(l10n_util::GetStringUTF16(
IDS_ASH_GLOBAL_MEDIA_CONTROLS_BUTTON_TOOLTIP_TEXT));
}
void MediaTray::UpdateDisplayState() {
if (!MediaNotificationProvider::Get())
return;
SetVisiblePreferred(
MediaNotificationProvider::Get()->HasActiveNotifications() ||
MediaNotificationProvider::Get()->HasFrozenNotifications());
}
} // namespace ash
// 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 ASH_SYSTEM_MEDIA_MEDIA_TRAY_H_
#define ASH_SYSTEM_MEDIA_MEDIA_TRAY_H_
#include "ash/public/cpp/media_notification_provider_observer.h"
#include "ash/system/tray/tray_background_view.h"
namespace views {
class ImageView;
} // namespace views
namespace ash {
class Shelf;
class MediaTray : public MediaNotificationProviderObserver,
public TrayBackgroundView {
public:
explicit MediaTray(Shelf* shelf);
~MediaTray() override;
// MediaNotificationProviderObserver implementations.
void OnNotificationListChanged() override;
void OnNotificationListViewSizeChanged() override;
// TrayBackgroundview implementations.
base::string16 GetAccessibleNameForTray() override;
void UpdateAfterLoginStatusChange() override;
void HandleLocaleChange() override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override {}
void ClickedOutsideBubble() override {}
private:
void UpdateDisplayState();
// Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_;
};
} // namespace ash
#endif // ASH_SYSTEM_MEDIA_MEDIA_TRAY_H_
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ash/system/accessibility/select_to_speak_tray.h" #include "ash/system/accessibility/select_to_speak_tray.h"
#include "ash/system/holding_space/holding_space_tray.h" #include "ash/system/holding_space/holding_space_tray.h"
#include "ash/system/ime_menu/ime_menu_tray.h" #include "ash/system/ime_menu/ime_menu_tray.h"
#include "ash/system/media/media_tray.h"
#include "ash/system/overview/overview_button_tray.h" #include "ash/system/overview/overview_button_tray.h"
#include "ash/system/palette/palette_tray.h" #include "ash/system/palette/palette_tray.h"
#include "ash/system/session/logout_button_tray.h" #include "ash/system/session/logout_button_tray.h"
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "media/base/media_switches.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -114,6 +116,11 @@ void StatusAreaWidget::Initialize() { ...@@ -114,6 +116,11 @@ void StatusAreaWidget::Initialize() {
palette_tray_ = std::make_unique<PaletteTray>(shelf_); palette_tray_ = std::make_unique<PaletteTray>(shelf_);
AddTrayButton(palette_tray_.get()); AddTrayButton(palette_tray_.get());
if (base::FeatureList::IsEnabled(media::kGlobalMediaControlsForChromeOS)) {
media_tray_ = std::make_unique<MediaTray>(shelf_);
AddTrayButton(media_tray_.get());
}
unified_system_tray_ = std::make_unique<UnifiedSystemTray>(shelf_); unified_system_tray_ = std::make_unique<UnifiedSystemTray>(shelf_);
AddTrayButton(unified_system_tray_.get()); AddTrayButton(unified_system_tray_.get());
......
...@@ -33,6 +33,7 @@ class StopRecordingButtonTray; ...@@ -33,6 +33,7 @@ class StopRecordingButtonTray;
class UnifiedSystemTray; class UnifiedSystemTray;
class TrayBackgroundView; class TrayBackgroundView;
class VirtualKeyboardTray; class VirtualKeyboardTray;
class MediaTray;
// Widget showing the system tray, notification tray, and other tray views in // Widget showing the system tray, notification tray, and other tray views in
// the bottom-right of the screen. Exists separately from ShelfView/ShelfWidget // the bottom-right of the screen. Exists separately from ShelfView/ShelfWidget
...@@ -212,6 +213,7 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver, ...@@ -212,6 +213,7 @@ class ASH_EXPORT StatusAreaWidget : public SessionObserver,
std::unique_ptr<StatusAreaOverflowButtonTray> overflow_button_tray_; std::unique_ptr<StatusAreaOverflowButtonTray> overflow_button_tray_;
std::unique_ptr<OverviewButtonTray> overview_button_tray_; std::unique_ptr<OverviewButtonTray> overview_button_tray_;
std::unique_ptr<DictationButtonTray> dictation_button_tray_; std::unique_ptr<DictationButtonTray> dictation_button_tray_;
std::unique_ptr<MediaTray> media_tray_;
std::unique_ptr<UnifiedSystemTray> unified_system_tray_; std::unique_ptr<UnifiedSystemTray> unified_system_tray_;
std::unique_ptr<LogoutButtonTray> logout_button_tray_; std::unique_ptr<LogoutButtonTray> logout_button_tray_;
std::unique_ptr<PaletteTray> palette_tray_; std::unique_ptr<PaletteTray> palette_tray_;
......
...@@ -238,6 +238,9 @@ constexpr int kPrivacyScreenToastSpacing = 16; ...@@ -238,6 +238,9 @@ constexpr int kPrivacyScreenToastSpacing = 16;
constexpr gfx::Insets kHoldingSpaceContainerPadding = gfx::Insets(16); constexpr gfx::Insets kHoldingSpaceContainerPadding = gfx::Insets(16);
constexpr int kHoldingSpaceContainerSeparation = 8; constexpr int kHoldingSpaceContainerSeparation = 8;
// Constants used for media tray.
constexpr int kMediaTrayPadding = 8;
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_ #endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_
...@@ -370,6 +370,10 @@ const base::Feature kGlobalMediaControlsAutoDismiss{ ...@@ -370,6 +370,10 @@ const base::Feature kGlobalMediaControlsAutoDismiss{
const base::Feature kGlobalMediaControlsForCast{ const base::Feature kGlobalMediaControlsForCast{
"GlobalMediaControlsForCast", base::FEATURE_DISABLED_BY_DEFAULT}; "GlobalMediaControlsForCast", base::FEATURE_DISABLED_BY_DEFAULT};
// Allow Global Media Controls in system tray of CrOS.
const base::Feature kGlobalMediaControlsForChromeOS{
"GlobalMediaControlsForChromeOS", base::FEATURE_DISABLED_BY_DEFAULT};
// Allow global media controls notifications to be dragged out into overlay // Allow global media controls notifications to be dragged out into overlay
// notifications. It is no-op if kGlobalMediaControls is not enabled. // notifications. It is no-op if kGlobalMediaControls is not enabled.
const base::Feature kGlobalMediaControlsOverlayControls{ const base::Feature kGlobalMediaControlsOverlayControls{
......
...@@ -126,6 +126,7 @@ MEDIA_EXPORT extern const base::Feature kGav1VideoDecoder; ...@@ -126,6 +126,7 @@ MEDIA_EXPORT extern const base::Feature kGav1VideoDecoder;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControls; MEDIA_EXPORT extern const base::Feature kGlobalMediaControls;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsAutoDismiss; MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsAutoDismiss;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsForCast; MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsForCast;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsForChromeOS;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsOverlayControls; MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsOverlayControls;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsPictureInPicture; MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsPictureInPicture;
MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsSeamlessTransfer; MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsSeamlessTransfer;
......
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