Commit d0d0ada0 authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Rename MessageCenterNotificationManager -> NotificationUIManagerImpl

This CL renames these classes:
- MessageCenterNotificationManager -> NotificationUIManagerImpl
- MessageCenterNotificationManagerTest -> NotificationUIManagerTest
- MessageCenterNotificationsTest -> NotificationUIManagerBrowserTest
- MessageCenterNotificationManagerBrowserTest
    -> NotificationUIManagerInteractiveUITest

MessageCenterNotificationManager was confusing, because this class is
not for CrOS (which has message center) but for Win/Mac/Linux (popup only).

This CL renames this class into NotificationUIManagerImpl, because this is
an implementation of NotificationUIManager. And this also renames the
related test classes accordingly.

Bug: 869278
Test: trybots pass

Change-Id: I296f46d0b8634c95081167d6585f6f42798661f6
Reviewed-on: https://chromium-review.googlesource.com/1158669
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580955}
parent 2a9331ed
......@@ -3316,9 +3316,8 @@ jumbo_split_static_library("browser") {
"net/disk_cache_dir_policy_handler.h",
"notifications/fullscreen_notification_blocker.cc",
"notifications/fullscreen_notification_blocker.h",
"notifications/message_center_notification_manager.cc",
"notifications/message_center_notification_manager.h",
"notifications/notification_ui_manager_desktop.cc",
"notifications/notification_ui_manager_impl.cc",
"notifications/notification_ui_manager_impl.h",
"notifications/screen_lock_notification_blocker.cc",
"notifications/screen_lock_notification_blocker.h",
"platform_util.cc",
......
......@@ -15,8 +15,7 @@
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/notifications/notification_ui_manager_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_features.h"
......@@ -31,14 +30,14 @@
using message_center::Notification;
class MessageCenterNotificationsTest : public InProcessBrowserTest {
class NotificationUIManagerBrowserTest : public InProcessBrowserTest {
public:
MessageCenterNotificationsTest() {
NotificationUIManagerBrowserTest() {
feature_list_.InitAndDisableFeature(features::kNativeNotifications);
}
MessageCenterNotificationManager* manager() {
return static_cast<MessageCenterNotificationManager*>(
NotificationUIManagerImpl* manager() {
return static_cast<NotificationUIManagerImpl*>(
g_browser_process->notification_ui_manager());
}
......@@ -117,12 +116,12 @@ class MessageCenterNotificationsTest : public InProcessBrowserTest {
base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) {
IN_PROC_BROWSER_TEST_F(NotificationUIManagerBrowserTest, RetrieveBaseParts) {
EXPECT_TRUE(manager());
EXPECT_TRUE(message_center());
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) {
IN_PROC_BROWSER_TEST_F(NotificationUIManagerBrowserTest, BasicAddCancel) {
// Someone may create system notifications like "you're in multi-profile
// mode..." or something which may change the expectation.
// TODO(mukai): move this to SetUpOnMainThread() after fixing the side-effect
......@@ -134,7 +133,7 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) {
EXPECT_EQ(0u, message_center()->NotificationCount());
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) {
IN_PROC_BROWSER_TEST_F(NotificationUIManagerBrowserTest, BasicDelegate) {
TestDelegate* delegate;
manager()->Add(CreateTestNotification("hey", &delegate), profile());
manager()->CancelById("hey", NotificationUIManager::GetProfileID(profile()));
......@@ -143,7 +142,8 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) {
delegate->Release();
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) {
IN_PROC_BROWSER_TEST_F(NotificationUIManagerBrowserTest,
ButtonClickedDelegate) {
TestDelegate* delegate;
manager()->Add(CreateTestNotification("n", &delegate), profile());
const std::string notification_id =
......@@ -154,7 +154,7 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) {
delegate->Release();
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
IN_PROC_BROWSER_TEST_F(NotificationUIManagerBrowserTest,
UpdateExistingNotification) {
TestDelegate* delegate;
manager()->Add(CreateTestNotification("n", &delegate), profile());
......@@ -168,7 +168,7 @@ IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
delegate2->Release();
}
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) {
IN_PROC_BROWSER_TEST_F(NotificationUIManagerBrowserTest, VerifyKeepAlives) {
EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered(
KeepAliveOrigin::NOTIFICATION));
......
// Copyright 2014 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/notifications/notification_ui_manager.h"
#include <memory>
#include <utility>
#include "chrome/browser/notifications/message_center_notification_manager.h"
#include "ui/message_center/message_center.h"
// static
NotificationUIManager* NotificationUIManager::Create() {
// If there's no MessageCenter, there should be no NotificationUIManager to
// manage it.
if (!message_center::MessageCenter::Get())
return nullptr;
return new MessageCenterNotificationManager();
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 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/notifications/message_center_notification_manager.h"
#include "chrome/browser/notifications/notification_ui_manager_impl.h"
#include <memory>
#include <utility>
......@@ -30,7 +29,17 @@
using message_center::MessageCenter;
using message_center::NotifierId;
MessageCenterNotificationManager::MessageCenterNotificationManager()
// static
NotificationUIManager* NotificationUIManager::Create() {
// If there's no MessageCenter, there should be no NotificationUIManager to
// manage it.
if (!message_center::MessageCenter::Get())
return nullptr;
return new NotificationUIManagerImpl();
}
NotificationUIManagerImpl::NotificationUIManagerImpl()
: system_observer_(this),
popups_only_ui_controller_(std::make_unique<PopupsOnlyUiController>(
PopupsOnlyUiController::CreateDelegate())) {
......@@ -43,7 +52,7 @@ MessageCenterNotificationManager::MessageCenterNotificationManager()
std::make_unique<FullscreenNotificationBlocker>(message_center));
}
MessageCenterNotificationManager::~MessageCenterNotificationManager() {
NotificationUIManagerImpl::~NotificationUIManagerImpl() {
// The message center may have already been shut down (on Chrome OS).
if (MessageCenter::Get())
MessageCenter::Get()->RemoveObserver(this);
......@@ -54,7 +63,7 @@ MessageCenterNotificationManager::~MessageCenterNotificationManager() {
////////////////////////////////////////////////////////////////////////////////
// NotificationUIManager
void MessageCenterNotificationManager::Add(
void NotificationUIManagerImpl::Add(
const message_center::Notification& notification,
Profile* profile) {
// We won't have time to process and act on this notification.
......@@ -79,7 +88,7 @@ void MessageCenterNotificationManager::Add(
profile_notification->notification()));
}
bool MessageCenterNotificationManager::Update(
bool NotificationUIManagerImpl::Update(
const message_center::Notification& notification,
Profile* profile) {
const std::string profile_id = ProfileNotification::GetProfileNotificationId(
......@@ -126,7 +135,7 @@ bool MessageCenterNotificationManager::Update(
return false;
}
const message_center::Notification* MessageCenterNotificationManager::FindById(
const message_center::Notification* NotificationUIManagerImpl::FindById(
const std::string& id,
ProfileID profile_id) const {
std::string profile_notification_id =
......@@ -137,8 +146,8 @@ const message_center::Notification* MessageCenterNotificationManager::FindById(
return &(iter->second->notification());
}
bool MessageCenterNotificationManager::CancelById(const std::string& id,
ProfileID profile_id) {
bool NotificationUIManagerImpl::CancelById(const std::string& id,
ProfileID profile_id) {
std::string profile_notification_id =
ProfileNotification::GetProfileNotificationId(id, profile_id);
// See if this ID hasn't been shown yet.
......@@ -153,7 +162,7 @@ bool MessageCenterNotificationManager::CancelById(const std::string& id,
return true;
}
std::set<std::string> MessageCenterNotificationManager::GetAllIdsByProfile(
std::set<std::string> NotificationUIManagerImpl::GetAllIdsByProfile(
ProfileID profile_id) {
std::set<std::string> original_ids;
for (const auto& pair : profile_notifications_) {
......@@ -164,8 +173,7 @@ std::set<std::string> MessageCenterNotificationManager::GetAllIdsByProfile(
return original_ids;
}
bool MessageCenterNotificationManager::CancelAllBySourceOrigin(
const GURL& source) {
bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) {
// Same pattern as CancelById, but more complicated than the above
// because there may be multiple notifications from the same source.
bool removed = false;
......@@ -183,8 +191,7 @@ bool MessageCenterNotificationManager::CancelAllBySourceOrigin(
return removed;
}
bool MessageCenterNotificationManager::CancelAllByProfile(
ProfileID profile_id) {
bool NotificationUIManagerImpl::CancelAllByProfile(ProfileID profile_id) {
// Same pattern as CancelAllBySourceOrigin.
bool removed = false;
......@@ -201,12 +208,12 @@ bool MessageCenterNotificationManager::CancelAllByProfile(
return removed;
}
void MessageCenterNotificationManager::CancelAll() {
void NotificationUIManagerImpl::CancelAll() {
MessageCenter::Get()->RemoveAllNotifications(
false /* by_user */, message_center::MessageCenter::RemoveType::ALL);
}
void MessageCenterNotificationManager::StartShutdown() {
void NotificationUIManagerImpl::StartShutdown() {
is_shutdown_started_ = true;
CancelAll();
popups_only_ui_controller_.reset();
......@@ -215,18 +222,16 @@ void MessageCenterNotificationManager::StartShutdown() {
////////////////////////////////////////////////////////////////////////////////
// MessageCenter::Observer
void MessageCenterNotificationManager::OnNotificationRemoved(
const std::string& id,
bool by_user) {
void NotificationUIManagerImpl::OnNotificationRemoved(const std::string& id,
bool by_user) {
RemoveProfileNotification(id);
}
void MessageCenterNotificationManager::ResetUiControllerForTest() {
void NotificationUIManagerImpl::ResetUiControllerForTest() {
popups_only_ui_controller_.reset();
}
std::string
MessageCenterNotificationManager::GetMessageCenterNotificationIdForTest(
std::string NotificationUIManagerImpl::GetMessageCenterNotificationIdForTest(
const std::string& id,
Profile* profile) {
return ProfileNotification::GetProfileNotificationId(id,
......@@ -236,7 +241,7 @@ MessageCenterNotificationManager::GetMessageCenterNotificationIdForTest(
////////////////////////////////////////////////////////////////////////////////
// private
void MessageCenterNotificationManager::AddProfileNotification(
void NotificationUIManagerImpl::AddProfileNotification(
std::unique_ptr<ProfileNotification> profile_notification) {
const message_center::Notification& notification =
profile_notification->notification();
......@@ -246,7 +251,7 @@ void MessageCenterNotificationManager::AddProfileNotification(
profile_notifications_[id] = std::move(profile_notification);
}
void MessageCenterNotificationManager::RemoveProfileNotification(
void NotificationUIManagerImpl::RemoveProfileNotification(
const std::string& notification_id) {
auto it = profile_notifications_.find(notification_id);
if (it == profile_notifications_.end())
......@@ -267,7 +272,7 @@ void MessageCenterNotificationManager::RemoveProfileNotification(
profile_notifications_.erase(it);
}
ProfileNotification* MessageCenterNotificationManager::FindProfileNotification(
ProfileNotification* NotificationUIManagerImpl::FindProfileNotification(
const std::string& id) const {
auto iter = profile_notifications_.find(id);
if (iter == profile_notifications_.end())
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_
#define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_
#include <map>
#include <memory>
......@@ -29,17 +29,16 @@ namespace message_center {
class Notification;
class NotificationBlocker;
FORWARD_DECLARE_TEST(NotificationTrayTest, ManuallyCloseMessageCenter);
}
} // namespace message_center
// This class extends NotificationUIManagerImpl and delegates actual display
// This class extends NotificationUIManager and delegates actual display
// of notifications to MessageCenter, doing necessary conversions. This is only
// used on platforms that support non-native notifications.
class MessageCenterNotificationManager
: public NotificationUIManager,
public message_center::MessageCenterObserver {
class NotificationUIManagerImpl : public NotificationUIManager,
public message_center::MessageCenterObserver {
public:
MessageCenterNotificationManager();
~MessageCenterNotificationManager() override;
NotificationUIManagerImpl();
~NotificationUIManagerImpl() override;
// NotificationUIManager
void Add(const message_center::Notification& notification,
......@@ -67,7 +66,8 @@ class MessageCenterNotificationManager
// Returns the notification id which this manager will use to add to message
// center, for this combination of delegate id and profile.
std::string GetMessageCenterNotificationIdForTest(
const std::string& delegate_id, Profile* profile);
const std::string& delegate_id,
Profile* profile);
// Returns true if the popup bubbles are currently visible.
bool popups_visible() const { return popups_visible_; }
......@@ -104,7 +104,7 @@ class MessageCenterNotificationManager
// Tracks the current visibility status of the popup bubbles.
bool popups_visible_ = false;
DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager);
DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerImpl);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_
......@@ -28,11 +28,10 @@ const char kTestFileName[] = "notifications/platform_notification_service.html";
} // namespace
class MessageCenterNotificationManagerBrowserTest
: public InProcessBrowserTest {
class NotificationUIManagerInteractiveUITest : public InProcessBrowserTest {
public:
MessageCenterNotificationManagerBrowserTest() = default;
~MessageCenterNotificationManagerBrowserTest() override = default;
NotificationUIManagerInteractiveUITest() = default;
~NotificationUIManagerInteractiveUITest() override = default;
// InProcessBrowserTest overrides.
void SetUp() override {
......@@ -82,12 +81,12 @@ class MessageCenterNotificationManagerBrowserTest
std::unique_ptr<net::EmbeddedTestServer> https_server_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManagerBrowserTest);
DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerInteractiveUITest);
};
// Make sure that clicks go through on web notifications. Regression test for
// crbug.com/767868
IN_PROC_BROWSER_TEST_F(MessageCenterNotificationManagerBrowserTest,
IN_PROC_BROWSER_TEST_F(NotificationUIManagerInteractiveUITest,
CloseDisplayedPersistentNotification) {
GrantNotificationPermissionForTest();
......
......@@ -9,8 +9,8 @@
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
#include "chrome/browser/notifications/notification_test_util.h"
#include "chrome/browser/notifications/notification_ui_manager_impl.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/scoped_testing_local_state.h"
......@@ -25,9 +25,9 @@
namespace message_center {
class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
class NotificationUIManagerTest : public BrowserWithTestWindowTest {
public:
MessageCenterNotificationManagerTest() {}
NotificationUIManagerTest() {}
protected:
void SetUp() override {
......@@ -43,8 +43,8 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
MessageCenter::Shutdown();
}
MessageCenterNotificationManager* notification_manager() {
return (MessageCenterNotificationManager*)
NotificationUIManagerImpl* notification_manager() {
return (NotificationUIManagerImpl*)
g_browser_process->notification_ui_manager();
}
......@@ -64,12 +64,12 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
MessageCenter* message_center_;
};
TEST_F(MessageCenterNotificationManagerTest, SetupNotificationManager) {
TEST_F(NotificationUIManagerTest, SetupNotificationManager) {
TestingProfile profile;
notification_manager()->Add(GetANotification("test"), &profile);
}
TEST_F(MessageCenterNotificationManagerTest, AddNotificationOnShutdown) {
TEST_F(NotificationUIManagerTest, AddNotificationOnShutdown) {
TestingProfile profile;
EXPECT_TRUE(message_center()->NotificationCount() == 0);
notification_manager()->Add(GetANotification("test"), &profile);
......@@ -83,7 +83,7 @@ TEST_F(MessageCenterNotificationManagerTest, AddNotificationOnShutdown) {
EXPECT_TRUE(message_center()->NotificationCount() == 0);
}
TEST_F(MessageCenterNotificationManagerTest, UpdateNotification) {
TEST_F(NotificationUIManagerTest, UpdateNotification) {
TestingProfile profile;
EXPECT_TRUE(message_center()->NotificationCount() == 0);
notification_manager()->Add(GetANotification("test"), &profile);
......@@ -94,7 +94,7 @@ TEST_F(MessageCenterNotificationManagerTest, UpdateNotification) {
}
// Regression test for crbug.com/767868
TEST_F(MessageCenterNotificationManagerTest, GetAllIdsReturnsOriginalId) {
TEST_F(NotificationUIManagerTest, GetAllIdsReturnsOriginalId) {
TestingProfile profile;
EXPECT_TRUE(message_center()->NotificationCount() == 0);
notification_manager()->Add(GetANotification("test"), &profile);
......
......@@ -3050,7 +3050,7 @@ test("unit_tests") {
"../browser/resource_coordinator/usage_clock_unittest.cc",
# Android does not use the Message Center notification system.
"../browser/notifications/message_center_notifications_unittest.cc",
"../browser/notifications/notification_ui_manager_unittest.cc",
"../browser/platform_util_unittest.cc",
"../browser/policy/policy_path_parser_unittest.cc",
"../browser/profile_resetter/profile_resetter_unittest.cc",
......@@ -3341,7 +3341,7 @@ test("unit_tests") {
if (is_chromeos) {
sources -= [
"../browser/notifications/message_center_notifications_unittest.cc",
"../browser/notifications/notification_ui_manager_unittest.cc",
"../browser/signin/chrome_signin_status_metrics_provider_delegate_unittest.cc",
"../browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc",
......@@ -5057,11 +5057,11 @@ if (!is_android) {
} else { # ! is_chromeos
# Non-ChromeOS notifications tests.
sources += [
"../browser/notifications/message_center_notifications_browsertest.cc",
"../browser/notifications/notification_interactive_uitest.cc",
"../browser/notifications/notification_interactive_uitest_mac.mm",
"../browser/notifications/notification_interactive_uitest_support.cc",
"../browser/notifications/notification_interactive_uitest_support.h",
"../browser/notifications/notification_ui_manager_browsertest.cc",
]
}
......@@ -5150,13 +5150,13 @@ if (!is_android) {
}
if (!enable_native_notifications) {
sources += [ "../browser/notifications/message_center_notification_manager_interactive_uitest.cc" ]
sources += [ "../browser/notifications/notification_ui_manager_interactive_uitest.cc" ]
}
if (is_android) {
sources -= [
# Android does not use the message center-based Notification system.
"../browser/notifications/message_center_notifications_browsertest.cc",
"../browser/notifications/notification_ui_manager_browsertest.cc",
# TODO(peter): Enable the Notification browser tests.
"../browser/notifications/notification_interactive_uitest.cc",
......
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