Commit 4da4d1e4 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Chrome OS: remove non-native notifications codepaths.

Only support native notifications, i.e. those passed over mojo.

Some tests are permanently removed on Chrome OS. Some tests are
migrated to message_center_unittests.

Bug: 578868
Change-Id: Ibd4edcd1968c94af2d24b15ed3c1329ea7bf49b1
Reviewed-on: https://chromium-review.googlesource.com/1083937Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564928}
parent f73246ba
...@@ -2609,11 +2609,8 @@ jumbo_split_static_library("browser") { ...@@ -2609,11 +2609,8 @@ jumbo_split_static_library("browser") {
"metrics/tab_stats_tracker_win.cc", "metrics/tab_stats_tracker_win.cc",
"metrics/tab_usage_recorder.cc", "metrics/tab_usage_recorder.cc",
"metrics/tab_usage_recorder.h", "metrics/tab_usage_recorder.h",
"notifications/message_center_notification_manager.cc",
"notifications/message_center_notification_manager.h",
"notifications/notification_system_observer.cc", "notifications/notification_system_observer.cc",
"notifications/notification_system_observer.h", "notifications/notification_system_observer.h",
"notifications/notification_ui_manager_desktop.cc",
"notifications/profile_notification.cc", "notifications/profile_notification.cc",
"notifications/profile_notification.h", "notifications/profile_notification.h",
"obsolete_system/obsolete_system.h", "obsolete_system/obsolete_system.h",
...@@ -3251,6 +3248,9 @@ jumbo_split_static_library("browser") { ...@@ -3251,6 +3248,9 @@ jumbo_split_static_library("browser") {
"net/disk_cache_dir_policy_handler.h", "net/disk_cache_dir_policy_handler.h",
"notifications/fullscreen_notification_blocker.cc", "notifications/fullscreen_notification_blocker.cc",
"notifications/fullscreen_notification_blocker.h", "notifications/fullscreen_notification_blocker.h",
"notifications/message_center_notification_manager.cc",
"notifications/message_center_notification_manager.h",
"notifications/notification_ui_manager_desktop.cc",
"notifications/screen_lock_notification_blocker.cc", "notifications/screen_lock_notification_blocker.cc",
"notifications/screen_lock_notification_blocker.h", "notifications/screen_lock_notification_blocker.h",
"platform_util.cc", "platform_util.cc",
......
...@@ -1833,7 +1833,7 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -1833,7 +1833,7 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kTranslateRankerEnforcementName, flag_descriptions::kTranslateRankerEnforcementName,
flag_descriptions::kTranslateRankerEnforcementDescription, kOsAll, flag_descriptions::kTranslateRankerEnforcementDescription, kOsAll,
FEATURE_VALUE_TYPE(translate::kTranslateRankerEnforcement)}, FEATURE_VALUE_TYPE(translate::kTranslateRankerEnforcement)},
#if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) && !defined(OS_CHROMEOS)
{"enable-native-notifications", {"enable-native-notifications",
flag_descriptions::kNotificationsNativeFlagName, flag_descriptions::kNotificationsNativeFlagName,
flag_descriptions::kNotificationsNativeFlagDescription, flag_descriptions::kNotificationsNativeFlagDescription,
......
...@@ -139,7 +139,6 @@ ...@@ -139,7 +139,6 @@
#include "ui/base/idle/idle.h" #include "ui/base/idle/idle.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/message_center/message_center.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
...@@ -149,6 +148,8 @@ ...@@ -149,6 +148,8 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/ash/ash_util.h"
#else
#include "ui/message_center/message_center.h"
#endif #endif
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
...@@ -264,16 +265,9 @@ void BrowserProcessImpl::Init() { ...@@ -264,16 +265,9 @@ void BrowserProcessImpl::Init() {
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
#endif #endif
bool initialize_message_center = true; #if !defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS)
// On Chrome OS, the message center is initialized and shut down by Ash and
// should not be directly accessible to Chrome. However, ARC++ still relies
// on the existence of a MessageCenter object, so in Mash, initialize one
// here.
initialize_message_center = ash_util::IsRunningInMash();
#endif
if (initialize_message_center)
message_center::MessageCenter::Initialize(); message_center::MessageCenter::Initialize();
#endif
update_client::UpdateQueryParams::SetDelegate( update_client::UpdateQueryParams::SetDelegate(
ChromeUpdateQueryParamsDelegate::GetInstance()); ChromeUpdateQueryParamsDelegate::GetInstance());
...@@ -403,8 +397,10 @@ void BrowserProcessImpl::StartTearDown() { ...@@ -403,8 +397,10 @@ void BrowserProcessImpl::StartTearDown() {
storage_monitor::StorageMonitor::Destroy(); storage_monitor::StorageMonitor::Destroy();
#endif #endif
#if !defined(OS_CHROMEOS)
if (message_center::MessageCenter::Get()) if (message_center::MessageCenter::Get())
message_center::MessageCenter::Shutdown(); message_center::MessageCenter::Shutdown();
#endif
// The policy providers managed by |browser_policy_connector_| need to shut // The policy providers managed by |browser_policy_connector_| need to shut
// down while the IO and FILE threads are still alive. The monitoring // down while the IO and FILE threads are still alive. The monitoring
...@@ -686,19 +682,13 @@ NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { ...@@ -686,19 +682,13 @@ NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(miguelg) return NULL for MAC as well once native notifications // TODO(miguelg) return NULL for MAC as well once native notifications
// are enabled by default. // are enabled by default.
#if defined(OS_ANDROID) #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
return nullptr;
#else // !defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kNativeNotifications) ||
base::FeatureList::IsEnabled(features::kMash)) {
return nullptr; return nullptr;
} #else
#endif // defined(OS_CHROMEOS)
if (!created_notification_ui_manager_) if (!created_notification_ui_manager_)
CreateNotificationUIManager(); CreateNotificationUIManager();
return notification_ui_manager_.get(); return notification_ui_manager_.get();
#endif // !defined(OS_ANDROID) #endif
} }
NotificationPlatformBridge* BrowserProcessImpl::notification_platform_bridge() { NotificationPlatformBridge* BrowserProcessImpl::notification_platform_bridge() {
......
...@@ -98,7 +98,6 @@ ...@@ -98,7 +98,6 @@
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/net/chrome_network_delegate.h" #include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/notifications/notification_platform_bridge.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/task_manager/task_manager_interface.h" #include "chrome/browser/task_manager/task_manager_interface.h"
...@@ -676,11 +675,6 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { ...@@ -676,11 +675,6 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
chromeos::ResourceReporter::GetInstance()->StartMonitoring( chromeos::ResourceReporter::GetInstance()->StartMonitoring(
task_manager::TaskManagerInterface::GetTaskManager()); task_manager::TaskManagerInterface::GetTaskManager());
if (!base::FeatureList::IsEnabled(features::kNativeNotifications) &&
!base::FeatureList::IsEnabled(features::kMash)) {
notification_client_.reset(NotificationPlatformBridge::Create());
}
ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); ChromeBrowserMainPartsLinux::PreMainMessageLoopRun();
} }
...@@ -1116,9 +1110,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { ...@@ -1116,9 +1110,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
->browser_policy_connector_chromeos() ->browser_policy_connector_chromeos()
->PreShutdown(); ->PreShutdown();
// Close the notification client before destroying the profile manager.
notification_client_.reset();
// NOTE: Closes ash and destroys ash::Shell. // NOTE: Closes ash and destroys ash::Shell.
ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); ChromeBrowserMainPartsLinux::PostMainMessageLoopRun();
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "chrome/browser/memory/memory_kills_monitor.h" #include "chrome/browser/memory/memory_kills_monitor.h"
#include "chromeos/system/version_loader.h" #include "chromeos/system/version_loader.h"
class NotificationPlatformBridge;
class SpokenFeedbackEventRewriterDelegate; class SpokenFeedbackEventRewriterDelegate;
namespace lock_screen_apps { namespace lock_screen_apps {
...@@ -121,11 +120,6 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux { ...@@ -121,11 +120,6 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
std::unique_ptr<lock_screen_apps::StateController> std::unique_ptr<lock_screen_apps::StateController>
lock_screen_apps_state_controller_; lock_screen_apps_state_controller_;
// TODO(estade): Remove this when Chrome OS uses native notifications by
// default (as it will be instantiated elsewhere). For now it's necessary to
// send notifier settings information to Ash.
std::unique_ptr<NotificationPlatformBridge> notification_client_;
std::unique_ptr<power::ml::AdaptiveScreenBrightnessManager> std::unique_ptr<power::ml::AdaptiveScreenBrightnessManager>
adaptive_screen_brightness_manager_; adaptive_screen_brightness_manager_;
......
...@@ -48,8 +48,6 @@ class EasyUnlockNotificationControllerTest : public BrowserWithTestWindowTest { ...@@ -48,8 +48,6 @@ class EasyUnlockNotificationControllerTest : public BrowserWithTestWindowTest {
profile()); profile());
} }
// const content::TestBrowserThreadBundle thread_bundle_;
// TestMessageCenter message_center_;
std::unique_ptr<testing::StrictMock<TestableNotificationController>> std::unique_ptr<testing::StrictMock<TestableNotificationController>>
notification_controller_; notification_controller_;
std::unique_ptr<NotificationDisplayServiceTester> display_service_; std::unique_ptr<NotificationDisplayServiceTester> display_service_;
......
include_rules = [
"+ui/message_center",
]
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification.h"
#endif #endif
...@@ -419,10 +418,7 @@ AutotestPrivateGetVisibleNotificationsFunction:: ...@@ -419,10 +418,7 @@ AutotestPrivateGetVisibleNotificationsFunction::
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateGetVisibleNotificationsFunction::Run() { AutotestPrivateGetVisibleNotificationsFunction::Run() {
DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction"; DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction";
std::unique_ptr<base::ListValue> values(new base::ListValue);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kNativeNotifications) ||
base::FeatureList::IsEnabled(features::kMash)) {
auto* connection = content::ServiceManagerConnection::GetForProcess(); auto* connection = content::ServiceManagerConnection::GetForProcess();
connection->GetConnector()->BindInterface(ash::mojom::kServiceName, connection->GetConnector()->BindInterface(ash::mojom::kServiceName,
&controller_); &controller_);
...@@ -430,16 +426,9 @@ AutotestPrivateGetVisibleNotificationsFunction::Run() { ...@@ -430,16 +426,9 @@ AutotestPrivateGetVisibleNotificationsFunction::Run() {
&AutotestPrivateGetVisibleNotificationsFunction::OnGotNotifications, &AutotestPrivateGetVisibleNotificationsFunction::OnGotNotifications,
this)); this));
return RespondLater(); return RespondLater();
} #else
return RespondNow(OneArgument(std::make_unique<base::ListValue>()));
CHECK(message_center::MessageCenter::Get());
for (auto* notification :
message_center::MessageCenter::Get()->GetVisibleNotifications()) {
values->Append(MakeDictionaryFromNotification(*notification));
}
#endif #endif
return RespondNow(OneArgument(std::move(values)));
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -5,31 +5,15 @@ ...@@ -5,31 +5,15 @@
#include "chrome/browser/notifications/chrome_ash_message_center_client.h" #include "chrome/browser/notifications/chrome_ash_message_center_client.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/notifications/notification_display_service.h" #include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/notifications/notification_test_util.h" #include "chrome/browser/notifications/notification_test_util.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "ui/message_center/public/cpp/notification_delegate.h" #include "ui/message_center/public/cpp/notification_delegate.h"
namespace { namespace {
class ChromeAshMessageCenterClientBrowserTest : public InProcessBrowserTest { using ChromeAshMessageCenterClientBrowserTest = InProcessBrowserTest;
public:
ChromeAshMessageCenterClientBrowserTest() = default;
~ChromeAshMessageCenterClientBrowserTest() override = default;
// InProcessBrowserTest overrides.
void SetUpInProcessBrowserTestFixture() override {
scoped_feature_list_.InitWithFeatures({features::kNativeNotifications}, {});
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(ChromeAshMessageCenterClientBrowserTest);
};
class TestNotificationDelegate : public message_center::NotificationDelegate { class TestNotificationDelegate : public message_center::NotificationDelegate {
public: public:
......
...@@ -31,13 +31,12 @@ class NotificationBlocker; ...@@ -31,13 +31,12 @@ class NotificationBlocker;
FORWARD_DECLARE_TEST(NotificationTrayTest, ManuallyCloseMessageCenter); FORWARD_DECLARE_TEST(NotificationTrayTest, ManuallyCloseMessageCenter);
} }
#if !defined(OS_CHROMEOS)
// Implementations are platform specific. // Implementations are platform specific.
message_center::UiDelegate* CreateUiDelegate(); message_center::UiDelegate* CreateUiDelegate();
#endif
// This class extends NotificationUIManagerImpl and delegates actual display // This class extends NotificationUIManagerImpl and delegates actual display
// of notifications to MessageCenter, doing necessary conversions. // of notifications to MessageCenter, doing necessary conversions. This is only
// used on platforms that support non-native notifications.
class MessageCenterNotificationManager class MessageCenterNotificationManager
: public NotificationUIManager, : public NotificationUIManager,
public message_center::MessageCenterObserver { public message_center::MessageCenterObserver {
......
...@@ -31,37 +31,6 @@ ...@@ -31,37 +31,6 @@
using message_center::Notification; using message_center::Notification;
class TestAddObserver : public message_center::MessageCenterObserver {
public:
explicit TestAddObserver(message_center::MessageCenter* message_center)
: message_center_(message_center) {
message_center_->AddObserver(this);
}
~TestAddObserver() override { message_center_->RemoveObserver(this); }
void OnNotificationAdded(const std::string& id) override {
std::string log = logs_[id];
if (!log.empty())
log += "_";
logs_[id] = log + "add-" + id;
}
void OnNotificationUpdated(const std::string& id) override {
std::string log = logs_[id];
if (!log.empty())
log += "_";
logs_[id] = log + "update-" + id;
}
const std::string log(const std::string& id) { return logs_[id]; }
void reset_logs() { logs_.clear(); }
private:
std::map<std::string, std::string> logs_;
message_center::MessageCenter* message_center_;
};
class MessageCenterNotificationsTest : public InProcessBrowserTest { class MessageCenterNotificationsTest : public InProcessBrowserTest {
public: public:
MessageCenterNotificationsTest() { MessageCenterNotificationsTest() {
...@@ -199,125 +168,6 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ...@@ -199,125 +168,6 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
delegate2->Release(); delegate2->Release();
} }
// Notification center is only used on ChromeOS.
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, QueueWhenCenterVisible) {
TestAddObserver observer(message_center());
TestDelegate* delegate;
TestDelegate* delegate2;
manager()->Add(CreateTestNotification("n", &delegate), profile());
const std::string id_n =
manager()->GetMessageCenterNotificationIdForTest("n", profile());
message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
manager()->Add(CreateTestNotification("n2", &delegate2), profile());
const std::string id_n2 =
manager()->GetMessageCenterNotificationIdForTest("n2", profile());
// 'update-n' should happen since SetVisibility updates is_read status of n.
// TODO(mukai): fix event handling to happen update-n just once.
EXPECT_EQ(base::StringPrintf("add-%s_update-%s_update-%s",
id_n.c_str(),
id_n.c_str(),
id_n.c_str()),
observer.log(id_n));
message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT);
EXPECT_EQ(base::StringPrintf("add-%s", id_n2.c_str()), observer.log(id_n2));
delegate->Release();
delegate2->Release();
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
UpdateProgressNotificationWhenCenterVisible) {
TestAddObserver observer(message_center());
TestDelegate* delegate;
// Add a progress notification and update it while the message center
// is visible.
Notification notification = CreateTestNotification("n", &delegate);
notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
manager()->Add(notification, profile());
const std::string notification_id =
manager()->GetMessageCenterNotificationIdForTest("n", profile());
message_center()->ClickOnNotification(notification_id);
message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
observer.reset_logs();
notification.set_progress(50);
manager()->Update(notification, profile());
// Expect that the progress notification update is performed.
EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()),
observer.log(notification_id));
delegate->Release();
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
UpdateNonProgressNotificationWhenCenterVisible) {
TestAddObserver observer(message_center());
TestDelegate* delegate;
// Add a non-progress notification and update it while the message center
// is visible.
Notification notification = CreateTestNotification("n", &delegate);
manager()->Add(notification, profile());
const std::string notification_id =
manager()->GetMessageCenterNotificationIdForTest("n", profile());
message_center()->ClickOnNotification(notification_id);
message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
observer.reset_logs();
notification.set_title(base::ASCIIToUTF16("title2"));
manager()->Update(notification, profile());
// Expect that the notification update is done.
EXPECT_NE("", observer.log(notification_id));
message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT);
EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()),
observer.log(notification_id));
delegate->Release();
}
IN_PROC_BROWSER_TEST_F(
MessageCenterNotificationsTest,
UpdateNonProgressToProgressNotificationWhenCenterVisible) {
TestAddObserver observer(message_center());
TestDelegate* delegate;
// Add a non-progress notification and change the type to progress while the
// message center is visible.
Notification notification = CreateTestNotification("n", &delegate);
manager()->Add(notification, profile());
const std::string notification_id =
manager()->GetMessageCenterNotificationIdForTest("n", profile());
message_center()->ClickOnNotification(notification_id);
message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
observer.reset_logs();
notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
manager()->Update(notification, profile());
// Expect that the notification update is done.
EXPECT_NE("", observer.log(notification_id));
message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT);
EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()),
observer.log(notification_id));
delegate->Release();
}
#else // !defined(OS_CHROMEOS)
// ScopedKeepAlives are not used on Chrome OS notifications.
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) { IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) {
EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered(
KeepAliveOrigin::NOTIFICATION)); KeepAliveOrigin::NOTIFICATION));
...@@ -347,5 +197,3 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) { ...@@ -347,5 +197,3 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) {
delegate->Release(); delegate->Release();
delegate2->Release(); delegate2->Release();
} }
#endif // !defined(OS_CHROMEOS)
...@@ -33,10 +33,7 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest { ...@@ -33,10 +33,7 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
protected: protected:
void SetUp() override { void SetUp() override {
#if !defined(OS_CHROMEOS)
// Ash shell initializes the message center.
MessageCenter::Initialize(); MessageCenter::Initialize();
#endif
BrowserWithTestWindowTest::SetUp(); BrowserWithTestWindowTest::SetUp();
message_center_ = MessageCenter::Get(); message_center_ = MessageCenter::Get();
...@@ -46,10 +43,7 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest { ...@@ -46,10 +43,7 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
void TearDown() override { void TearDown() override {
BrowserWithTestWindowTest::TearDown(); BrowserWithTestWindowTest::TearDown();
#if !defined(OS_CHROMEOS)
// Shutdown the message center if we initialized it manually.
MessageCenter::Shutdown(); MessageCenter::Shutdown();
#endif
} }
MessageCenterNotificationManager* notification_manager() { MessageCenterNotificationManager* notification_manager() {
......
...@@ -71,10 +71,7 @@ NotificationPlatformBridge* GetNativeNotificationPlatformBridge() { ...@@ -71,10 +71,7 @@ NotificationPlatformBridge* GetNativeNotificationPlatformBridge() {
if (NotificationPlatformBridgeWin::NativeNotificationEnabled()) if (NotificationPlatformBridgeWin::NativeNotificationEnabled())
return g_browser_process->notification_platform_bridge(); return g_browser_process->notification_platform_bridge();
#elif defined(OS_CHROMEOS) #elif defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kNativeNotifications) ||
base::FeatureList::IsEnabled(features::kMash)) {
return g_browser_process->notification_platform_bridge(); return g_browser_process->notification_platform_bridge();
}
#else #else
if (base::FeatureList::IsEnabled(features::kNativeNotifications) && if (base::FeatureList::IsEnabled(features::kNativeNotifications) &&
g_browser_process->notification_platform_bridge()) { g_browser_process->notification_platform_bridge()) {
...@@ -287,7 +284,7 @@ void NotificationDisplayServiceImpl::ProfileLoadedCallback( ...@@ -287,7 +284,7 @@ void NotificationDisplayServiceImpl::ProfileLoadedCallback(
void NotificationDisplayServiceImpl::OnNotificationPlatformBridgeReady( void NotificationDisplayServiceImpl::OnNotificationPlatformBridgeReady(
bool success) { bool success) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) && !defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kNativeNotifications)) { if (base::FeatureList::IsEnabled(features::kNativeNotifications)) {
UMA_HISTOGRAM_BOOLEAN("Notifications.UsingNativeNotificationCenter", UMA_HISTOGRAM_BOOLEAN("Notifications.UsingNativeNotificationCenter",
success); success);
......
...@@ -46,8 +46,6 @@ class NotificationPlatformBridgeDelegate { ...@@ -46,8 +46,6 @@ class NotificationPlatformBridgeDelegate {
}; };
// A platform bridge that uses Ash's message center to display notifications. // A platform bridge that uses Ash's message center to display notifications.
// Currently under development and controlled by feature:
// --enable-features=NativeNotifications
class NotificationPlatformBridgeChromeOs class NotificationPlatformBridgeChromeOs
: public NotificationPlatformBridge, : public NotificationPlatformBridge,
public NotificationPlatformBridgeDelegate { public NotificationPlatformBridgeDelegate {
......
...@@ -21,16 +21,18 @@ namespace message_center { ...@@ -21,16 +21,18 @@ namespace message_center {
class Notification; class Notification;
} }
// This interface is used to manage the UI surfaces for desktop notifications. // This interface is used to manage the UI surfaces for non-native desktop
// There is just one instance for all profiles. This represents the middle layer // notifications (hence, this is not used by Chrome OS and is not used for
// of notification and it's aware of profile. It identifies a notification by // Windows Action Center notifications). There is just one instance for all
// the id string and a profile, hence two notifications from two different // profiles. This represents the middle layer of notification and it's aware of
// profiles, even though they may have identical ids, will not be considered the // profile. It identifies a notification by the id string and a profile, hence
// same notification. This interface will generate a new id behind the scene // two notifications from two different profiles, even though they may have
// based on the id string and the profile's characteristics for each // identical ids, will not be considered the same notification. This interface
// notification and use this new id to call lower layer MessageCenter interface // will generate a new id behind the scene based on the id string and the
// which is profile agnostic. Therefore the ids passed into this interface are // profile's characteristics for each notification and use this new id to call
// not the same as those passed into the MessageCenter interface. // lower layer MessageCenter interface which is profile agnostic. Therefore the
// ids passed into this interface are not the same as those passed into the
// MessageCenter interface.
class NotificationUIManager { class NotificationUIManager {
public: public:
// Convert a profile pointer into an opaque profile id, which can be safely // Convert a profile pointer into an opaque profile id, which can be safely
......
...@@ -398,8 +398,9 @@ const base::Feature kMultidevice{"Multidevice", ...@@ -398,8 +398,9 @@ const base::Feature kMultidevice{"Multidevice",
#endif #endif
// Enables the use of native notification centers instead of using the Message // Enables the use of native notification centers instead of using the Message
// Center for displaying the toasts. Note that OS_LINUX includes Chrome OS. // Center for displaying the toasts. The feature is hardcoded to enabled for
#if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) // Chrome OS.
#if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) && !defined(OS_CHROMEOS)
#if defined(OS_MACOSX) || defined(OS_ANDROID) || defined(OS_LINUX) #if defined(OS_MACOSX) || defined(OS_ANDROID) || defined(OS_LINUX)
const base::Feature kNativeNotifications{"NativeNotifications", const base::Feature kNativeNotifications{"NativeNotifications",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -3250,6 +3250,7 @@ test("unit_tests") { ...@@ -3250,6 +3250,7 @@ test("unit_tests") {
if (is_chromeos) { if (is_chromeos) {
sources -= [ sources -= [
"../browser/notifications/message_center_notifications_unittest.cc",
"../browser/signin/chrome_signin_status_metrics_provider_delegate_unittest.cc", "../browser/signin/chrome_signin_status_metrics_provider_delegate_unittest.cc",
"../browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc", "../browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc",
...@@ -4646,7 +4647,6 @@ if (!is_android) { ...@@ -4646,7 +4647,6 @@ if (!is_android) {
"../browser/extensions/updater/extension_cache_fake.h", "../browser/extensions/updater/extension_cache_fake.h",
"../browser/extensions/window_open_interactive_apitest.cc", "../browser/extensions/window_open_interactive_apitest.cc",
"../browser/mouse_events_interactive_uitest.cc", "../browser/mouse_events_interactive_uitest.cc",
"../browser/notifications/message_center_notifications_browsertest.cc",
"../browser/notifications/platform_notification_service_interactive_uitest.cc", "../browser/notifications/platform_notification_service_interactive_uitest.cc",
"../browser/password_manager/password_generation_interactive_uitest.cc", "../browser/password_manager/password_generation_interactive_uitest.cc",
"../browser/password_manager/password_manager_interactive_test_base.cc", "../browser/password_manager/password_manager_interactive_test_base.cc",
...@@ -4966,9 +4966,9 @@ if (!is_android) { ...@@ -4966,9 +4966,9 @@ if (!is_android) {
} }
} }
} else { # ! is_chromeos } else { # ! is_chromeos
# Non-ChromeOS notifications tests (ChromeOS does not use cross-platform # Non-ChromeOS notifications tests.
# panels).
sources += [ sources += [
"../browser/notifications/message_center_notifications_browsertest.cc",
"../browser/notifications/notification_interactive_uitest.cc", "../browser/notifications/notification_interactive_uitest.cc",
"../browser/notifications/notification_interactive_uitest_mac.mm", "../browser/notifications/notification_interactive_uitest_mac.mm",
"../browser/notifications/notification_interactive_uitest_support.cc", "../browser/notifications/notification_interactive_uitest_support.cc",
......
...@@ -289,7 +289,7 @@ TestingBrowserProcess::extension_event_router_forwarder() { ...@@ -289,7 +289,7 @@ TestingBrowserProcess::extension_event_router_forwarder() {
} }
NotificationUIManager* TestingBrowserProcess::notification_ui_manager() { NotificationUIManager* TestingBrowserProcess::notification_ui_manager() {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
if (!notification_ui_manager_.get()) if (!notification_ui_manager_.get())
notification_ui_manager_.reset(NotificationUIManager::Create()); notification_ui_manager_.reset(NotificationUIManager::Create());
return notification_ui_manager_.get(); return notification_ui_manager_.get();
......
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