Commit 2813d7fc authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Hide WebNotificationTray on flag.

This CL removes WebNotificationTray button when --enable-features=
SystemTrayUnified.
UnifiedSystemTray will replace WebNotificationTray and SystemTray.
When the flag is enabled, UiController, AshPopupAlignmentDelegate, and
MessagePopupCollection will be also owned by UnifiedSystemTray.

TEST=manual
BUG=828752

Change-Id: I03cf6949bb2b165d4bda89327570aac74328e88c
Reviewed-on: https://chromium-review.googlesource.com/987635Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548837}
parent dc1f1329
......@@ -56,9 +56,11 @@ void StatusAreaWidget::Initialize() {
}
// Must happen after the widget is initialized so the native window exists.
web_notification_tray_ =
std::make_unique<WebNotificationTray>(shelf_, GetNativeWindow());
status_area_widget_delegate_->AddChildView(web_notification_tray_.get());
if (!features::IsSystemTrayUnifiedEnabled()) {
web_notification_tray_ =
std::make_unique<WebNotificationTray>(shelf_, GetNativeWindow());
status_area_widget_delegate_->AddChildView(web_notification_tray_.get());
}
palette_tray_ = std::make_unique<PaletteTray>(shelf_);
status_area_widget_delegate_->AddChildView(palette_tray_.get());
......@@ -85,8 +87,12 @@ void StatusAreaWidget::Initialize() {
status_area_widget_delegate_->UpdateLayout();
// Initialize after all trays have been created.
system_tray_->InitializeTrayItems(web_notification_tray_.get());
web_notification_tray_->Initialize();
if (web_notification_tray_) {
system_tray_->InitializeTrayItems(web_notification_tray_.get());
web_notification_tray_->Initialize();
} else {
system_tray_->InitializeTrayItems(nullptr);
}
palette_tray_->Initialize();
virtual_keyboard_tray_->Initialize();
ime_menu_tray_->Initialize();
......@@ -119,7 +125,8 @@ StatusAreaWidget::~StatusAreaWidget() {
void StatusAreaWidget::UpdateAfterShelfAlignmentChange() {
system_tray_->UpdateAfterShelfAlignmentChange();
web_notification_tray_->UpdateAfterShelfAlignmentChange();
if (web_notification_tray_)
web_notification_tray_->UpdateAfterShelfAlignmentChange();
logout_button_tray_->UpdateAfterShelfAlignmentChange();
virtual_keyboard_tray_->UpdateAfterShelfAlignmentChange();
ime_menu_tray_->UpdateAfterShelfAlignmentChange();
......@@ -171,12 +178,14 @@ bool StatusAreaWidget::ShouldShowShelf() const {
bool StatusAreaWidget::IsMessageBubbleShown() const {
return system_tray_->IsSystemBubbleVisible() ||
web_notification_tray_->IsMessageCenterVisible();
(web_notification_tray_ &&
web_notification_tray_->IsMessageCenterVisible());
}
void StatusAreaWidget::SchedulePaint() {
status_area_widget_delegate_->SchedulePaint();
web_notification_tray_->SchedulePaint();
if (web_notification_tray_)
web_notification_tray_->SchedulePaint();
system_tray_->SchedulePaint();
virtual_keyboard_tray_->SchedulePaint();
logout_button_tray_->SchedulePaint();
......@@ -200,7 +209,8 @@ bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
}
void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) {
web_notification_tray_->UpdateShelfItemBackground(color);
if (web_notification_tray_)
web_notification_tray_->UpdateShelfItemBackground(color);
system_tray_->UpdateShelfItemBackground(color);
virtual_keyboard_tray_->UpdateShelfItemBackground(color);
ime_menu_tray_->UpdateShelfItemBackground(color);
......
......@@ -238,14 +238,14 @@ SystemTray::~SystemTray() {
void SystemTray::InitializeTrayItems(
WebNotificationTray* web_notification_tray) {
DCHECK(web_notification_tray);
DCHECK(web_notification_tray || features::IsSystemTrayUnifiedEnabled());
web_notification_tray_ = web_notification_tray;
TrayBackgroundView::Initialize();
CreateItems();
}
void SystemTray::Shutdown() {
DCHECK(web_notification_tray_);
DCHECK(web_notification_tray_ || features::IsSystemTrayUnifiedEnabled());
web_notification_tray_ = nullptr;
}
......
......@@ -7,10 +7,93 @@
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/web_notification/ash_popup_alignment_delegate.h"
#include "ui/display/display.h"
#include "ui/display/screen.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"
namespace ash {
UnifiedSystemTray::UnifiedSystemTray(Shelf* shelf) : TrayBackgroundView(shelf) {
class UnifiedSystemTray::UiDelegate : public message_center::UiDelegate {
public:
explicit UiDelegate(UnifiedSystemTray* owner);
~UiDelegate() override;
// message_center::UiDelegate:
void OnMessageCenterContentsChanged() override;
bool ShowPopups() override;
void HidePopups() override;
bool ShowMessageCenter(bool show_by_click) override;
void HideMessageCenter() override;
bool ShowNotifierSettings() override;
message_center::UiController* ui_controller() { return ui_controller_.get(); }
private:
std::unique_ptr<message_center::UiController> ui_controller_;
std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_;
std::unique_ptr<message_center::MessagePopupCollection>
message_popup_collection_;
UnifiedSystemTray* const owner_;
DISALLOW_COPY_AND_ASSIGN(UiDelegate);
};
UnifiedSystemTray::UiDelegate::UiDelegate(UnifiedSystemTray* owner)
: owner_(owner) {
ui_controller_ = std::make_unique<message_center::UiController>(this);
popup_alignment_delegate_ =
std::make_unique<AshPopupAlignmentDelegate>(owner->shelf());
message_popup_collection_ =
std::make_unique<message_center::MessagePopupCollection>(
message_center::MessageCenter::Get(), ui_controller_.get(),
popup_alignment_delegate_.get());
display::Screen* screen = display::Screen::GetScreen();
popup_alignment_delegate_->StartObserving(
screen, screen->GetDisplayNearestWindow(
owner->shelf()->GetStatusAreaWidget()->GetNativeWindow()));
}
UnifiedSystemTray::UiDelegate::~UiDelegate() = default;
void UnifiedSystemTray::UiDelegate::OnMessageCenterContentsChanged() {
// TODO(tetsui): Implement.
}
bool UnifiedSystemTray::UiDelegate::ShowPopups() {
if (owner_->IsBubbleShown())
return false;
message_popup_collection_->DoUpdate();
return true;
}
void UnifiedSystemTray::UiDelegate::HidePopups() {
message_popup_collection_->MarkAllPopupsShown();
}
bool UnifiedSystemTray::UiDelegate::ShowMessageCenter(bool show_by_click) {
if (owner_->IsBubbleShown())
return false;
owner_->ShowBubbleInternal();
return true;
}
void UnifiedSystemTray::UiDelegate::HideMessageCenter() {
owner_->HideBubbleInternal();
}
bool UnifiedSystemTray::UiDelegate::ShowNotifierSettings() {
return false;
}
UnifiedSystemTray::UnifiedSystemTray(Shelf* shelf)
: TrayBackgroundView(shelf),
ui_delegate_(std::make_unique<UiDelegate>(this)) {
// On the first step, features in the status area button are still provided by
// TrayViews in SystemTray.
// TODO(tetsui): Remove SystemTray from StatusAreaWidget and provide these
......@@ -33,15 +116,14 @@ bool UnifiedSystemTray::PerformAction(const ui::Event& event) {
}
void UnifiedSystemTray::ShowBubble(bool show_by_click) {
bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this);
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor.
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(true);
// ShowBubbleInternal will be called from UiDelegate.
if (!bubble_)
ui_delegate_->ui_controller()->ShowMessageCenterBubble(show_by_click);
}
void UnifiedSystemTray::CloseBubble() {
bubble_.reset();
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor.
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(false);
// HideBubbleInternal will be called from UiDelegate.
ui_delegate_->ui_controller()->HideMessageCenterBubble();
}
base::string16 UnifiedSystemTray::GetAccessibleNameForTray() {
......@@ -54,4 +136,16 @@ void UnifiedSystemTray::HideBubbleWithView(
void UnifiedSystemTray::ClickedOutsideBubble() {}
void UnifiedSystemTray::ShowBubbleInternal() {
bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this);
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor.
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(true);
}
void UnifiedSystemTray::HideBubbleInternal() {
bubble_.reset();
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor.
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(false);
}
} // namespace ash
......@@ -44,6 +44,15 @@ class UnifiedSystemTray : public TrayBackgroundView {
void ClickedOutsideBubble() override;
private:
// Private class implements message_center::UiDelegate.
class UiDelegate;
// Forwarded from UiDelegate.
void ShowBubbleInternal();
void HideBubbleInternal();
std::unique_ptr<UiDelegate> ui_delegate_;
std::unique_ptr<UnifiedSystemTrayBubble> bubble_;
DISALLOW_COPY_AND_ASSIGN(UnifiedSystemTray);
......
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