Commit 3284b1be authored by Andy Paicu's avatar Andy Paicu Committed by Commit Bot

Revert "CrOS Shelf: Start moving some hotseat logic into the hotseat widget"

This reverts commit d1531b9a.

Reason for revert:
Findit (https://goo.gl/kROfz5) identified CL at revision 711796 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtL2QxNTMxYjlhYzVhNDlkMTlmOTQ5ZTlkOGY0MmRhZjM0NzBkMzEzMmEM

Sample Failed Build: https://ci.chromium.org/b/8897957936228871696

Sample Failed Step: browser_tests

Original change's description:
> CrOS Shelf: Start moving some hotseat logic into the hotseat widget
>
> The general idea here is to encapsulate more of the hotseat's behavior
> into its own class rather than have it all over the shelf layout
> manager. Eventually, I hope to get rid of the huge
> "CalculateHotseatState" method by setting the hotseat state to the
> appropriate values from the relevant places.
>
> Change-Id: I03bf50bc9f6fb68f7f22f1b6ec966f08f48220da
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893997
> Commit-Queue: Manu Cornet <manucornet@chromium.org>
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#711796}

TBR=xiyuan@chromium.org,manucornet@chromium.org

Change-Id: I7dd2357dd075bee067c3bad1aa58db788ba1039e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893885Reviewed-by: default avatarAndy Paicu <andypaicu@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712119}
parent da5ec5da
......@@ -186,14 +186,6 @@ void HotseatWidget::Initialize(aura::Window* container, Shelf* shelf) {
delegate_view_->Init(scrollable_shelf_view(), GetLayer());
}
void HotseatWidget::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void HotseatWidget::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void HotseatWidget::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() == ui::ET_MOUSE_PRESSED)
keyboard::KeyboardUIController::Get()->HideKeyboardImplicitlyByUser();
......@@ -239,15 +231,6 @@ const ShelfView* HotseatWidget::GetShelfView() const {
const_cast<HotseatWidget*>(this)->GetShelfView());
}
void HotseatWidget::SetState(HotseatState state) {
if (state_ == state)
return;
state_ = state;
for (auto& observer : observers_)
observer.OnHotseatStateChanged();
}
bool HotseatWidget::IsShowingOverflowBubble() const {
return GetShelfView()->IsShowingOverflowBubble();
}
......
......@@ -7,9 +7,6 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_types.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "ui/views/widget/widget.h"
namespace ash {
......@@ -22,19 +19,12 @@ class ShelfView;
class ASH_EXPORT HotseatWidget : public views::Widget,
public ShelfConfig::Observer {
public:
class Observer : public base::CheckedObserver {
public:
virtual void OnHotseatStateChanged() = 0;
};
HotseatWidget();
~HotseatWidget() override;
// Initializes the widget, sets its contents view and basic properties.
void Initialize(aura::Window* container, Shelf* shelf);
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// views::Widget:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
......@@ -68,9 +58,6 @@ class ASH_EXPORT HotseatWidget : public views::Widget,
ShelfView* GetShelfView();
const ShelfView* GetShelfView() const;
void SetState(HotseatState state);
HotseatState state() const { return state_; }
ScrollableShelfView* scrollable_shelf_view() {
return scrollable_shelf_view_;
}
......@@ -95,10 +82,6 @@ class ASH_EXPORT HotseatWidget : public views::Widget,
// of the hotseat.
DelegateView* delegate_view_ = nullptr;
HotseatState state_ = HotseatState::kShown;
base::ObserverList<Observer> observers_;
// Whether the widget is currently extended because the user has manually
// dragged it. This will be reset with any visible shelf configuration change.
bool is_manually_extended_ = false;
......
This diff is collapsed.
......@@ -14,7 +14,6 @@
#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "ash/session/session_observer.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell_observer.h"
#include "ash/system/locale/locale_update_controller_impl.h"
#include "ash/wm/desks/desks_controller.h"
......@@ -65,7 +64,6 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
public ShellObserver,
public SplitViewObserver,
public OverviewObserver,
public HotseatWidget::Observer,
public ::wm::ActivationChangeObserver,
public LockStateObserver,
public WmDefaultLayoutManager,
......@@ -121,7 +119,7 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
void ProcessGestureEventOfAutoHideShelf(ui::GestureEvent* event,
aura::Window* target);
// Handles events that are detected while the hotseat is extended in in-app
// Handles events that are detected while the hotseat is kExtended in in-app
// shelf.
void ProcessGestureEventOfInAppHotseat(ui::GestureEvent* event,
aura::Window* target);
......@@ -189,9 +187,6 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
void OnOverviewModeEndingAnimationComplete(bool canceled) override;
void OnOverviewModeEnded() override;
// HotseatWidget::Observer:
void OnHotseatStateChanged() override;
// AppListControllerObserver:
void OnAppListVisibilityWillChange(bool shown, int64_t display_id) override;
void OnAppListVisibilityChanged(bool shown, int64_t display_id) override;
......@@ -237,9 +232,7 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
bool updating_bounds() const { return updating_bounds_; }
ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
HotseatState hotseat_state() const {
return shelf_widget_->hotseat_widget()->state();
}
HotseatState hotseat_state() const { return state_.hotseat_state; }
DragWindowFromShelfController* window_drag_controller_for_testing() {
return window_drag_controller_.get();
......
......@@ -30,6 +30,9 @@ class ASH_EXPORT ShelfLayoutManagerObserver {
virtual void OnBackgroundUpdated(ShelfBackgroundType background_type,
AnimationChangeType change_type) {}
// Called when the hotseat state changes.
virtual void OnHotseatStateChanged(HotseatState state) {}
// Called when ShelfLayoutManager has updated Shelf insets in work area
// insets.
virtual void OnWorkAreaInsetsChanged() {}
......
......@@ -3219,16 +3219,19 @@ class HotseatShelfLayoutManagerTest
};
// Records HotseatState transitions.
class HotseatStateWatcher : public HotseatWidget::Observer {
class HotseatStateWatcher : public ShelfLayoutManagerObserver {
public:
explicit HotseatStateWatcher(HotseatWidget* widget) : widget_(widget) {
widget_->AddObserver(this);
HotseatStateWatcher(ShelfLayoutManager* shelf_layout_manager)
: shelf_layout_manager_(shelf_layout_manager) {
shelf_layout_manager_->AddObserver(this);
}
~HotseatStateWatcher() override {
shelf_layout_manager_->RemoveObserver(this);
}
~HotseatStateWatcher() override { widget_->RemoveObserver(this); }
void OnHotseatStateChanged() override {
void OnHotseatStateChanged(HotseatState state) override {
run_loop_.QuitWhenIdle();
state_changes_.push_back(widget_->state());
state_changes_.push_back(state);
}
void CheckEqual(std::vector<HotseatState> state_changes) {
......@@ -3238,7 +3241,7 @@ class HotseatStateWatcher : public HotseatWidget::Observer {
void WaitUntilStateChanged() { run_loop_.Run(); }
private:
HotseatWidget* const widget_;
ShelfLayoutManager* shelf_layout_manager_;
std::vector<HotseatState> state_changes_;
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(HotseatStateWatcher);
......@@ -3536,8 +3539,8 @@ TEST_F(HotseatShelfLayoutManagerTest, ReleasingSlowDragBelowThreshold) {
EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
}
// Tests that releasing the hotseat gesture above the threshold results in an
// extended hotseat.
// Tests that releasing the hotseat gesture above the threshold results in a
// kExtended hotseat.
TEST_P(HotseatShelfLayoutManagerTest, ReleasingSlowDragAboveThreshold) {
GetPrimaryShelf()->SetAutoHideBehavior(GetParam());
TabletModeControllerTestApi().EnterTabletMode();
......@@ -3574,8 +3577,7 @@ TEST_P(HotseatShelfLayoutManagerTest, ShowingOverviewFromShownAnimatesOnce) {
wm::ActivateWindow(window.get());
std::unique_ptr<HotseatStateWatcher> state_watcher_ =
std::make_unique<HotseatStateWatcher>(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
std::make_unique<HotseatStateWatcher>(GetShelfLayoutManager());
SwipeUpOnShelf();
ASSERT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
......@@ -3779,8 +3781,7 @@ TEST_P(HotseatShelfLayoutManagerTest, HomeToOverviewChangesStateOnce) {
.CenterPoint();
{
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
OverviewAnimationWaiter waiter;
GetEventGenerator()->GestureTapAt(overview_button_center);
waiter.Wait();
......@@ -3799,8 +3800,7 @@ TEST_P(HotseatShelfLayoutManagerTest, HomeToOverviewChangesStateOnce) {
GetAppListTestHelper()->CheckVisibility(true);
// Activate overview and expect the hotseat only changes state to extended.
{
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
OverviewAnimationWaiter waiter;
GetEventGenerator()->GestureTapAt(overview_button_center);
waiter.Wait();
......@@ -3815,8 +3815,7 @@ TEST_P(HotseatShelfLayoutManagerTest, HomeToInAppChangesStateOnce) {
TabletModeControllerTestApi().EnterTabletMode();
// Go to in-app, the hotseat should hide.
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
......@@ -3840,8 +3839,7 @@ TEST_P(HotseatShelfLayoutManagerTest, InAppToHomeChangesStateOnce) {
// Press the HomeLauncher button, the hotseat should transition directly to
// kShown.
{
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
views::View* home_button =
GetPrimaryShelf()->shelf_widget()->GetHomeButton();
GetEventGenerator()->GestureTapAt(
......@@ -3859,8 +3857,7 @@ TEST_P(HotseatShelfLayoutManagerTest, InAppToHomeChangesStateOnce) {
{
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
FlingUpOnShelf();
watcher.WaitUntilStateChanged();
watcher.CheckEqual({HotseatState::kShown});
......@@ -3877,8 +3874,7 @@ TEST_P(HotseatShelfLayoutManagerTest, InAppToHomeChangesStateOnce) {
// Press the HomeLauncher button, the hotseat should transition directly to
// kShown.
{
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
views::View* home_button =
GetPrimaryShelf()->shelf_widget()->GetHomeButton();
GetEventGenerator()->GestureTapAt(
......@@ -3901,8 +3897,7 @@ TEST_F(HotseatShelfLayoutManagerTest,
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
{
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
// Enter overview by using the controller.
OverviewAnimationWaiter waiter;
Shell::Get()->overview_controller()->StartOverview();
......@@ -3922,8 +3917,7 @@ TEST_F(HotseatShelfLayoutManagerTest,
GetShelfLayoutManager()->auto_hide_state());
SwipeUpOnShelf();
{
HotseatStateWatcher watcher(
GetPrimaryShelf()->shelf_widget()->hotseat_widget());
HotseatStateWatcher watcher(GetShelfLayoutManager());
// Enter overview by using the controller.
OverviewAnimationWaiter waiter;
Shell::Get()->overview_controller()->StartOverview();
......
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