Commit 6791818d authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Move UiController/UiDelegate to ash

- message_center::UiController -> ash::MessageCenterUiCiontroller
- message_center::UiDelegate -> ash::MessageCenterUiDelegate

These CL moves these classes into ash/, since they are used only from ash.

Bug: 869278
Test: trybot passes

Change-Id: I15390ba972f5c522c5a95bad8c2e1b6281ee8d24
Reviewed-on: https://chromium-review.googlesource.com/1152756Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580110}
parent 6043d5cd
...@@ -425,6 +425,9 @@ component("ash") { ...@@ -425,6 +425,9 @@ component("ash") {
"message_center/message_center_scroll_bar.cc", "message_center/message_center_scroll_bar.cc",
"message_center/message_center_scroll_bar.h", "message_center/message_center_scroll_bar.h",
"message_center/message_center_style.h", "message_center/message_center_style.h",
"message_center/message_center_ui_controller.cc",
"message_center/message_center_ui_controller.h",
"message_center/message_center_ui_delegate.h",
"message_center/message_center_view.cc", "message_center/message_center_view.cc",
"message_center/message_center_view.h", "message_center/message_center_view.h",
"message_center/message_list_view.cc", "message_center/message_list_view.cc",
...@@ -1775,6 +1778,7 @@ test("ash_unittests") { ...@@ -1775,6 +1778,7 @@ test("ash_unittests") {
"magnifier/magnifier_test_utils.cc", "magnifier/magnifier_test_utils.cc",
"magnifier/magnifier_test_utils.h", "magnifier/magnifier_test_utils.h",
"magnifier/partial_magnification_controller_unittest.cc", "magnifier/partial_magnification_controller_unittest.cc",
"message_center/message_center_ui_controller_unittest.cc",
"message_center/message_center_view_unittest.cc", "message_center/message_center_view_unittest.cc",
"message_center/message_list_view_unittest.cc", "message_center/message_list_view_unittest.cc",
"message_center/notifier_settings_view_unittest.cc", "message_center/notifier_settings_view_unittest.cc",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/message_center/ui_controller.h" #include "ash/message_center/message_center_ui_controller.h"
#include <memory> #include <memory>
...@@ -15,25 +15,25 @@ ...@@ -15,25 +15,25 @@
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_types.h" #include "ui/message_center/message_center_types.h"
#include "ui/message_center/notification_blocker.h" #include "ui/message_center/notification_blocker.h"
#include "ui/message_center/ui_delegate.h"
#include "ui/message_center/views/notification_menu_model.h" #include "ui/message_center/views/notification_menu_model.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
namespace message_center { namespace ash {
UiController::UiController(UiDelegate* delegate) MessageCenterUiController::MessageCenterUiController(
: message_center_(MessageCenter::Get()), MessageCenterUiDelegate* delegate)
: message_center_(message_center::MessageCenter::Get()),
message_center_visible_(false), message_center_visible_(false),
popups_visible_(false), popups_visible_(false),
delegate_(delegate) { delegate_(delegate) {
message_center_->AddObserver(this); message_center_->AddObserver(this);
} }
UiController::~UiController() { MessageCenterUiController::~MessageCenterUiController() {
message_center_->RemoveObserver(this); message_center_->RemoveObserver(this);
} }
bool UiController::ShowMessageCenterBubble(bool show_by_click) { bool MessageCenterUiController::ShowMessageCenterBubble(bool show_by_click) {
if (message_center_visible_) if (message_center_visible_)
return true; return true;
...@@ -41,13 +41,13 @@ bool UiController::ShowMessageCenterBubble(bool show_by_click) { ...@@ -41,13 +41,13 @@ bool UiController::ShowMessageCenterBubble(bool show_by_click) {
message_center_visible_ = delegate_->ShowMessageCenter(show_by_click); message_center_visible_ = delegate_->ShowMessageCenter(show_by_click);
if (message_center_visible_) { if (message_center_visible_) {
message_center_->SetVisibility(VISIBILITY_MESSAGE_CENTER); message_center_->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
return message_center_visible_; return message_center_visible_;
} }
bool UiController::HideMessageCenterBubble() { bool MessageCenterUiController::HideMessageCenterBubble() {
if (!message_center_visible_) if (!message_center_visible_)
return false; return false;
...@@ -57,11 +57,11 @@ bool UiController::HideMessageCenterBubble() { ...@@ -57,11 +57,11 @@ bool UiController::HideMessageCenterBubble() {
return true; return true;
} }
void UiController::MarkMessageCenterHidden() { void MessageCenterUiController::MarkMessageCenterHidden() {
if (!message_center_visible_) if (!message_center_visible_)
return; return;
message_center_visible_ = false; message_center_visible_ = false;
message_center_->SetVisibility(VISIBILITY_TRANSIENT); message_center_->SetVisibility(message_center::VISIBILITY_TRANSIENT);
// Some notifications (like system ones) should appear as popups again // Some notifications (like system ones) should appear as popups again
// after the message center is closed. // after the message center is closed.
...@@ -73,7 +73,7 @@ void UiController::MarkMessageCenterHidden() { ...@@ -73,7 +73,7 @@ void UiController::MarkMessageCenterHidden() {
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
void UiController::ShowPopupBubble() { void MessageCenterUiController::ShowPopupBubble() {
if (message_center_visible_) if (message_center_visible_)
return; return;
...@@ -90,7 +90,7 @@ void UiController::ShowPopupBubble() { ...@@ -90,7 +90,7 @@ void UiController::ShowPopupBubble() {
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
bool UiController::HidePopupBubble() { bool MessageCenterUiController::HidePopupBubble() {
if (!popups_visible_) if (!popups_visible_)
return false; return false;
HidePopupBubbleInternal(); HidePopupBubbleInternal();
...@@ -99,7 +99,7 @@ bool UiController::HidePopupBubble() { ...@@ -99,7 +99,7 @@ bool UiController::HidePopupBubble() {
return true; return true;
} }
void UiController::HidePopupBubbleInternal() { void MessageCenterUiController::HidePopupBubbleInternal() {
if (!popups_visible_) if (!popups_visible_)
return; return;
...@@ -107,30 +107,33 @@ void UiController::HidePopupBubbleInternal() { ...@@ -107,30 +107,33 @@ void UiController::HidePopupBubbleInternal() {
popups_visible_ = false; popups_visible_ = false;
} }
void UiController::ShowNotifierSettingsBubble() { void MessageCenterUiController::ShowNotifierSettingsBubble() {
if (popups_visible_) if (popups_visible_)
HidePopupBubbleInternal(); HidePopupBubbleInternal();
message_center_visible_ = delegate_->ShowNotifierSettings(); message_center_visible_ = delegate_->ShowNotifierSettings();
message_center_->SetVisibility(VISIBILITY_SETTINGS); message_center_->SetVisibility(message_center::VISIBILITY_SETTINGS);
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
void UiController::OnNotificationAdded(const std::string& notification_id) { void MessageCenterUiController::OnNotificationAdded(
const std::string& notification_id) {
OnMessageCenterChanged(); OnMessageCenterChanged();
} }
void UiController::OnNotificationRemoved(const std::string& notification_id, void MessageCenterUiController::OnNotificationRemoved(
const std::string& notification_id,
bool by_user) { bool by_user) {
OnMessageCenterChanged(); OnMessageCenterChanged();
} }
void UiController::OnNotificationUpdated(const std::string& notification_id) { void MessageCenterUiController::OnNotificationUpdated(
const std::string& notification_id) {
OnMessageCenterChanged(); OnMessageCenterChanged();
} }
void UiController::OnNotificationClicked( void MessageCenterUiController::OnNotificationClicked(
const std::string& notification_id, const std::string& notification_id,
const base::Optional<int>& button_index, const base::Optional<int>& button_index,
const base::Optional<base::string16>& reply) { const base::Optional<base::string16>& reply) {
...@@ -138,25 +141,27 @@ void UiController::OnNotificationClicked( ...@@ -138,25 +141,27 @@ void UiController::OnNotificationClicked(
OnMessageCenterChanged(); OnMessageCenterChanged();
} }
void UiController::OnNotificationSettingsClicked(bool handled) { void MessageCenterUiController::OnNotificationSettingsClicked(bool handled) {
if (!handled) if (!handled)
ShowNotifierSettingsBubble(); ShowNotifierSettingsBubble();
} }
void UiController::OnNotificationDisplayed(const std::string& notification_id, void MessageCenterUiController::OnNotificationDisplayed(
const DisplaySource source) { const std::string& notification_id,
const message_center::DisplaySource source) {
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
void UiController::OnQuietModeChanged(bool in_quiet_mode) { void MessageCenterUiController::OnQuietModeChanged(bool in_quiet_mode) {
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
void UiController::OnBlockingStateChanged(NotificationBlocker* blocker) { void MessageCenterUiController::OnBlockingStateChanged(
message_center::NotificationBlocker* blocker) {
OnMessageCenterChanged(); OnMessageCenterChanged();
} }
void UiController::OnMessageCenterChanged() { void MessageCenterUiController::OnMessageCenterChanged() {
if (hide_on_last_notification_ && message_center_visible_ && if (hide_on_last_notification_ && message_center_visible_ &&
message_center_->NotificationCount() == 0) { message_center_->NotificationCount() == 0) {
HideMessageCenterBubble(); HideMessageCenterBubble();
...@@ -171,8 +176,8 @@ void UiController::OnMessageCenterChanged() { ...@@ -171,8 +176,8 @@ void UiController::OnMessageCenterChanged() {
NotifyUiControllerChanged(); NotifyUiControllerChanged();
} }
void UiController::NotifyUiControllerChanged() { void MessageCenterUiController::NotifyUiControllerChanged() {
delegate_->OnMessageCenterContentsChanged(); delegate_->OnMessageCenterContentsChanged();
} }
} // namespace message_center } // namespace ash
...@@ -2,29 +2,33 @@ ...@@ -2,29 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_MESSAGE_CENTER_UI_CONTROLLER_H_ #ifndef ASH_MESSAGE_CENTER_MESSAGE_CENTER_UI_CONTROLLER_H_
#define UI_MESSAGE_CENTER_UI_CONTROLLER_H_ #define ASH_MESSAGE_CENTER_MESSAGE_CENTER_UI_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/message_center/message_center_ui_delegate.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "ui/message_center/message_center_export.h" #include "ui/message_center/message_center_export.h"
#include "ui/message_center/message_center_observer.h" #include "ui/message_center/message_center_observer.h"
#include "ui/message_center/public/cpp/notifier_id.h" #include "ui/message_center/public/cpp/notifier_id.h"
#include "ui/message_center/ui_delegate.h"
namespace message_center { namespace message_center {
class MessageCenter; class MessageCenter;
}
namespace ash {
// Class that observes a MessageCenter and reacts to changes in the list of // Class that observes a MessageCenter and reacts to changes in the list of
// notifications. Manages the popup and message center bubbles. Tells the // notifications. Manages the popup and message center bubbles. Tells the
// UiDelegate when the tray is changed, as well as when bubbles are shown and // UiDelegate when the tray is changed, as well as when bubbles are shown and
// hidden. // hidden.
class MESSAGE_CENTER_EXPORT UiController : public MessageCenterObserver { class ASH_EXPORT MessageCenterUiController
: public message_center::MessageCenterObserver {
public: public:
explicit UiController(UiDelegate* delegate); explicit MessageCenterUiController(MessageCenterUiDelegate* delegate);
~UiController() override; ~MessageCenterUiController() override;
// Shows or updates the message center bubble and hides the popup bubble. Set // Shows or updates the message center bubble and hides the popup bubble. Set
// |show_by_click| to true if bubble is shown by mouse or gesture click. // |show_by_click| to true if bubble is shown by mouse or gesture click.
...@@ -51,9 +55,11 @@ class MESSAGE_CENTER_EXPORT UiController : public MessageCenterObserver { ...@@ -51,9 +55,11 @@ class MESSAGE_CENTER_EXPORT UiController : public MessageCenterObserver {
bool message_center_visible() { return message_center_visible_; } bool message_center_visible() { return message_center_visible_; }
bool popups_visible() { return popups_visible_; } bool popups_visible() { return popups_visible_; }
UiDelegate* delegate() { return delegate_; } MessageCenterUiDelegate* delegate() { return delegate_; }
const MessageCenter* message_center() const { return message_center_; } const message_center::MessageCenter* message_center() const {
MessageCenter* message_center() { return message_center_; } return message_center_;
}
message_center::MessageCenter* message_center() { return message_center_; }
void set_hide_on_last_notification(bool hide_on_last_notification) { void set_hide_on_last_notification(bool hide_on_last_notification) {
hide_on_last_notification_ = hide_on_last_notification; hide_on_last_notification_ = hide_on_last_notification;
} }
...@@ -68,27 +74,29 @@ class MESSAGE_CENTER_EXPORT UiController : public MessageCenterObserver { ...@@ -68,27 +74,29 @@ class MESSAGE_CENTER_EXPORT UiController : public MessageCenterObserver {
const base::Optional<int>& button_index, const base::Optional<int>& button_index,
const base::Optional<base::string16>& reply) override; const base::Optional<base::string16>& reply) override;
void OnNotificationSettingsClicked(bool handled) override; void OnNotificationSettingsClicked(bool handled) override;
void OnNotificationDisplayed(const std::string& notification_id, void OnNotificationDisplayed(
const DisplaySource source) override; const std::string& notification_id,
const message_center::DisplaySource source) override;
void OnQuietModeChanged(bool in_quiet_mode) override; void OnQuietModeChanged(bool in_quiet_mode) override;
void OnBlockingStateChanged(NotificationBlocker* blocker) override; void OnBlockingStateChanged(
message_center::NotificationBlocker* blocker) override;
private: private:
void OnMessageCenterChanged(); void OnMessageCenterChanged();
void NotifyUiControllerChanged(); void NotifyUiControllerChanged();
void HidePopupBubbleInternal(); void HidePopupBubbleInternal();
MessageCenter* message_center_; message_center::MessageCenter* const message_center_;
bool message_center_visible_ = false; bool message_center_visible_ = false;
bool popups_visible_ = false; bool popups_visible_ = false;
UiDelegate* delegate_; MessageCenterUiDelegate* const delegate_;
// Set true to hide MessageCenterView when the last notification is dismissed. // Set true to hide MessageCenterView when the last notification is dismissed.
bool hide_on_last_notification_ = true; bool hide_on_last_notification_ = true;
DISALLOW_COPY_AND_ASSIGN(UiController); DISALLOW_COPY_AND_ASSIGN(MessageCenterUiController);
}; };
} // namespace message_center } // namespace ash
#endif // UI_MESSAGE_CENTER_UI_CONTROLLER_H_ #endif // ASH_MESSAGE_CENTER_MESSAGE_CENTER_UI_CONTROLLER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/message_center/ui_controller.h" #include "ash/message_center/message_center_ui_controller.h"
#include <utility> #include <utility>
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
using base::ASCIIToUTF16; using base::ASCIIToUTF16;
namespace message_center { namespace ash {
namespace { namespace {
class TestNotificationDelegate : public NotificationDelegate { class TestNotificationDelegate : public message_center::NotificationDelegate {
public: public:
TestNotificationDelegate() = default; TestNotificationDelegate() = default;
...@@ -29,7 +29,7 @@ class TestNotificationDelegate : public NotificationDelegate { ...@@ -29,7 +29,7 @@ class TestNotificationDelegate : public NotificationDelegate {
DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate); DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate);
}; };
class MockDelegate : public UiDelegate { class MockDelegate : public MessageCenterUiDelegate {
public: public:
MockDelegate() {} MockDelegate() {}
~MockDelegate() override {} ~MockDelegate() override {}
...@@ -51,51 +51,58 @@ class MockDelegate : public UiDelegate { ...@@ -51,51 +51,58 @@ class MockDelegate : public UiDelegate {
} // namespace } // namespace
class UiControllerTest : public testing::Test { class MessageCenterUiControllerTest : public testing::Test {
public: public:
UiControllerTest() {} MessageCenterUiControllerTest() {}
~UiControllerTest() override {} ~MessageCenterUiControllerTest() override {}
void SetUp() override { void SetUp() override {
MessageCenter::Initialize(); message_center::MessageCenter::Initialize();
delegate_.reset(new MockDelegate); delegate_.reset(new MockDelegate);
message_center_ = MessageCenter::Get(); message_center_ = message_center::MessageCenter::Get();
ui_controller_.reset(new UiController(delegate_.get())); ui_controller_.reset(new MessageCenterUiController(delegate_.get()));
} }
void TearDown() override { void TearDown() override {
ui_controller_.reset(); ui_controller_.reset();
delegate_.reset(); delegate_.reset();
message_center_ = NULL; message_center_ = NULL;
MessageCenter::Shutdown(); message_center::MessageCenter::Shutdown();
} }
protected: protected:
NotifierId DummyNotifierId() { return NotifierId(); } message_center::NotifierId DummyNotifierId() {
return message_center::NotifierId();
}
Notification* AddNotification(const std::string& id) { message_center::Notification* AddNotification(const std::string& id) {
return AddNotification(id, DummyNotifierId()); return AddNotification(id, DummyNotifierId());
} }
Notification* AddNotification(const std::string& id, NotifierId notifier_id) { message_center::Notification* AddNotification(
std::unique_ptr<Notification> notification(new Notification( const std::string& id,
NOTIFICATION_TYPE_SIMPLE, id, ASCIIToUTF16("Test Web Notification"), message_center::NotifierId notifier_id) {
std::unique_ptr<message_center::Notification> notification(
new message_center::Notification(
message_center::NOTIFICATION_TYPE_SIMPLE, id,
ASCIIToUTF16("Test Web Notification"),
ASCIIToUTF16("Notification message body."), gfx::Image(), ASCIIToUTF16("Notification message body."), gfx::Image(),
ASCIIToUTF16("www.test.org"), GURL(), notifier_id, ASCIIToUTF16("www.test.org"), GURL(), notifier_id,
RichNotificationData(), new TestNotificationDelegate())); message_center::RichNotificationData(),
Notification* notification_ptr = notification.get(); new TestNotificationDelegate()));
message_center::Notification* notification_ptr = notification.get();
message_center_->AddNotification(std::move(notification)); message_center_->AddNotification(std::move(notification));
return notification_ptr; return notification_ptr;
} }
std::unique_ptr<MockDelegate> delegate_; std::unique_ptr<MockDelegate> delegate_;
std::unique_ptr<UiController> ui_controller_; std::unique_ptr<MessageCenterUiController> ui_controller_;
MessageCenter* message_center_; message_center::MessageCenter* message_center_;
private: private:
DISALLOW_COPY_AND_ASSIGN(UiControllerTest); DISALLOW_COPY_AND_ASSIGN(MessageCenterUiControllerTest);
}; };
TEST_F(UiControllerTest, BasicMessageCenter) { TEST_F(MessageCenterUiControllerTest, BasicMessageCenter) {
ASSERT_FALSE(ui_controller_->popups_visible()); ASSERT_FALSE(ui_controller_->popups_visible());
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
...@@ -122,7 +129,7 @@ TEST_F(UiControllerTest, BasicMessageCenter) { ...@@ -122,7 +129,7 @@ TEST_F(UiControllerTest, BasicMessageCenter) {
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
} }
TEST_F(UiControllerTest, BasicPopup) { TEST_F(MessageCenterUiControllerTest, BasicPopup) {
ASSERT_FALSE(ui_controller_->popups_visible()); ASSERT_FALSE(ui_controller_->popups_visible());
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
...@@ -142,7 +149,7 @@ TEST_F(UiControllerTest, BasicPopup) { ...@@ -142,7 +149,7 @@ TEST_F(UiControllerTest, BasicPopup) {
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
} }
TEST_F(UiControllerTest, MessageCenterClosesPopups) { TEST_F(MessageCenterUiControllerTest, MessageCenterClosesPopups) {
ASSERT_FALSE(ui_controller_->popups_visible()); ASSERT_FALSE(ui_controller_->popups_visible());
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
...@@ -178,16 +185,19 @@ TEST_F(UiControllerTest, MessageCenterClosesPopups) { ...@@ -178,16 +185,19 @@ TEST_F(UiControllerTest, MessageCenterClosesPopups) {
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
} }
TEST_F(UiControllerTest, MessageCenterReopenPopupsForSystemPriority) { TEST_F(MessageCenterUiControllerTest,
MessageCenterReopenPopupsForSystemPriority) {
ASSERT_FALSE(ui_controller_->popups_visible()); ASSERT_FALSE(ui_controller_->popups_visible());
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
std::unique_ptr<Notification> notification(new Notification( std::unique_ptr<message_center::Notification> notification(
NOTIFICATION_TYPE_SIMPLE, "MessageCenterReopnPopupsForSystemPriority", new message_center::Notification(
message_center::NOTIFICATION_TYPE_SIMPLE,
"MessageCenterReopnPopupsForSystemPriority",
ASCIIToUTF16("Test Web Notification"), ASCIIToUTF16("Test Web Notification"),
ASCIIToUTF16("Notification message body."), gfx::Image(), ASCIIToUTF16("Notification message body."), gfx::Image(),
ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(), ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(),
RichNotificationData(), NULL /* delegate */)); message_center::RichNotificationData(), NULL /* delegate */));
notification->SetSystemPriority(); notification->SetSystemPriority();
message_center_->AddNotification(std::move(notification)); message_center_->AddNotification(std::move(notification));
...@@ -207,7 +217,7 @@ TEST_F(UiControllerTest, MessageCenterReopenPopupsForSystemPriority) { ...@@ -207,7 +217,7 @@ TEST_F(UiControllerTest, MessageCenterReopenPopupsForSystemPriority) {
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
} }
TEST_F(UiControllerTest, ShowBubbleFails) { TEST_F(MessageCenterUiControllerTest, ShowBubbleFails) {
// Now the delegate will signal that it was unable to show a bubble. // Now the delegate will signal that it was unable to show a bubble.
delegate_->show_popups_success_ = false; delegate_->show_popups_success_ = false;
delegate_->show_message_center_success_ = false; delegate_->show_message_center_success_ = false;
...@@ -245,4 +255,4 @@ TEST_F(UiControllerTest, ShowBubbleFails) { ...@@ -245,4 +255,4 @@ TEST_F(UiControllerTest, ShowBubbleFails) {
ASSERT_FALSE(ui_controller_->message_center_visible()); ASSERT_FALSE(ui_controller_->message_center_visible());
} }
} // namespace message_center } // namespace ash
...@@ -2,19 +2,17 @@ ...@@ -2,19 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_MESSAGE_CENTER_UI_DELEGATE_H_ #ifndef ASH_MESSAGE_CENTER_MESSAGE_CENTER_UI_DELEGATE_H_
#define UI_MESSAGE_CENTER_UI_DELEGATE_H_ #define ASH_MESSAGE_CENTER_MESSAGE_CENTER_UI_DELEGATE_H_
#include "ui/message_center/message_center_export.h" namespace ash {
namespace message_center {
// A UiDelegate class is responsible for managing the various UI surfaces // A UiDelegate class is responsible for managing the various UI surfaces
// (MessageCenter and popups) as notifications are added and updated. // (MessageCenter and popups) as notifications are added and updated.
// Implementations are platform specific. // Implementations are platform specific.
class MESSAGE_CENTER_EXPORT UiDelegate { class MessageCenterUiDelegate {
public: public:
virtual ~UiDelegate(){}; virtual ~MessageCenterUiDelegate(){};
// Called whenever a change to the visible UI has occurred. // Called whenever a change to the visible UI has occurred.
virtual void OnMessageCenterContentsChanged() = 0; virtual void OnMessageCenterContentsChanged() = 0;
...@@ -39,6 +37,6 @@ class MESSAGE_CENTER_EXPORT UiDelegate { ...@@ -39,6 +37,6 @@ class MESSAGE_CENTER_EXPORT UiDelegate {
virtual bool ShowNotifierSettings() = 0; virtual bool ShowNotifierSettings() = 0;
}; };
} // namespace message_center } // namespace ash
#endif // UI_MESSAGE_CENTER_UI_DELEGATE_H_ #endif // ASH_MESSAGE_CENTER_MESSAGE_CENTER_UI_DELEGATE_H_
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/message_center/message_center_bubble.h" #include "ash/message_center/message_center_bubble.h"
#include "ash/message_center/message_center_ui_controller.h"
#include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/message_center_constants.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/message_center/views/message_popup_collection.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/tray_bubble_view.h" #include "ui/views/bubble/tray_bubble_view.h"
...@@ -317,7 +317,7 @@ NotificationTray::NotificationTray(Shelf* shelf, ...@@ -317,7 +317,7 @@ NotificationTray::NotificationTray(Shelf* shelf,
tray_container()->AddChildView(counter_.get()); tray_container()->AddChildView(counter_.get());
message_center_ui_controller_ = message_center_ui_controller_ =
std::make_unique<message_center::UiController>(this); std::make_unique<MessageCenterUiController>(this);
popup_alignment_delegate_ = popup_alignment_delegate_ =
std::make_unique<AshPopupAlignmentDelegate>(shelf); std::make_unique<AshPopupAlignmentDelegate>(shelf);
popup_collection_ = std::make_unique<message_center::MessagePopupCollection>( popup_collection_ = std::make_unique<message_center::MessagePopupCollection>(
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/login_status.h" #include "ash/login_status.h"
#include "ash/message_center/message_center_ui_delegate.h"
#include "ash/system/tray/tray_background_view.h" #include "ash/system/tray/tray_background_view.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "ui/gfx/animation/animation_container.h" #include "ui/gfx/animation/animation_container.h"
#include "ui/message_center/ui_delegate.h"
#include "ui/views/bubble/tray_bubble_view.h" #include "ui/views/bubble/tray_bubble_view.h"
namespace aura { namespace aura {
...@@ -24,12 +24,12 @@ class Window; ...@@ -24,12 +24,12 @@ class Window;
namespace message_center { namespace message_center {
class MessageCenter; class MessageCenter;
class MessagePopupCollection; class MessagePopupCollection;
class UiController;
} // namespace message_center } // namespace message_center
namespace ash { namespace ash {
class AshPopupAlignmentDelegate; class AshPopupAlignmentDelegate;
class MessageCenterBubble; class MessageCenterBubble;
class MessageCenterUiController;
class NotificationBubbleWrapper; class NotificationBubbleWrapper;
class NotificationTrayImageSubview; class NotificationTrayImageSubview;
class NotificationTrayLabelSubview; class NotificationTrayLabelSubview;
...@@ -39,7 +39,7 @@ class NotificationTrayLabelSubview; ...@@ -39,7 +39,7 @@ class NotificationTrayLabelSubview;
// notification list. This class contains the Ash specific tray implementation. // notification list. This class contains the Ash specific tray implementation.
class ASH_EXPORT NotificationTray class ASH_EXPORT NotificationTray
: public TrayBackgroundView, : public TrayBackgroundView,
public message_center::UiDelegate, public MessageCenterUiDelegate,
public base::SupportsWeakPtr<NotificationTray> { public base::SupportsWeakPtr<NotificationTray> {
public: public:
NotificationTray(Shelf* shelf, aura::Window* status_area_window); NotificationTray(Shelf* shelf, aura::Window* status_area_window);
...@@ -128,7 +128,7 @@ class ASH_EXPORT NotificationTray ...@@ -128,7 +128,7 @@ class ASH_EXPORT NotificationTray
MessageCenterBubble* GetMessageCenterBubbleForTest(); MessageCenterBubble* GetMessageCenterBubbleForTest();
aura::Window* status_area_window_; aura::Window* status_area_window_;
std::unique_ptr<message_center::UiController> message_center_ui_controller_; std::unique_ptr<MessageCenterUiController> message_center_ui_controller_;
std::unique_ptr<NotificationBubbleWrapper> message_center_bubble_; std::unique_ptr<NotificationBubbleWrapper> message_center_bubble_;
std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; std::unique_ptr<message_center::MessagePopupCollection> popup_collection_;
std::unique_ptr<views::View> bell_icon_; std::unique_ptr<views::View> bell_icon_;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include "ash/message_center/message_center_bubble.h" #include "ash/message_center/message_center_bubble.h"
#include "ash/message_center/message_center_ui_controller.h"
#include "ash/message_center/message_center_view.h" #include "ash/message_center/message_center_view.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/config.h" #include "ash/public/cpp/config.h"
...@@ -41,7 +42,6 @@ ...@@ -41,7 +42,6 @@
#include "ui/message_center/notification_list.h" #include "ui/message_center/notification_list.h"
#include "ui/message_center/public/cpp/message_center_constants.h" #include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/public/cpp/notification_types.h" #include "ui/message_center/public/cpp/notification_types.h"
#include "ui/message_center/ui_controller.h"
#include "ui/message_center/views/message_popup_collection.h" #include "ui/message_center/views/message_popup_collection.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "ash/system/unified/unified_system_tray.h" #include "ash/system/unified/unified_system_tray.h"
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/message_center/message_center_ui_controller.h"
#include "ash/message_center/message_center_ui_delegate.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/date/date_view.h" #include "ash/system/date/date_view.h"
...@@ -27,18 +29,16 @@ ...@@ -27,18 +29,16 @@
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/ui_controller.h"
#include "ui/message_center/ui_delegate.h"
#include "ui/message_center/views/message_popup_collection.h" #include "ui/message_center/views/message_popup_collection.h"
namespace ash { namespace ash {
class UnifiedSystemTray::UiDelegate : public message_center::UiDelegate { class UnifiedSystemTray::UiDelegate : public MessageCenterUiDelegate {
public: public:
UiDelegate(UnifiedSystemTray* owner); UiDelegate(UnifiedSystemTray* owner);
~UiDelegate() override; ~UiDelegate() override;
// message_center::UiDelegate: // MessageCenterUiDelegate:
void OnMessageCenterContentsChanged() override; void OnMessageCenterContentsChanged() override;
bool ShowPopups() override; bool ShowPopups() override;
void HidePopups() override; void HidePopups() override;
...@@ -46,14 +46,14 @@ class UnifiedSystemTray::UiDelegate : public message_center::UiDelegate { ...@@ -46,14 +46,14 @@ class UnifiedSystemTray::UiDelegate : public message_center::UiDelegate {
void HideMessageCenter() override; void HideMessageCenter() override;
bool ShowNotifierSettings() override; bool ShowNotifierSettings() override;
message_center::UiController* ui_controller() { return ui_controller_.get(); } MessageCenterUiController* ui_controller() { return ui_controller_.get(); }
void SetTrayBubbleHeight(int height) { void SetTrayBubbleHeight(int height) {
popup_alignment_delegate_->SetTrayBubbleHeight(height); popup_alignment_delegate_->SetTrayBubbleHeight(height);
} }
private: private:
std::unique_ptr<message_center::UiController> ui_controller_; std::unique_ptr<MessageCenterUiController> ui_controller_;
std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_;
std::unique_ptr<message_center::MessagePopupCollection> std::unique_ptr<message_center::MessagePopupCollection>
message_popup_collection_; message_popup_collection_;
...@@ -65,7 +65,7 @@ class UnifiedSystemTray::UiDelegate : public message_center::UiDelegate { ...@@ -65,7 +65,7 @@ class UnifiedSystemTray::UiDelegate : public message_center::UiDelegate {
UnifiedSystemTray::UiDelegate::UiDelegate(UnifiedSystemTray* owner) UnifiedSystemTray::UiDelegate::UiDelegate(UnifiedSystemTray* owner)
: owner_(owner) { : owner_(owner) {
ui_controller_ = std::make_unique<message_center::UiController>(this); ui_controller_ = std::make_unique<MessageCenterUiController>(this);
ui_controller_->set_hide_on_last_notification(false); ui_controller_->set_hide_on_last_notification(false);
popup_alignment_delegate_ = popup_alignment_delegate_ =
std::make_unique<AshPopupAlignmentDelegate>(owner->shelf()); std::make_unique<AshPopupAlignmentDelegate>(owner->shelf());
......
...@@ -92,7 +92,7 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView { ...@@ -92,7 +92,7 @@ class ASH_EXPORT UnifiedSystemTray : public TrayBackgroundView {
friend class UnifiedSystemTrayTest; friend class UnifiedSystemTrayTest;
friend class UnifiedSystemTrayTestApi; friend class UnifiedSystemTrayTestApi;
// Private class implements message_center::UiDelegate. // Private class implements MessageCenterUiDelegate.
class UiDelegate; class UiDelegate;
// Private class implements TrayNetworkStateObserver::Delegate. // Private class implements TrayNetworkStateObserver::Delegate.
......
...@@ -107,15 +107,6 @@ jumbo_component("message_center") { ...@@ -107,15 +107,6 @@ jumbo_component("message_center") {
] ]
} }
# TODO(yoshiki): move the following files to ash/message_center.
if (is_chromeos) {
sources += [
"ui_controller.cc",
"ui_controller.h",
"ui_delegate.h",
]
}
# On Mac, toolkit-views builds still use the Cocoa UI. Keep this in sync # On Mac, toolkit-views builds still use the Cocoa UI. Keep this in sync
# with message_center_unittests below. # with message_center_unittests below.
if (toolkit_views && !is_mac) { if (toolkit_views && !is_mac) {
...@@ -239,12 +230,7 @@ if (enable_message_center) { ...@@ -239,12 +230,7 @@ if (enable_message_center) {
] ]
if (is_chromeos) { if (is_chromeos) {
sources += [ sources += [ "public/mojo/struct_traits_unittest.cc" ]
"public/mojo/struct_traits_unittest.cc",
# TODO(yoshiki): move ui_controller_unittest.cc to ash/message_center.
"ui_controller_unittest.cc",
]
deps += [ deps += [
"//mojo/core/embedder", "//mojo/core/embedder",
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notification.h" #include "ui/message_center/public/cpp/notification.h"
#include "ui/message_center/public/cpp/notification_types.h" #include "ui/message_center/public/cpp/notification_types.h"
#include "ui/message_center/ui_controller.h"
namespace message_center { namespace message_center {
namespace { namespace {
......
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