Commit c27d0e2e authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Support UnifiedSystemTray in first run tutorial.

UnifiedSystemTray class will replace old SystemTray class. Therefore, we
have to remove all the references that rely on old SystemTray
implementation.

UnifiedSystemTray does not have help button (it will be replaced by one
in app launcher), so we remove HelpStep from first run tutorial.

Screenshot: http://screen/ZcfkBjBZT0x
Design doc: http://go/cros-qs-restyling

TEST=manual
BUG=837508,837502

Change-Id: I90b8eff7095b9e49cddd31398349b3c5db8728df
Reviewed-on: https://chromium-review.googlesource.com/1063529Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560212}
parent 2281901a
......@@ -5,13 +5,17 @@
#include "ash/first_run/first_run_helper.h"
#include "ash/first_run/desktop_cleaner.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller.h"
#include "ash/shelf/app_list_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray.h"
#include "base/logging.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/gfx/geometry/rect.h"
......@@ -39,7 +43,7 @@ void FirstRunHelper::Start(mojom::FirstRunHelperClientPtr client) {
void FirstRunHelper::Stop() {
Shell::Get()->session_controller()->RemoveObserver(this);
// Ensure the tray is closed.
Shell::Get()->GetPrimarySystemTray()->CloseBubble();
CloseTrayBubble();
cleaner_.reset();
}
......@@ -50,18 +54,38 @@ void FirstRunHelper::GetAppListButtonBounds(GetAppListButtonBoundsCallback cb) {
}
void FirstRunHelper::OpenTrayBubble(OpenTrayBubbleCallback cb) {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
tray->ShowPersistentDefaultView();
views::View* bubble = tray->GetSystemBubble()->bubble_view();
std::move(cb).Run(bubble->GetBoundsInScreen());
if (features::IsSystemTrayUnifiedEnabled()) {
UnifiedSystemTray* tray = Shell::Get()
->GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->unified_system_tray();
tray->ShowBubble(false /* show_by_click */);
std::move(cb).Run(tray->GetBubbleBoundsInScreen());
} else {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
tray->ShowPersistentDefaultView();
views::View* bubble = tray->GetSystemBubble()->bubble_view();
std::move(cb).Run(bubble->GetBoundsInScreen());
}
}
void FirstRunHelper::CloseTrayBubble() {
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
tray->CloseBubble();
if (features::IsSystemTrayUnifiedEnabled()) {
Shell::Get()
->GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->unified_system_tray()
->CloseBubble();
} else {
Shell::Get()->GetPrimarySystemTray()->CloseBubble();
}
}
void FirstRunHelper::GetHelpButtonBounds(GetHelpButtonBoundsCallback cb) {
if (features::IsSystemTrayUnifiedEnabled()) {
std::move(cb).Run(gfx::Rect());
return;
}
SystemTray* tray = Shell::Get()->GetPrimarySystemTray();
views::View* help_button = tray->GetHelpButtonView();
// |help_button| could be null if the tray isn't open.
......
......@@ -160,6 +160,10 @@ bool UnifiedSystemTray::IsBubbleShown() const {
return !!bubble_;
}
gfx::Rect UnifiedSystemTray::GetBubbleBoundsInScreen() const {
return bubble_ ? bubble_->GetBoundsInScreen() : gfx::Rect();
}
bool UnifiedSystemTray::PerformAction(const ui::Event& event) {
if (bubble_)
CloseBubble();
......
......@@ -36,6 +36,9 @@ class UnifiedSystemTray : public TrayBackgroundView {
// True if the bubble is shown.
bool IsBubbleShown() const;
// Return the bounds of the bubble in the screen.
gfx::Rect GetBubbleBoundsInScreen() const;
// TrayBackgroundView:
bool PerformAction(const ui::Event& event) override;
void ShowBubble(bool show_by_click) override;
......
......@@ -81,6 +81,11 @@ UnifiedSystemTrayBubble::~UnifiedSystemTrayBubble() {
}
}
gfx::Rect UnifiedSystemTrayBubble::GetBoundsInScreen() const {
DCHECK(bubble_view_);
return bubble_view_->GetBoundsInScreen();
}
TrayBackgroundView* UnifiedSystemTrayBubble::GetTray() const {
return tray_;
}
......
......@@ -34,6 +34,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase,
explicit UnifiedSystemTrayBubble(UnifiedSystemTray* tray, bool show_by_click);
~UnifiedSystemTrayBubble() override;
// Return the bounds of the bubble in the screen.
gfx::Rect GetBoundsInScreen() const;
// TrayBubbleBase:
TrayBackgroundView* GetTray() const override;
views::TrayBubbleView* GetBubbleView() const override;
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shelf_prefs.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/interfaces/constants.mojom.h"
......@@ -205,7 +206,9 @@ void FirstRunController::OnCancelled() {
void FirstRunController::RegisterSteps() {
steps_.push_back(std::make_unique<first_run::AppListStep>(this, actor_));
steps_.push_back(std::make_unique<first_run::TrayStep>(this, actor_));
steps_.push_back(std::make_unique<first_run::HelpStep>(this, actor_));
// UnifiedSystemTray does not have a help button. https://crbug.com/837502
if (!ash::features::IsSystemTrayUnifiedEnabled())
steps_.push_back(std::make_unique<first_run::HelpStep>(this, actor_));
}
void FirstRunController::ShowNextStep() {
......
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