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

CrOS GMC: Add interface connecting ash and browser.

This CL adds MediaNotificationProvider and
MediaNotificationProviderObserver interface serve as a connection
between ash and browser. Which will be used to send
MediaNotificationListViews and media session info from browser to ash.

Bug: 1111420

Change-Id: I276ff5d10642450ab392096c0a6db7c00a1c1c41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315092Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801489}
parent cc69a30d
...@@ -188,6 +188,9 @@ component("cpp") { ...@@ -188,6 +188,9 @@ component("cpp") {
"media_client.h", "media_client.h",
"media_controller.cc", "media_controller.cc",
"media_controller.h", "media_controller.h",
"media_notification_provider.cc",
"media_notification_provider.h",
"media_notification_provider_observer.h",
"message_center/arc_notification_constants.h", "message_center/arc_notification_constants.h",
"message_center/arc_notification_manager_base.cc", "message_center/arc_notification_manager_base.cc",
"message_center/arc_notification_manager_base.h", "message_center/arc_notification_manager_base.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.
#include "ash/public/cpp/media_notification_provider.h"
namespace ash {
namespace {
MediaNotificationProvider* g_media_notification_provider = nullptr;
} // namespace
// static
MediaNotificationProvider* MediaNotificationProvider::Get() {
return g_media_notification_provider;
}
// static
void MediaNotificationProvider::Set(MediaNotificationProvider* provider) {
g_media_notification_provider = provider;
}
} // 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_PUBLIC_CPP_MEDIA_NOTIFICATION_PROVIDER_H_
#define ASH_PUBLIC_CPP_MEDIA_NOTIFICATION_PROVIDER_H_
#include <memory>
#include "ash/public/cpp/ash_public_export.h"
namespace views {
class View;
} // namespace views
namespace ash {
class MediaNotificationProviderObserver;
// Interface used to send media notification info from browser to ash.
class ASH_PUBLIC_EXPORT MediaNotificationProvider {
public:
// Get the global instance.
static MediaNotificationProvider* Get();
// Set the global instance.
static void Set(MediaNotificationProvider* provider);
virtual void AddObserver(MediaNotificationProviderObserver* observer) = 0;
virtual void RemoveObserver(MediaNotificationProviderObserver* observer) = 0;
// True if there are non-frozen media session notifications or active cast
// notifications.
virtual bool HasActiveNotifications() = 0;
// True if there are active frozen media session notifications.
virtual bool HasFrozenNotifications() = 0;
// Returns a MediaNotificationListView populated with the correct
// MediaNotificationContainerImpls. Used to populate the dialog on the Ash
// shelf.
virtual std::unique_ptr<views::View> GetMediaNotificationListView() = 0;
// Returns a MediaNotificationContainerimplView for the active MediaSession.
// Displayed in the quick settings of the Ash shelf.
virtual std::unique_ptr<views::View> GetActiveMediaNotificationView() = 0;
protected:
virtual ~MediaNotificationProvider() = default;
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_MEDIA_NOTIFICATION_PROVIDER_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 ASH_PUBLIC_CPP_MEDIA_NOTIFICATION_PROVIDER_OBSERVER_H_
#define ASH_PUBLIC_CPP_MEDIA_NOTIFICATION_PROVIDER_OBSERVER_H_
#include "base/observer_list_types.h"
namespace ash {
// Observer for ash to be notified when notification info changed.
class MediaNotificationProviderObserver : public base::CheckedObserver {
public:
// Called when the list of notifications has chagned.
virtual void OnNotificationListChanged() = 0;
// Called when the size of the view representing the list of notifications
// has changed.
virtual void OnNotificationListViewSizeChanged() = 0;
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_MEDIA_NOTIFICATION_PROVIDER_OBSERVER_H_
...@@ -1958,6 +1958,8 @@ static_library("ui") { ...@@ -1958,6 +1958,8 @@ static_library("ui") {
"ash/login_screen_client.h", "ash/login_screen_client.h",
"ash/media_client_impl.cc", "ash/media_client_impl.cc",
"ash/media_client_impl.h", "ash/media_client_impl.h",
"ash/media_notification_provider_impl.cc",
"ash/media_notification_provider_impl.h",
"ash/multi_user/multi_profile_support.cc", "ash/multi_user/multi_profile_support.cc",
"ash/multi_user/multi_profile_support.h", "ash/multi_user/multi_profile_support.h",
"ash/multi_user/multi_user_context_menu.h", "ash/multi_user/multi_user_context_menu.h",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <utility> #include <utility>
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/media_notification_provider.h"
#include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h" #include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/ash/media_client_impl.h" #include "chrome/browser/ui/ash/media_client_impl.h"
#include "chrome/browser/ui/ash/media_notification_provider_impl.h"
#include "chrome/browser/ui/ash/network/mobile_data_notifications.h" #include "chrome/browser/ui/ash/network/mobile_data_notifications.h"
#include "chrome/browser/ui/ash/network/network_connect_delegate_chromeos.h" #include "chrome/browser/ui/ash/network/network_connect_delegate_chromeos.h"
#include "chrome/browser/ui/ash/network/network_portal_notification_controller.h" #include "chrome/browser/ui/ash/network/network_portal_notification_controller.h"
...@@ -123,6 +125,10 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { ...@@ -123,6 +125,10 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
if (chromeos::features::IsAmbientModeEnabled()) if (chromeos::features::IsAmbientModeEnabled())
ambient_client_ = std::make_unique<AmbientClientImpl>(); ambient_client_ = std::make_unique<AmbientClientImpl>();
media_notification_provider_ =
std::make_unique<MediaNotificationProviderImpl>();
ash::MediaNotificationProvider::Set(media_notification_provider_.get());
ash_shell_init_ = std::make_unique<AshShellInit>(); ash_shell_init_ = std::make_unique<AshShellInit>();
screen_orientation_delegate_ = screen_orientation_delegate_ =
...@@ -247,6 +253,8 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { ...@@ -247,6 +253,8 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
ambient_client_.reset(); ambient_client_.reset();
cast_config_controller_media_router_.reset(); cast_config_controller_media_router_.reset();
media_notification_provider_.reset();
ash::MediaNotificationProvider::Set(nullptr);
if (chromeos::NetworkConnect::IsInitialized()) if (chromeos::NetworkConnect::IsInitialized())
chromeos::NetworkConnect::Shutdown(); chromeos::NetworkConnect::Shutdown();
network_connect_delegate_.reset(); network_connect_delegate_.reset();
......
...@@ -39,6 +39,7 @@ class SystemTrayClient; ...@@ -39,6 +39,7 @@ class SystemTrayClient;
class TabletModePageBehavior; class TabletModePageBehavior;
class VpnListForwarder; class VpnListForwarder;
class WallpaperControllerClient; class WallpaperControllerClient;
class MediaNotificationProviderImpl;
#if BUILDFLAG(ENABLE_WAYLAND_SERVER) #if BUILDFLAG(ENABLE_WAYLAND_SERVER)
class ExoParts; class ExoParts;
...@@ -70,6 +71,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts { ...@@ -70,6 +71,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<NetworkConnectDelegateChromeOS> network_connect_delegate_; std::unique_ptr<NetworkConnectDelegateChromeOS> network_connect_delegate_;
std::unique_ptr<CastConfigControllerMediaRouter> std::unique_ptr<CastConfigControllerMediaRouter>
cast_config_controller_media_router_; cast_config_controller_media_router_;
std::unique_ptr<MediaNotificationProviderImpl> media_notification_provider_;
// Initialized in PreProfileInit if ash config != MASH: // Initialized in PreProfileInit if ash config != MASH:
std::unique_ptr<AshShellInit> ash_shell_init_; std::unique_ptr<AshShellInit> ash_shell_init_;
......
// 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 "chrome/browser/ui/ash/media_notification_provider_impl.h"
#include "ash/public/cpp/media_notification_provider_observer.h"
#include "ui/views/view.h"
MediaNotificationProviderImpl::MediaNotificationProviderImpl() = default;
MediaNotificationProviderImpl::~MediaNotificationProviderImpl() = default;
void MediaNotificationProviderImpl::AddObserver(
ash::MediaNotificationProviderObserver* observer) {
observers_.AddObserver(observer);
}
void MediaNotificationProviderImpl::RemoveObserver(
ash::MediaNotificationProviderObserver* observer) {
observers_.RemoveObserver(observer);
}
bool MediaNotificationProviderImpl::HasActiveNotifications() {
return false;
}
bool MediaNotificationProviderImpl::HasFrozenNotifications() {
return false;
}
std::unique_ptr<views::View>
MediaNotificationProviderImpl::GetMediaNotificationListView() {
return std::make_unique<views::View>();
}
std::unique_ptr<views::View>
MediaNotificationProviderImpl::GetActiveMediaNotificationView() {
return std::make_unique<views::View>();
}
// 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 CHROME_BROWSER_UI_ASH_MEDIA_NOTIFICATION_PROVIDER_IMPL_H_
#define CHROME_BROWSER_UI_ASH_MEDIA_NOTIFICATION_PROVIDER_IMPL_H_
#include "ash/public/cpp/media_notification_provider.h"
#include "base/observer_list.h"
class MediaNotificationProviderImpl : public ash::MediaNotificationProvider {
public:
MediaNotificationProviderImpl();
~MediaNotificationProviderImpl() override;
// MediaNotificationProvider implementations.
void AddObserver(ash::MediaNotificationProviderObserver* observer) override;
void RemoveObserver(
ash::MediaNotificationProviderObserver* observer) override;
bool HasActiveNotifications() override;
bool HasFrozenNotifications() override;
std::unique_ptr<views::View> GetMediaNotificationListView() override;
std::unique_ptr<views::View> GetActiveMediaNotificationView() override;
private:
base::ObserverList<ash::MediaNotificationProviderObserver> observers_;
};
#endif // CHROME_BROWSER_UI_ASH_MEDIA_NOTIFICATION_PROVIDER_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