Commit 4054a4e9 authored by Findit's avatar Findit

Revert "Remove HomeLauncherGestureHandlerObserver"

This reverts commit 433bbd52.

Reason for revert:

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

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

Sample Failed Step: compile

Original change's description:
> Remove HomeLauncherGestureHandlerObserver
> 
> HomeLauncherGestureHandler currently has two observers:
> *   AppListControllerImpl, which is also a HomeScreenDelegate
>     implementation (on which HomeScreenGestureHandler already
>     depends, so additional observer interface just
>     obscures/complicates this dependency)
> *   HomeLauncherStateWaiter which is used by interactive UI/perf tests
>     to wait for launcher animations to complete
> 
> For the former case, moving the observer methods to HomeScreenDelegate
> interface will work fine.
> For latter case, the test waiter can register a callback with
> AppListControllerImpl to be run when the home launcher animations are
> complete - the same way it's done by LauncherStateWaiter, an equivalent
> test waiter used in clamshell mode (or for waiting for non-visibility
> app list state transitions)
> 
> Change-Id: Ia333bedab2b8683d35da2d00030cf40df2c619f5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888652
> Reviewed-by: Manu Cornet <manucornet@chromium.org>
> Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
> Commit-Queue: Toni Baržić <tbarzic@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#711038}


Change-Id: I449d4c15018c05c09953d445a50d1c1dc6f7c1a0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890735
Cr-Commit-Position: refs/heads/master@{#711044}
parent 3fe28bd3
...@@ -347,6 +347,7 @@ component("ash") { ...@@ -347,6 +347,7 @@ component("ash") {
"home_screen/drag_window_from_shelf_controller.h", "home_screen/drag_window_from_shelf_controller.h",
"home_screen/home_launcher_gesture_handler.cc", "home_screen/home_launcher_gesture_handler.cc",
"home_screen/home_launcher_gesture_handler.h", "home_screen/home_launcher_gesture_handler.h",
"home_screen/home_launcher_gesture_handler_observer.h",
"home_screen/home_screen_controller.cc", "home_screen/home_screen_controller.cc",
"home_screen/home_screen_controller.h", "home_screen/home_screen_controller.h",
"home_screen/home_screen_delegate.h", "home_screen/home_screen_delegate.h",
......
...@@ -167,6 +167,8 @@ AppListControllerImpl::AppListControllerImpl() ...@@ -167,6 +167,8 @@ AppListControllerImpl::AppListControllerImpl()
shell->assistant_controller()->AddObserver(this); shell->assistant_controller()->AddObserver(this);
shell->assistant_controller()->ui_controller()->AddModelObserver(this); shell->assistant_controller()->ui_controller()->AddModelObserver(this);
} }
shell->home_screen_controller()->home_launcher_gesture_handler()->AddObserver(
this);
} }
AppListControllerImpl::~AppListControllerImpl() { AppListControllerImpl::~AppListControllerImpl() {
...@@ -792,9 +794,6 @@ void AppListControllerImpl::OnHomeLauncherAnimationComplete( ...@@ -792,9 +794,6 @@ void AppListControllerImpl::OnHomeLauncherAnimationComplete(
// visibility is correct first. // visibility is correct first.
OnVisibilityWillChange(shown, display_id); OnVisibilityWillChange(shown, display_id);
OnVisibilityChanged(shown, display_id); OnVisibilityChanged(shown, display_id);
if (!home_launcher_animation_callback_.is_null())
home_launcher_animation_callback_.Run(shown);
} }
void AppListControllerImpl::OnHomeLauncherTargetPositionChanged( void AppListControllerImpl::OnHomeLauncherTargetPositionChanged(
...@@ -933,16 +932,11 @@ void AppListControllerImpl::SetAppListModelForTest( ...@@ -933,16 +932,11 @@ void AppListControllerImpl::SetAppListModelForTest(
model_->AddObserver(this); model_->AddObserver(this);
} }
void AppListControllerImpl::SetStateTransitionAnimationCallbackForTesting( void AppListControllerImpl::SetStateTransitionAnimationCallback(
StateTransitionAnimationCallback callback) { StateTransitionAnimationCallback callback) {
state_transition_animation_callback_ = std::move(callback); state_transition_animation_callback_ = std::move(callback);
} }
void AppListControllerImpl::SetHomeLauncherAnimationCallbackForTesting(
HomeLauncherAnimationCallback callback) {
home_launcher_animation_callback_ = std::move(callback);
}
void AppListControllerImpl::RecordShelfAppLaunched( void AppListControllerImpl::RecordShelfAppLaunched(
base::Optional<AppListViewState> recorded_app_list_view_state, base::Optional<AppListViewState> recorded_app_list_view_state,
base::Optional<bool> recorded_home_launcher_shown) { base::Optional<bool> recorded_home_launcher_shown) {
...@@ -1560,6 +1554,9 @@ void AppListControllerImpl::Shutdown() { ...@@ -1560,6 +1554,9 @@ void AppListControllerImpl::Shutdown() {
is_shutdown_ = true; is_shutdown_ = true;
Shell* shell = Shell::Get(); Shell* shell = Shell::Get();
shell->home_screen_controller()
->home_launcher_gesture_handler()
->RemoveObserver(this);
if (app_list_features::IsEmbeddedAssistantUIEnabled()) { if (app_list_features::IsEmbeddedAssistantUIEnabled()) {
shell->assistant_controller()->RemoveObserver(this); shell->assistant_controller()->RemoveObserver(this);
shell->assistant_controller()->ui_controller()->RemoveModelObserver(this); shell->assistant_controller()->ui_controller()->RemoveModelObserver(this);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ash/assistant/assistant_controller_observer.h" #include "ash/assistant/assistant_controller_observer.h"
#include "ash/assistant/model/assistant_ui_model_observer.h" #include "ash/assistant/model/assistant_ui_model_observer.h"
#include "ash/display/window_tree_host_manager.h" #include "ash/display/window_tree_host_manager.h"
#include "ash/home_screen/home_launcher_gesture_handler_observer.h"
#include "ash/home_screen/home_screen_delegate.h" #include "ash/home_screen/home_screen_delegate.h"
#include "ash/public/cpp/app_list/app_list_controller.h" #include "ash/public/cpp/app_list/app_list_controller.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h" #include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
...@@ -63,6 +64,7 @@ class ASH_EXPORT AppListControllerImpl ...@@ -63,6 +64,7 @@ class ASH_EXPORT AppListControllerImpl
public ash::MruWindowTracker::Observer, public ash::MruWindowTracker::Observer,
public AssistantControllerObserver, public AssistantControllerObserver,
public AssistantUiModelObserver, public AssistantUiModelObserver,
public HomeLauncherGestureHandlerObserver,
public HomeScreenDelegate { public HomeScreenDelegate {
public: public:
AppListControllerImpl(); AppListControllerImpl();
...@@ -268,6 +270,10 @@ class ASH_EXPORT AppListControllerImpl ...@@ -268,6 +270,10 @@ class ASH_EXPORT AppListControllerImpl
base::Optional<AssistantEntryPoint> entry_point, base::Optional<AssistantEntryPoint> entry_point,
base::Optional<AssistantExitPoint> exit_point) override; base::Optional<AssistantExitPoint> exit_point) override;
// HomeLauncherGestureHandlerObserver:
void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) override;
void OnHomeLauncherTargetPositionChanged(bool showing,
int64_t display_id) override;
// HomeScreenDelegate: // HomeScreenDelegate:
void ShowHomeScreenView() override; void ShowHomeScreenView() override;
...@@ -284,9 +290,6 @@ class ASH_EXPORT AppListControllerImpl ...@@ -284,9 +290,6 @@ class ASH_EXPORT AppListControllerImpl
base::Optional<base::TimeDelta> GetOptionalAnimationDuration() override; base::Optional<base::TimeDelta> GetOptionalAnimationDuration() override;
void NotifyHomeLauncherAnimationTransition(AnimationTrigger trigger, void NotifyHomeLauncherAnimationTransition(AnimationTrigger trigger,
bool launcher_will_show) override; bool launcher_will_show) override;
void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) override;
void OnHomeLauncherTargetPositionChanged(bool showing,
int64_t display_id) override;
bool IsHomeScreenVisible() override; bool IsHomeScreenVisible() override;
gfx::Rect GetInitialAppListItemScreenBoundsForWindow( gfx::Rect GetInitialAppListItemScreenBoundsForWindow(
aura::Window* window) override; aura::Window* window) override;
...@@ -324,14 +327,9 @@ class ASH_EXPORT AppListControllerImpl ...@@ -324,14 +327,9 @@ class ASH_EXPORT AppListControllerImpl
using StateTransitionAnimationCallback = using StateTransitionAnimationCallback =
base::RepeatingCallback<void(ash::AppListViewState)>; base::RepeatingCallback<void(ash::AppListViewState)>;
void SetStateTransitionAnimationCallbackForTesting( void SetStateTransitionAnimationCallback(
StateTransitionAnimationCallback callback); StateTransitionAnimationCallback callback);
using HomeLauncherAnimationCallback =
base::RepeatingCallback<void(bool shown)>;
void SetHomeLauncherAnimationCallbackForTesting(
HomeLauncherAnimationCallback callback);
void RecordShelfAppLaunched( void RecordShelfAppLaunched(
base::Optional<AppListViewState> recorded_app_list_view_state, base::Optional<AppListViewState> recorded_app_list_view_state,
base::Optional<bool> home_launcher_shown); base::Optional<bool> home_launcher_shown);
...@@ -425,14 +423,8 @@ class ASH_EXPORT AppListControllerImpl ...@@ -425,14 +423,8 @@ class ASH_EXPORT AppListControllerImpl
// each profile has its own AppListModelUpdater to manipulate app list items. // each profile has its own AppListModelUpdater to manipulate app list items.
int profile_id_ = kAppListInvalidProfileID; int profile_id_ = kAppListInvalidProfileID;
// A callback that can be registered by a test to wait for the app list state
// transition animation to finish.
StateTransitionAnimationCallback state_transition_animation_callback_; StateTransitionAnimationCallback state_transition_animation_callback_;
// A callback that can be registered by a test to wait for the home launcher
// visibility animation to finish. Should only be used in tablet mode.
HomeLauncherAnimationCallback home_launcher_animation_callback_;
// Used to prevent ShelfLayoutManager updating visibility state when overview // Used to prevent ShelfLayoutManager updating visibility state when overview
// is showing over the AppList. // is showing over the AppList.
std::unique_ptr<ShelfLayoutManager::ScopedSuspendVisibilityUpdate> std::unique_ptr<ShelfLayoutManager::ScopedSuspendVisibilityUpdate>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/home_screen/drag_window_from_shelf_controller.h" #include "ash/home_screen/drag_window_from_shelf_controller.h"
#include "ash/home_screen/home_launcher_gesture_handler_observer.h"
#include "ash/home_screen/home_screen_controller.h" #include "ash/home_screen/home_screen_controller.h"
#include "ash/home_screen/swipe_home_to_overview_controller.h" #include "ash/home_screen/swipe_home_to_overview_controller.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
...@@ -397,17 +398,28 @@ bool HomeLauncherGestureHandler::IsDragInProgress() const { ...@@ -397,17 +398,28 @@ bool HomeLauncherGestureHandler::IsDragInProgress() const {
return mode_ != Mode::kNone; return mode_ != Mode::kNone;
} }
void HomeLauncherGestureHandler::AddObserver(
HomeLauncherGestureHandlerObserver* observer) {
observers_.AddObserver(observer);
}
void HomeLauncherGestureHandler::RemoveObserver(
HomeLauncherGestureHandlerObserver* observer) {
observers_.RemoveObserver(observer);
}
void HomeLauncherGestureHandler::NotifyHomeLauncherTargetPositionChanged( void HomeLauncherGestureHandler::NotifyHomeLauncherTargetPositionChanged(
bool showing, bool showing,
int64_t display_id) { int64_t display_id) {
GetHomeScreenDelegate()->OnHomeLauncherTargetPositionChanged(showing, for (auto& observer : observers_)
display_id); observer.OnHomeLauncherTargetPositionChanged(showing, display_id);
} }
void HomeLauncherGestureHandler::NotifyHomeLauncherAnimationComplete( void HomeLauncherGestureHandler::NotifyHomeLauncherAnimationComplete(
bool shown, bool shown,
int64_t display_id) { int64_t display_id) {
GetHomeScreenDelegate()->OnHomeLauncherAnimationComplete(shown, display_id); for (auto& observer : observers_)
observer.OnHomeLauncherAnimationComplete(shown, display_id);
} }
void HomeLauncherGestureHandler::OnWindowDestroying(aura::Window* window) { void HomeLauncherGestureHandler::OnWindowDestroying(aura::Window* window) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
namespace ash { namespace ash {
class HomeLauncherGestureHandlerObserver;
class SwipeHomeToOverviewController; class SwipeHomeToOverviewController;
// HomeLauncherGestureHandler makes modifications to a window's transform and // HomeLauncherGestureHandler makes modifications to a window's transform and
...@@ -79,6 +80,9 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -79,6 +80,9 @@ class ASH_EXPORT HomeLauncherGestureHandler
bool IsDragInProgress() const; bool IsDragInProgress() const;
void AddObserver(HomeLauncherGestureHandlerObserver* observer);
void RemoveObserver(HomeLauncherGestureHandlerObserver* obsever);
void NotifyHomeLauncherTargetPositionChanged(bool showing, void NotifyHomeLauncherTargetPositionChanged(bool showing,
int64_t display_id); int64_t display_id);
void NotifyHomeLauncherAnimationComplete(bool shown, int64_t display_id); void NotifyHomeLauncherAnimationComplete(bool shown, int64_t display_id);
...@@ -209,6 +213,8 @@ class ASH_EXPORT HomeLauncherGestureHandler ...@@ -209,6 +213,8 @@ class ASH_EXPORT HomeLauncherGestureHandler
std::unique_ptr<SwipeHomeToOverviewController> std::unique_ptr<SwipeHomeToOverviewController>
swipe_home_to_overview_controller_; swipe_home_to_overview_controller_;
base::ObserverList<HomeLauncherGestureHandlerObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(HomeLauncherGestureHandler); DISALLOW_COPY_AND_ASSIGN(HomeLauncherGestureHandler);
}; };
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_HOME_SCREEN_HOME_LAUNCHER_GESTURE_HANDLER_OBSERVER_H_
#define ASH_HOME_SCREEN_HOME_LAUNCHER_GESTURE_HANDLER_OBSERVER_H_
#include "base/observer_list_types.h"
namespace ash {
class HomeLauncherGestureHandlerObserver : public base::CheckedObserver {
public:
// Called when the HomeLauncher has started to be dragged, or a positional
// animation has begun.
virtual void OnHomeLauncherTargetPositionChanged(bool showing,
int64_t display_id) {}
// Called when the HomeLauncher positional animation has completed.
virtual void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) {
}
};
} // namespace ash
#endif // ASH_HOME_SCREEN_HOME_LAUNCHER_GESTURE_HANDLER_OBSERVER_H_
...@@ -98,15 +98,6 @@ class HomeScreenDelegate { ...@@ -98,15 +98,6 @@ class HomeScreenDelegate {
// whether the launcher will show by the end of animation. // whether the launcher will show by the end of animation.
virtual void NotifyHomeLauncherAnimationTransition(AnimationTrigger trigger, virtual void NotifyHomeLauncherAnimationTransition(AnimationTrigger trigger,
bool launcher_will_show) {} bool launcher_will_show) {}
// Called when the HomeLauncher has started to be dragged, or a positional
// animation has begun.
virtual void OnHomeLauncherTargetPositionChanged(bool showing,
int64_t display_id) {}
// Called when the HomeLauncher positional animation has completed.
virtual void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) {
}
}; };
} // namespace ash } // namespace ash
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/app_list_presenter_impl.h" #include "ash/app_list/app_list_presenter_impl.h"
#include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/home_screen/home_launcher_gesture_handler.h"
#include "ash/home_screen/home_launcher_gesture_handler_observer.h"
#include "ash/home_screen/home_screen_controller.h" #include "ash/home_screen/home_screen_controller.h"
#include "ash/keyboard/keyboard_controller_impl.h" #include "ash/keyboard/keyboard_controller_impl.h"
#include "ash/public/cpp/app_list/app_list_types.h" #include "ash/public/cpp/app_list/app_list_types.h"
...@@ -72,26 +74,26 @@ class PointerMoveLoopWaiter : public ui::CompositorObserver { ...@@ -72,26 +74,26 @@ class PointerMoveLoopWaiter : public ui::CompositorObserver {
DISALLOW_COPY_AND_ASSIGN(PointerMoveLoopWaiter); DISALLOW_COPY_AND_ASSIGN(PointerMoveLoopWaiter);
}; };
class HomeLauncherStateWaiter { class HomeLauncherStateWaiter : public HomeLauncherGestureHandlerObserver {
public: public:
HomeLauncherStateWaiter(bool target_shown, base::OnceClosure closure) HomeLauncherStateWaiter(bool target_shown, base::OnceClosure closure)
: target_shown_(target_shown), closure_(std::move(closure)) { : target_shown_(target_shown), closure_(std::move(closure)) {
Shell::Get() Shell::Get()
->app_list_controller() ->home_screen_controller()
->SetHomeLauncherAnimationCallbackForTesting(base::BindRepeating( ->home_launcher_gesture_handler()
&HomeLauncherStateWaiter::OnHomeLauncherAnimationCompleted, ->AddObserver(this);
base::Unretained(this)));
} }
~HomeLauncherStateWaiter() { ~HomeLauncherStateWaiter() override {
Shell::Get() Shell::Get()
->app_list_controller() ->home_screen_controller()
->SetHomeLauncherAnimationCallbackForTesting(base::NullCallback()); ->home_launcher_gesture_handler()
->RemoveObserver(this);
} }
private: private:
// Passed to AppListControllerImpl as a callback to run when home launcher // HomeLauncherGestureHandlerObserver:
// transition animation is complete. void OnHomeLauncherAnimationComplete(bool shown,
void OnHomeLauncherAnimationCompleted(bool shown) { int64_t display_id) override {
if (shown == target_shown_) { if (shown == target_shown_) {
std::move(closure_).Run(); std::move(closure_).Run();
delete this; delete this;
...@@ -110,15 +112,13 @@ class LauncherStateWaiter { ...@@ -110,15 +112,13 @@ class LauncherStateWaiter {
public: public:
LauncherStateWaiter(ash::AppListViewState state, base::OnceClosure closure) LauncherStateWaiter(ash::AppListViewState state, base::OnceClosure closure)
: target_state_(state), closure_(std::move(closure)) { : target_state_(state), closure_(std::move(closure)) {
Shell::Get() Shell::Get()->app_list_controller()->SetStateTransitionAnimationCallback(
->app_list_controller() base::BindRepeating(&LauncherStateWaiter::OnStateChanged,
->SetStateTransitionAnimationCallbackForTesting(base::BindRepeating( base::Unretained(this)));
&LauncherStateWaiter::OnStateChanged, base::Unretained(this)));
} }
~LauncherStateWaiter() { ~LauncherStateWaiter() {
Shell::Get() Shell::Get()->app_list_controller()->SetStateTransitionAnimationCallback(
->app_list_controller() base::NullCallback());
->SetStateTransitionAnimationCallbackForTesting(base::NullCallback());
} }
void OnStateChanged(ash::AppListViewState state) { void OnStateChanged(ash::AppListViewState state) {
......
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