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() { ...@@ -56,9 +56,11 @@ void StatusAreaWidget::Initialize() {
} }
// Must happen after the widget is initialized so the native window exists. // Must happen after the widget is initialized so the native window exists.
if (!features::IsSystemTrayUnifiedEnabled()) {
web_notification_tray_ = web_notification_tray_ =
std::make_unique<WebNotificationTray>(shelf_, GetNativeWindow()); std::make_unique<WebNotificationTray>(shelf_, GetNativeWindow());
status_area_widget_delegate_->AddChildView(web_notification_tray_.get()); status_area_widget_delegate_->AddChildView(web_notification_tray_.get());
}
palette_tray_ = std::make_unique<PaletteTray>(shelf_); palette_tray_ = std::make_unique<PaletteTray>(shelf_);
status_area_widget_delegate_->AddChildView(palette_tray_.get()); status_area_widget_delegate_->AddChildView(palette_tray_.get());
...@@ -85,8 +87,12 @@ void StatusAreaWidget::Initialize() { ...@@ -85,8 +87,12 @@ void StatusAreaWidget::Initialize() {
status_area_widget_delegate_->UpdateLayout(); status_area_widget_delegate_->UpdateLayout();
// Initialize after all trays have been created. // Initialize after all trays have been created.
if (web_notification_tray_) {
system_tray_->InitializeTrayItems(web_notification_tray_.get()); system_tray_->InitializeTrayItems(web_notification_tray_.get());
web_notification_tray_->Initialize(); web_notification_tray_->Initialize();
} else {
system_tray_->InitializeTrayItems(nullptr);
}
palette_tray_->Initialize(); palette_tray_->Initialize();
virtual_keyboard_tray_->Initialize(); virtual_keyboard_tray_->Initialize();
ime_menu_tray_->Initialize(); ime_menu_tray_->Initialize();
...@@ -119,6 +125,7 @@ StatusAreaWidget::~StatusAreaWidget() { ...@@ -119,6 +125,7 @@ StatusAreaWidget::~StatusAreaWidget() {
void StatusAreaWidget::UpdateAfterShelfAlignmentChange() { void StatusAreaWidget::UpdateAfterShelfAlignmentChange() {
system_tray_->UpdateAfterShelfAlignmentChange(); system_tray_->UpdateAfterShelfAlignmentChange();
if (web_notification_tray_)
web_notification_tray_->UpdateAfterShelfAlignmentChange(); web_notification_tray_->UpdateAfterShelfAlignmentChange();
logout_button_tray_->UpdateAfterShelfAlignmentChange(); logout_button_tray_->UpdateAfterShelfAlignmentChange();
virtual_keyboard_tray_->UpdateAfterShelfAlignmentChange(); virtual_keyboard_tray_->UpdateAfterShelfAlignmentChange();
...@@ -171,11 +178,13 @@ bool StatusAreaWidget::ShouldShowShelf() const { ...@@ -171,11 +178,13 @@ bool StatusAreaWidget::ShouldShowShelf() const {
bool StatusAreaWidget::IsMessageBubbleShown() const { bool StatusAreaWidget::IsMessageBubbleShown() const {
return system_tray_->IsSystemBubbleVisible() || return system_tray_->IsSystemBubbleVisible() ||
web_notification_tray_->IsMessageCenterVisible(); (web_notification_tray_ &&
web_notification_tray_->IsMessageCenterVisible());
} }
void StatusAreaWidget::SchedulePaint() { void StatusAreaWidget::SchedulePaint() {
status_area_widget_delegate_->SchedulePaint(); status_area_widget_delegate_->SchedulePaint();
if (web_notification_tray_)
web_notification_tray_->SchedulePaint(); web_notification_tray_->SchedulePaint();
system_tray_->SchedulePaint(); system_tray_->SchedulePaint();
virtual_keyboard_tray_->SchedulePaint(); virtual_keyboard_tray_->SchedulePaint();
...@@ -200,6 +209,7 @@ bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { ...@@ -200,6 +209,7 @@ bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
} }
void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) { void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) {
if (web_notification_tray_)
web_notification_tray_->UpdateShelfItemBackground(color); web_notification_tray_->UpdateShelfItemBackground(color);
system_tray_->UpdateShelfItemBackground(color); system_tray_->UpdateShelfItemBackground(color);
virtual_keyboard_tray_->UpdateShelfItemBackground(color); virtual_keyboard_tray_->UpdateShelfItemBackground(color);
......
...@@ -238,14 +238,14 @@ SystemTray::~SystemTray() { ...@@ -238,14 +238,14 @@ SystemTray::~SystemTray() {
void SystemTray::InitializeTrayItems( void SystemTray::InitializeTrayItems(
WebNotificationTray* web_notification_tray) { WebNotificationTray* web_notification_tray) {
DCHECK(web_notification_tray); DCHECK(web_notification_tray || features::IsSystemTrayUnifiedEnabled());
web_notification_tray_ = web_notification_tray; web_notification_tray_ = web_notification_tray;
TrayBackgroundView::Initialize(); TrayBackgroundView::Initialize();
CreateItems(); CreateItems();
} }
void SystemTray::Shutdown() { void SystemTray::Shutdown() {
DCHECK(web_notification_tray_); DCHECK(web_notification_tray_ || features::IsSystemTrayUnifiedEnabled());
web_notification_tray_ = nullptr; web_notification_tray_ = nullptr;
} }
......
...@@ -7,10 +7,93 @@ ...@@ -7,10 +7,93 @@
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.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 { 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 // On the first step, features in the status area button are still provided by
// TrayViews in SystemTray. // TrayViews in SystemTray.
// TODO(tetsui): Remove SystemTray from StatusAreaWidget and provide these // TODO(tetsui): Remove SystemTray from StatusAreaWidget and provide these
...@@ -33,15 +116,14 @@ bool UnifiedSystemTray::PerformAction(const ui::Event& event) { ...@@ -33,15 +116,14 @@ bool UnifiedSystemTray::PerformAction(const ui::Event& event) {
} }
void UnifiedSystemTray::ShowBubble(bool show_by_click) { void UnifiedSystemTray::ShowBubble(bool show_by_click) {
bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this); // ShowBubbleInternal will be called from UiDelegate.
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor. if (!bubble_)
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(true); ui_delegate_->ui_controller()->ShowMessageCenterBubble(show_by_click);
} }
void UnifiedSystemTray::CloseBubble() { void UnifiedSystemTray::CloseBubble() {
bubble_.reset(); // HideBubbleInternal will be called from UiDelegate.
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor. ui_delegate_->ui_controller()->HideMessageCenterBubble();
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(false);
} }
base::string16 UnifiedSystemTray::GetAccessibleNameForTray() { base::string16 UnifiedSystemTray::GetAccessibleNameForTray() {
...@@ -54,4 +136,16 @@ void UnifiedSystemTray::HideBubbleWithView( ...@@ -54,4 +136,16 @@ void UnifiedSystemTray::HideBubbleWithView(
void UnifiedSystemTray::ClickedOutsideBubble() {} 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 } // namespace ash
...@@ -44,6 +44,15 @@ class UnifiedSystemTray : public TrayBackgroundView { ...@@ -44,6 +44,15 @@ class UnifiedSystemTray : public TrayBackgroundView {
void ClickedOutsideBubble() override; void ClickedOutsideBubble() override;
private: 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_; std::unique_ptr<UnifiedSystemTrayBubble> bubble_;
DISALLOW_COPY_AND_ASSIGN(UnifiedSystemTray); 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