Commit 2465a549 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

Revert "Message center cleanup: rename some classes to better reflect roles."

This reverts commit c7497956.

Reason for revert: suspected to consistently break Linux Tests (dbg). Example: https://uberchromegw.corp.google.com/i/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29%2832%29/builds/45886

Original change's description:
> Message center cleanup: rename some classes to better reflect roles.
> All mentions of "tray" should now be confined to ash.
> 
> - MessageCenterTray => UiController
> - MessageCenterTrayDelegate => UiDelegate
> - (Chrome's) WebNotificationTray => MessageCenterUiDelegate
> 
> Also remove some unnecessary includes.
> 
> TBR=atwilson@chromium.org
> 
> Bug: 755413
> Change-Id: Ic7774387ad313ed3ce356e5122a97dd9427699a9
> Reviewed-on: https://chromium-review.googlesource.com/758931
> Commit-Queue: Evan Stade <estade@chromium.org>
> Reviewed-by: Evan Stade <estade@chromium.org>
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Reviewed-by: Drew Wilson <atwilson@chromium.org>
> Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#516028}

TBR=stevenjb@chromium.org,atwilson@chromium.org,dewittj@chromium.org,estade@chromium.org,rsesek@chromium.org

Change-Id: Iaf1fe86a8a5e06e47dd35e3ed32ad1fa114bb260
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 755413
Reviewed-on: https://chromium-review.googlesource.com/767828Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516121}
parent 8c25a456
......@@ -13,6 +13,7 @@
#include "ui/views/widget/widget.h"
using message_center::MessageCenter;
using message_center::MessageCenterTray;
namespace ash {
......@@ -64,11 +65,10 @@ void ContentsView::ChildPreferredSizeChanged(View* child) {
// MessageCenterBubble /////////////////////////////////////////////////////////
MessageCenterBubble::MessageCenterBubble(
MessageCenter* message_center,
message_center::UiController* ui_controller)
MessageCenterBubble::MessageCenterBubble(MessageCenter* message_center,
MessageCenterTray* tray)
: message_center_(message_center),
ui_controller_(ui_controller),
tray_(tray),
max_height_(kDefaultMaxHeight) {}
MessageCenterBubble::~MessageCenterBubble() {
......@@ -108,9 +108,8 @@ void MessageCenterBubble::InitializeContents(
views::TrayBubbleView* new_bubble_view) {
bubble_view_ = new_bubble_view;
bubble_view_->GetWidget()->AddObserver(this);
message_center_view_ =
new MessageCenterView(message_center_, ui_controller_, max_height_,
initially_settings_visible_);
message_center_view_ = new MessageCenterView(
message_center_, tray_, max_height_, initially_settings_visible_);
bubble_view_->AddChildView(new ContentsView(this, message_center_view_));
message_center_view_->Init();
// Resize the content of the bubble view to the given bubble size. This is
......
......@@ -18,7 +18,7 @@ class TrayBubbleView;
namespace message_center {
class MessageCenter;
class UiController;
class MessageCenterTray;
} // namespace message_center
namespace ash {
......@@ -30,7 +30,7 @@ class MessageCenterBubble : public views::WidgetObserver,
public base::SupportsWeakPtr<MessageCenterBubble> {
public:
MessageCenterBubble(message_center::MessageCenter* message_center,
message_center::UiController* ui_controller);
message_center::MessageCenterTray* tray);
~MessageCenterBubble() override;
// Gets called when the bubble view associated with this bubble is
......@@ -62,7 +62,7 @@ class MessageCenterBubble : public views::WidgetObserver,
void UpdateBubbleView();
message_center::MessageCenter* message_center_;
message_center::UiController* ui_controller_;
message_center::MessageCenterTray* tray_;
views::TrayBubbleView* bubble_view_ = nullptr;
MessageCenterView* message_center_view_ = nullptr;
......
......@@ -17,6 +17,7 @@
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/text_constants.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/notifier_id.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/resources/grit/ui_resources.h"
......
......@@ -26,9 +26,9 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/ui_controller.h"
#include "ui/message_center/views/message_view.h"
#include "ui/message_center/views/message_view_factory.h"
#include "ui/message_center/views/notification_control_buttons_view.h"
......@@ -43,6 +43,7 @@
#include "ui/views/widget/widget.h"
using message_center::MessageCenter;
using message_center::MessageCenterTray;
using message_center::MessageView;
using message_center::Notification;
using message_center::NotificationList;
......@@ -112,13 +113,11 @@ class EmptyNotificationView : public views::View {
// MessageCenterView ///////////////////////////////////////////////////////////
MessageCenterView::MessageCenterView(
MessageCenter* message_center,
message_center::UiController* ui_controller,
int max_height,
bool initially_settings_visible)
MessageCenterView::MessageCenterView(MessageCenter* message_center,
MessageCenterTray* tray,
int max_height,
bool initially_settings_visible)
: message_center_(message_center),
ui_controller_(ui_controller),
settings_visible_(initially_settings_visible),
is_locked_(Shell::Get()->session_controller()->IsScreenLocked()) {
if (is_locked_)
......@@ -454,7 +453,7 @@ void MessageCenterView::RemoveNotification(const std::string& notification_id,
std::unique_ptr<ui::MenuModel> MessageCenterView::CreateMenuModel(
const message_center::Notification& notification) {
return ui_controller_->CreateNotificationMenuModel(notification);
return tray_->CreateNotificationMenuModel(notification);
}
void MessageCenterView::ClickOnNotificationButton(
......
......@@ -26,7 +26,7 @@ class SlideAnimation;
namespace message_center {
class MessageCenter;
class UiController;
class MessageCenterTray;
class MessageView;
} // namespace message_center
......@@ -50,7 +50,7 @@ class ASH_EXPORT MessageCenterView
public views::FocusChangeListener {
public:
MessageCenterView(message_center::MessageCenter* message_center,
message_center::UiController* ui_controller,
message_center::MessageCenterTray* tray,
int max_height,
bool initially_settings_visible);
~MessageCenterView() override;
......@@ -67,7 +67,7 @@ class ASH_EXPORT MessageCenterView
void SetSettingsVisible(bool visible);
void OnSettingsChanged();
bool settings_visible() const { return settings_visible_; }
message_center::UiController* ui_controller() { return ui_controller_; }
message_center::MessageCenterTray* tray() { return tray_; }
void SetIsClosing(bool is_closing);
......@@ -152,7 +152,7 @@ class ASH_EXPORT MessageCenterView
int GetContentHeightDuringAnimation(int width) const;
message_center::MessageCenter* message_center_;
message_center::UiController* ui_controller_;
message_center::MessageCenterTray* tray_;
// Child views.
views::ScrollView* scroller_ = nullptr;
......
......@@ -32,7 +32,7 @@ namespace ash {
using message_center::FakeMessageCenter;
using message_center::MessageCenter;
using message_center::MessageViewDelegate;
using message_center::UiController;
using message_center::MessageCenterTray;
using message_center::MessageView;
using message_center::Notification;
using message_center::NotificationList;
......@@ -125,7 +125,7 @@ class FakeMessageCenterImpl : public FakeMessageCenter {
class MockMessageCenterView : public MessageCenterView {
public:
MockMessageCenterView(MessageCenter* message_center,
UiController* ui_controller,
MessageCenterTray* tray,
int max_height,
bool initially_settings_visible);
......@@ -138,11 +138,11 @@ class MockMessageCenterView : public MessageCenterView {
};
MockMessageCenterView::MockMessageCenterView(MessageCenter* message_center,
UiController* ui_controller,
MessageCenterTray* tray,
int max_height,
bool initially_settings_visible)
: MessageCenterView(message_center,
ui_controller,
tray,
max_height,
initially_settings_visible) {}
......
......@@ -32,8 +32,8 @@
#include "ui/display/screen.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_tray_delegate.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/ui_controller.h"
#include "ui/message_center/views/message_popup_collection.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/tray_bubble_view.h"
......@@ -294,15 +294,16 @@ WebNotificationTray::WebNotificationTray(Shelf* shelf,
counter_.reset(new WebNotificationLabel(animation_container_.get(), this));
tray_container()->AddChildView(counter_.get());
message_center_ui_controller_.reset(new message_center::UiController(this));
message_center_tray_.reset(new message_center::MessageCenterTray(
this, message_center::MessageCenter::Get()));
popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf));
popup_collection_.reset(new message_center::MessagePopupCollection(
message_center(), message_center_ui_controller_.get(),
message_center(), message_center_tray_.get(),
popup_alignment_delegate_.get()));
display::Screen* screen = display::Screen::GetScreen();
popup_alignment_delegate_->StartObserving(
screen, screen->GetDisplayNearestWindow(status_area_window_));
OnMessageCenterContentsChanged();
OnMessageCenterTrayChanged();
tray_container()->SetMargin(kTrayMainAxisInset, kTrayCrossAxisInset);
}
......@@ -326,8 +327,8 @@ bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings,
if (!ShouldShowMessageCenter())
return false;
MessageCenterBubble* message_center_bubble = new MessageCenterBubble(
message_center(), message_center_ui_controller_.get());
MessageCenterBubble* message_center_bubble =
new MessageCenterBubble(message_center(), message_center_tray_.get());
// In the horizontal case, message center starts from the top of the shelf.
// In the vertical case, it starts from the bottom of WebNotificationTray.
......@@ -404,8 +405,8 @@ bool WebNotificationTray::IsMessageCenterBubbleVisible() const {
void WebNotificationTray::UpdateAfterShelfAlignmentChange() {
TrayBackgroundView::UpdateAfterShelfAlignmentChange();
// Destroy any existing bubble so that it will be rebuilt correctly.
message_center_ui_controller_->HideMessageCenterBubble();
message_center_ui_controller_->HidePopupBubble();
message_center_tray_->HideMessageCenterBubble();
message_center_tray_->HidePopupBubble();
}
void WebNotificationTray::AnchorUpdated() {
......@@ -426,17 +427,17 @@ void WebNotificationTray::AnchorUpdated() {
base::string16 WebNotificationTray::GetAccessibleNameForTray() {
return l10n_util::GetStringFUTF16Int(
IDS_MESSAGE_CENTER_ACCESSIBLE_NAME,
static_cast<int>(message_center_ui_controller_->message_center()
->NotificationCount()));
static_cast<int>(
message_center_tray_->message_center()->NotificationCount()));
}
void WebNotificationTray::HideBubbleWithView(
const views::TrayBubbleView* bubble_view) {
if (message_center_bubble() &&
bubble_view == message_center_bubble()->bubble_view()) {
message_center_ui_controller_->HideMessageCenterBubble();
message_center_tray_->HideMessageCenterBubble();
} else if (popup_collection_.get()) {
message_center_ui_controller_->HidePopupBubble();
message_center_tray_->HidePopupBubble();
}
}
......@@ -493,7 +494,7 @@ void WebNotificationTray::ExecuteCommand(int command_id, int event_flags) {
message_center()->EnterQuietModeWithExpire(expires_in);
}
void WebNotificationTray::OnMessageCenterContentsChanged() {
void WebNotificationTray::OnMessageCenterTrayChanged() {
// Do not update the tray contents directly. Multiple change events can happen
// consecutively, and calling Update in the middle of those events will show
// intermediate unread counts for a moment.
......@@ -514,7 +515,7 @@ void WebNotificationTray::UpdateTrayContent() {
// Add small icons (up to kMaximumSmallIconCount = 3).
message_center::MessageCenter* message_center =
message_center_ui_controller_->message_center();
message_center_tray_->message_center();
size_t visible_small_icon_count = 0;
for (const auto* notification : message_center->GetVisibleNotifications()) {
gfx::Image image = notification->GenerateMaskedSmallIcon(
......@@ -574,7 +575,7 @@ void WebNotificationTray::ClickedOutsideBubble() {
if (!message_center_bubble())
return;
message_center_ui_controller_->HideMessageCenterBubble();
message_center_tray_->HideMessageCenterBubble();
}
bool WebNotificationTray::PerformAction(const ui::Event& event) {
......@@ -588,12 +589,12 @@ bool WebNotificationTray::PerformAction(const ui::Event& event) {
}
void WebNotificationTray::CloseBubble() {
message_center_ui_controller_->HideMessageCenterBubble();
message_center_tray_->HideMessageCenterBubble();
}
void WebNotificationTray::ShowBubble(bool show_by_click) {
if (!IsMessageCenterBubbleVisible())
message_center_ui_controller_->ShowMessageCenterBubble(show_by_click);
message_center_tray_->ShowMessageCenterBubble(show_by_click);
}
views::TrayBubbleView* WebNotificationTray::GetBubbleView() {
......@@ -602,13 +603,13 @@ views::TrayBubbleView* WebNotificationTray::GetBubbleView() {
}
message_center::MessageCenter* WebNotificationTray::message_center() const {
return message_center_ui_controller_->message_center();
return message_center_tray_->message_center();
}
// Methods for testing
bool WebNotificationTray::IsPopupVisible() const {
return message_center_ui_controller_->popups_visible();
return message_center_tray_->popups_visible();
}
MessageCenterBubble* WebNotificationTray::GetMessageCenterBubbleForTest() {
......
......@@ -15,7 +15,8 @@
#include "base/memory/weak_ptr.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/animation/animation_container.h"
#include "ui/message_center/ui_delegate.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_tray_delegate.h"
#include "ui/views/bubble/tray_bubble_view.h"
namespace aura {
......@@ -25,7 +26,6 @@ class Window;
namespace message_center {
class MessageCenter;
class MessagePopupCollection;
class UiController;
}
namespace ash {
......@@ -45,7 +45,7 @@ class WebNotificationLabel;
// is controlled by StatusAreaWidget.
class ASH_EXPORT WebNotificationTray
: public TrayBackgroundView,
public message_center::UiDelegate,
public message_center::MessageCenterTrayDelegate,
public base::SupportsWeakPtr<WebNotificationTray>,
public ui::SimpleMenuModel::Delegate {
public:
......@@ -89,8 +89,8 @@ class ASH_EXPORT WebNotificationTray
bool ShouldEnableExtraKeyboardAccessibility() override;
void HideBubble(const views::TrayBubbleView* bubble_view) override;
// Overridden from message_center::UiDelegate.
void OnMessageCenterContentsChanged() override;
// Overridden from MessageCenterTrayDelegate.
void OnMessageCenterTrayChanged() override;
bool ShowMessageCenter(bool show_by_click) override;
void HideMessageCenter() override;
bool ShowPopups() override;
......@@ -149,7 +149,7 @@ class ASH_EXPORT WebNotificationTray
aura::Window* status_area_window_;
SystemTray* system_tray_;
std::unique_ptr<message_center::UiController> message_center_ui_controller_;
std::unique_ptr<message_center::MessageCenterTray> message_center_tray_;
std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_;
std::unique_ptr<message_center::MessagePopupCollection> popup_collection_;
std::unique_ptr<WebNotificationImage> bell_icon_;
......
......@@ -35,10 +35,10 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/notification_list.h"
#include "ui/message_center/notification_types.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/ui_controller.h"
#include "ui/message_center/views/message_popup_collection.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
......@@ -204,9 +204,9 @@ TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) {
AddNotification("test_id5");
EXPECT_TRUE(GetTray()->IsPopupVisible());
GetTray()->message_center_ui_controller_->ShowMessageCenterBubble(
GetTray()->message_center_tray_->ShowMessageCenterBubble(
false /* show_by_click */);
GetTray()->message_center_ui_controller_->HideMessageCenterBubble();
GetTray()->message_center_tray_->HideMessageCenterBubble();
EXPECT_FALSE(GetTray()->IsPopupVisible());
}
......@@ -220,9 +220,8 @@ TEST_F(WebNotificationTrayTest, ManyMessageCenterNotifications) {
std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
AddNotification(id);
}
bool shown =
GetTray()->message_center_ui_controller_->ShowMessageCenterBubble(
false /* show_by_click */);
bool shown = GetTray()->message_center_tray_->ShowMessageCenterBubble(
false /* show_by_click */);
EXPECT_TRUE(shown);
RunAllPendingInMessageLoop();
EXPECT_TRUE(GetTray()->message_center_bubble() != NULL);
......
......@@ -31,7 +31,7 @@
#include "extensions/common/extension.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "ui/message_center/fake_ui_delegate.h"
#include "ui/message_center/fake_message_center_tray_delegate.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_observer.h"
#include "ui/message_center/notification.h"
......@@ -187,7 +187,9 @@ class BackgroundContentsServiceNotificationTest
MessageCenterNotificationManager* manager =
static_cast<MessageCenterNotificationManager*>(
g_browser_process->notification_ui_manager());
manager->SetUiDelegateForTest(new message_center::FakeUiDelegate());
manager->SetMessageCenterTrayDelegateForTest(
new message_center::FakeMessageCenterTrayDelegate(
message_center::MessageCenter::Get()));
}
void TearDown() override {
......
......@@ -23,7 +23,7 @@
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/fake_ui_delegate.h"
#include "ui/message_center/fake_message_center_tray_delegate.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/notification.h"
......@@ -51,7 +51,9 @@ class HatsNotificationControllerTest : public BrowserWithTestWindowTest {
MessageCenterNotificationManager* manager =
static_cast<MessageCenterNotificationManager*>(
g_browser_process->notification_ui_manager());
manager->SetUiDelegateForTest(new message_center::FakeUiDelegate());
manager->SetMessageCenterTrayDelegateForTest(
new message_center::FakeMessageCenterTrayDelegate(
message_center::MessageCenter::Get()));
network_portal_detector::InitializeForTesting(
&mock_network_portal_detector_);
......
......@@ -18,11 +18,11 @@
#include "extensions/common/extension_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/notifier_id.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/ui_controller.h"
#if !defined(OS_CHROMEOS)
#include "chrome/browser/notifications/fullscreen_notification_blocker.h"
......@@ -49,7 +49,7 @@ MessageCenterNotificationManager::MessageCenterNotificationManager(
|| (defined(OS_LINUX) && !defined(OS_CHROMEOS))
// On Windows, Linux and Mac, the notification manager owns the tray icon and
// views.Other platforms have global ownership and Create will return NULL.
tray_.reset(CreateUiDelegate());
tray_.reset(CreateMessageCenterTrayDelegate());
#endif
}
......@@ -232,8 +232,8 @@ void MessageCenterNotificationManager::OnNotificationRemoved(
RemoveProfileNotification(id);
}
void MessageCenterNotificationManager::SetUiDelegateForTest(
message_center::UiDelegate* delegate) {
void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest(
message_center::MessageCenterTrayDelegate* delegate) {
tray_.reset(delegate);
}
......
......@@ -20,9 +20,9 @@
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_observer.h"
#include "ui/message_center/message_center_tray_delegate.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/ui_delegate.h"
class Profile;
class ProfileNotification;
......@@ -35,7 +35,7 @@ FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManuallyCloseMessageCenter);
#if !defined(OS_CHROMEOS)
// Implementations are platform specific.
message_center::UiDelegate* CreateUiDelegate();
message_center::MessageCenterTrayDelegate* CreateMessageCenterTrayDelegate();
#endif
// This class extends NotificationUIManagerImpl and delegates actual display
......@@ -69,7 +69,8 @@ class MessageCenterNotificationManager
bool by_user) override;
// Takes ownership of |delegate|.
void SetUiDelegateForTest(message_center::UiDelegate* delegate);
void SetMessageCenterTrayDelegateForTest(
message_center::MessageCenterTrayDelegate* delegate);
// Returns the notification id which this manager will use to add to message
// center, for this combination of delegate id and profile.
......@@ -80,7 +81,7 @@ class MessageCenterNotificationManager
FRIEND_TEST_ALL_PREFIXES(message_center::WebNotificationTrayTest,
ManuallyCloseMessageCenter);
std::unique_ptr<message_center::UiDelegate> tray_;
std::unique_ptr<message_center::MessageCenterTrayDelegate> tray_;
message_center::MessageCenter* message_center_; // Weak, global.
// Use a map by notification_id since this mapping is the most often used.
......
......@@ -19,12 +19,12 @@
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/fake_ui_delegate.h"
#include "ui/message_center/fake_message_center_tray_delegate.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/notification_types.h"
#include "ui/message_center/notifier_id.h"
#include "ui/message_center/ui_controller.h"
namespace message_center {
......@@ -47,8 +47,8 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
ASSERT_TRUE(profile_manager_->SetUp());
message_center_ = MessageCenter::Get();
delegate_ = new FakeUiDelegate();
notification_manager()->SetUiDelegateForTest(delegate_);
delegate_ = new FakeMessageCenterTrayDelegate(message_center_);
notification_manager()->SetMessageCenterTrayDelegateForTest(delegate_);
}
void TearDown() override {
......@@ -82,7 +82,7 @@ class MessageCenterNotificationManagerTest : public BrowserWithTestWindowTest {
private:
std::unique_ptr<TestingProfileManager> profile_manager_;
MessageCenter* message_center_;
FakeUiDelegate* delegate_;
FakeMessageCenterTrayDelegate* delegate_;
};
TEST_F(MessageCenterNotificationManagerTest, SetupNotificationManager) {
......
......@@ -1744,8 +1744,8 @@ split_static_library("ui") {
"cocoa/media_picker/desktop_media_picker_item.mm",
"cocoa/native_window_tracker_cocoa.h",
"cocoa/native_window_tracker_cocoa.mm",
"cocoa/notifications/message_center_bridge.h",
"cocoa/notifications/message_center_bridge.mm",
"cocoa/notifications/message_center_tray_bridge.h",
"cocoa/notifications/message_center_tray_bridge.mm",
"cocoa/nsmenuitem_additions.h",
"cocoa/nsmenuitem_additions.mm",
"cocoa/profiles/profile_menu_controller.h",
......@@ -3224,8 +3224,10 @@ split_static_library("ui") {
"views/frame/browser_non_client_frame_view_factory_views.cc",
"views/frame/desktop_browser_frame_aura.cc",
"views/frame/desktop_browser_frame_aura.h",
"views/message_center/popups_only_ui_delegate.cc",
"views/message_center/popups_only_ui_delegate.h",
"views/message_center/message_center_frame_view.cc",
"views/message_center/message_center_frame_view.h",
"views/message_center/web_notification_tray.cc",
"views/message_center/web_notification_tray.h",
]
}
}
......
......@@ -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_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_BRIDGE_H_
#define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_BRIDGE_H_
#ifndef CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
#define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
#import <AppKit/AppKit.h>
......@@ -14,25 +14,27 @@
#include "base/memory/weak_ptr.h"
#include "components/prefs/pref_member.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/ui_delegate.h"
#include "ui/message_center/message_center_tray_delegate.h"
@class MCPopupCollection;
namespace message_center {
class MessageCenter;
class UiController;
} // namespace message_center
class MessageCenterTray;
}
// MessageCenterBridge is the owner of all the Cocoa UI objects for the
// message_center. It bridges C++ notifications from the UiController to
// MessageCenterTrayBridge is the owner of all the Cocoa UI objects for the
// message_center. It bridges C++ notifications from the MessageCenterTray to
// the various UI objects.
class MessageCenterBridge : public message_center::UiDelegate {
class MessageCenterTrayBridge :
public message_center::MessageCenterTrayDelegate {
public:
explicit MessageCenterBridge(message_center::MessageCenter* message_center);
~MessageCenterBridge() override;
explicit MessageCenterTrayBridge(
message_center::MessageCenter* message_center);
~MessageCenterTrayBridge() override;
// message_center::UiDelegate:
void OnMessageCenterContentsChanged() override;
// message_center::MessageCenterTrayDelegate:
void OnMessageCenterTrayChanged() override;
bool ShowPopups() override;
void HidePopups() override;
bool ShowMessageCenter(bool show_by_click) override;
......@@ -42,18 +44,18 @@ class MessageCenterBridge : public message_center::UiDelegate {
message_center::MessageCenter* message_center() { return message_center_; }
private:
friend class MessageCenterBridgeTest;
friend class MessageCenterTrayBridgeTest;
// The global, singleton message center model object. Weak.
message_center::MessageCenter* message_center_;
// C++ controller for the UI (which informs |this| of changes).
std::unique_ptr<message_center::UiController> controller_;
// C++ controller for the notification tray UI.
std::unique_ptr<message_center::MessageCenterTray> tray_;
// Obj-C controller for the on-screen popup notifications.
base::scoped_nsobject<MCPopupCollection> popup_collection_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterBridge);
DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayBridge);
};
#endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_BRIDGE_H_
#endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
......@@ -2,47 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/cocoa/notifications/message_center_bridge.h"
#include "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h"
#include "base/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#import "ui/message_center/cocoa/popup_collection.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/ui_controller.h"
#include "ui/message_center/message_center_tray.h"
message_center::UiDelegate* CreateUiDelegate() {
return new MessageCenterBridge(g_browser_process->message_center());
message_center::MessageCenterTrayDelegate* CreateMessageCenterTrayDelegate() {
return new MessageCenterTrayBridge(g_browser_process->message_center());
}
MessageCenterBridge::MessageCenterBridge(
MessageCenterTrayBridge::MessageCenterTrayBridge(
message_center::MessageCenter* message_center)
: message_center_(message_center),
controller_(new message_center::UiController(this)) {}
tray_(new message_center::MessageCenterTray(this, message_center)) {}
MessageCenterBridge::~MessageCenterBridge() {}
MessageCenterTrayBridge::~MessageCenterTrayBridge() {
}
void MessageCenterBridge::OnMessageCenterContentsChanged() {}
void MessageCenterTrayBridge::OnMessageCenterTrayChanged() {
}
bool MessageCenterBridge::ShowPopups() {
bool MessageCenterTrayBridge::ShowPopups() {
popup_collection_.reset(
[[MCPopupCollection alloc] initWithMessageCenter:message_center_]);
return true;
}
void MessageCenterBridge::HidePopups() {
void MessageCenterTrayBridge::HidePopups() {
popup_collection_.reset();
}
bool MessageCenterBridge::ShowMessageCenter(bool show_by_click) {
bool MessageCenterTrayBridge::ShowMessageCenter(bool show_by_click) {
return false;
}
void MessageCenterBridge::HideMessageCenter() {}
void MessageCenterTrayBridge::HideMessageCenter() {
}
bool MessageCenterBridge::ShowNotifierSettings() {
bool MessageCenterTrayBridge::ShowNotifierSettings() {
return false;
}
file://ui/message_center/OWNERS
dewittj@chromium.org
mukai@chromium.org
# COMPONENT: UI>Notifications