Commit c0ab0467 authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Cros: Dismiss app list when tapping on the shelf

Bug: 923481
Change-Id: I60cb8729b9d423858afe6c15b47da67b98b58e6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131043
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755479}
parent a7fc1f50
...@@ -1054,13 +1054,13 @@ void AppListControllerImpl::SetHomeLauncherAnimationCallbackForTesting( ...@@ -1054,13 +1054,13 @@ void AppListControllerImpl::SetHomeLauncherAnimationCallbackForTesting(
home_launcher_animation_callback_ = std::move(callback); home_launcher_animation_callback_ = std::move(callback);
} }
void AppListControllerImpl::RecordShelfAppLaunched( void AppListControllerImpl::RecordShelfAppLaunched() {
base::Optional<AppListViewState> recorded_app_list_view_state,
base::Optional<bool> recorded_home_launcher_shown) {
RecordAppListAppLaunched( RecordAppListAppLaunched(
AppListLaunchedFrom::kLaunchedFromShelf, AppListLaunchedFrom::kLaunchedFromShelf,
recorded_app_list_view_state.value_or(GetAppListViewState()), recorded_app_list_view_state_.value_or(GetAppListViewState()),
IsTabletMode(), recorded_home_launcher_shown.value_or(last_visible_)); IsTabletMode(), recorded_app_list_visibility_.value_or(last_visible_));
recorded_app_list_view_state_ = base::nullopt;
recorded_app_list_visibility_ = base::nullopt;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -1766,4 +1766,9 @@ void AppListControllerImpl::UpdateTrackedAppWindow() { ...@@ -1766,4 +1766,9 @@ void AppListControllerImpl::UpdateTrackedAppWindow() {
tracked_app_window_->AddObserver(this); tracked_app_window_->AddObserver(this);
} }
void AppListControllerImpl::RecordAppListState() {
recorded_app_list_view_state_ = GetAppListViewState();
recorded_app_list_visibility_ = last_visible_;
}
} // namespace ash } // namespace ash
...@@ -333,9 +333,7 @@ class ASH_EXPORT AppListControllerImpl : public AppListController, ...@@ -333,9 +333,7 @@ class ASH_EXPORT AppListControllerImpl : public AppListController,
void SetHomeLauncherAnimationCallbackForTesting( void SetHomeLauncherAnimationCallbackForTesting(
HomeLauncherAnimationCallback callback); HomeLauncherAnimationCallback callback);
void RecordShelfAppLaunched( void RecordShelfAppLaunched();
base::Optional<AppListViewState> recorded_app_list_view_state,
base::Optional<bool> home_launcher_shown);
// Updates which container the launcher window should be in. // Updates which container the launcher window should be in.
void UpdateLauncherContainer( void UpdateLauncherContainer(
...@@ -351,6 +349,10 @@ class ASH_EXPORT AppListControllerImpl : public AppListController, ...@@ -351,6 +349,10 @@ class ASH_EXPORT AppListControllerImpl : public AppListController,
aura::Window* GetContainerForDisplayId( aura::Window* GetContainerForDisplayId(
base::Optional<int64_t> display_id = base::nullopt); base::Optional<int64_t> display_id = base::nullopt);
// Methods for recording the state of the app list before it changes in order
// to record metrics.
void RecordAppListState();
private: private:
// HomeScreenDelegate: // HomeScreenDelegate:
void OnHomeLauncherDragStart() override; void OnHomeLauncherDragStart() override;
...@@ -444,6 +446,16 @@ class ASH_EXPORT AppListControllerImpl : public AppListController, ...@@ -444,6 +446,16 @@ class ASH_EXPORT AppListControllerImpl : public AppListController,
// visibility animation to finish. Should only be used in tablet mode. // visibility animation to finish. Should only be used in tablet mode.
HomeLauncherAnimationCallback home_launcher_animation_callback_; HomeLauncherAnimationCallback home_launcher_animation_callback_;
// The AppListViewState at the moment it was recorded, used to record app
// launching metrics. This allows an accurate AppListViewState to be recorded
// before AppListViewState changes.
base::Optional<AppListViewState> recorded_app_list_view_state_;
// Whether the applist was shown at the moment it was recorded, used to record
// app launching metrics. This is recorded because AppList visibility can
// change before the metric is recorded.
base::Optional<bool> recorded_app_list_visibility_;
// ScopedClosureRunner which while in scope keeps background blur in home // ScopedClosureRunner which while in scope keeps background blur in home
// screen (in particular, apps container suggestion chips background) // screen (in particular, apps container suggestion chips background)
// disabled. Set while home screen transitions are in progress. // disabled. Set while home screen transitions are in progress.
......
...@@ -250,18 +250,20 @@ void AppListPresenterDelegateImpl::ProcessLocatedEvent( ...@@ -250,18 +250,20 @@ void AppListPresenterDelegateImpl::ProcessLocatedEvent(
!switches::ShouldNotDismissOnBlur() && !IsTabletMode()) { !switches::ShouldNotDismissOnBlur() && !IsTabletMode()) {
const aura::Window* status_window = const aura::Window* status_window =
shelf->shelf_widget()->status_area_widget()->GetNativeWindow(); shelf->shelf_widget()->status_area_widget()->GetNativeWindow();
// Don't dismiss the auto-hide shelf if event happened in status area. Then
// the event can still be propagated to the status area tray to open the
// corresponding tray bubble.
base::Optional<Shelf::ScopedAutoHideLock> auto_hide_lock;
if (status_window && status_window->Contains(target))
auto_hide_lock.emplace(shelf);
// Keep the app list open if the event happened in the shelf area.
const aura::Window* hotseat_window = const aura::Window* hotseat_window =
shelf->hotseat_widget()->GetNativeWindow(); shelf->hotseat_widget()->GetNativeWindow();
if (!hotseat_window || !hotseat_window->Contains(target)) // Don't dismiss the auto-hide shelf if event happened in status area or the
presenter_->Dismiss(event->time_stamp()); // hotseat. Then the event can still be propagated.
base::Optional<Shelf::ScopedAutoHideLock> auto_hide_lock;
if ((status_window && status_window->Contains(target)) ||
(hotseat_window && hotseat_window->Contains(target))) {
auto_hide_lock.emplace(shelf);
}
// Record the current AppListViewState to be used later for metrics. The
// AppListViewState will change on app launch, so this will record the
// AppListViewState before the app was launched.
controller_->RecordAppListState();
presenter_->Dismiss(event->time_stamp());
} }
} }
......
...@@ -2202,11 +2202,11 @@ TEST_F(AppListPresenterDelegateTest, TapAutoHideShelfWithAppListOpened) { ...@@ -2202,11 +2202,11 @@ TEST_F(AppListPresenterDelegateTest, TapAutoHideShelfWithAppListOpened) {
GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckVisibility(true);
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
// Test that tapping the auto-hidden shelf keeps the app list and shelf // Test that tapping the auto-hidden shelf keeps shelf visible but dismiss the
// visible. // app list.
generator->GestureTapAt( generator->GestureTapAt(
shelf->GetShelfViewForTesting()->GetBoundsInScreen().CenterPoint()); shelf->GetShelfViewForTesting()->GetBoundsInScreen().CenterPoint());
GetAppListTestHelper()->CheckVisibility(true); GetAppListTestHelper()->CheckVisibility(false);
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
} }
......
...@@ -41,9 +41,7 @@ void ShelfApplicationMenuModel::ExecuteCommand(int command_id, ...@@ -41,9 +41,7 @@ void ShelfApplicationMenuModel::ExecuteCommand(int command_id,
if (delegate_) { if (delegate_) {
// Record app launch when selecting window to open from disambiguation // Record app launch when selecting window to open from disambiguation
// menu. // menu.
Shell::Get()->app_list_controller()->RecordShelfAppLaunched( Shell::Get()->app_list_controller()->RecordShelfAppLaunched();
base::nullopt /* recorded_app_list_view_state */,
base::nullopt /* recorded_home_launcher_shown */);
// The display hosting the menu is irrelevant, windows activate in-place. // The display hosting the menu is irrelevant, windows activate in-place.
delegate_->ExecuteCommand(false /*from_context_menu*/, command_id, delegate_->ExecuteCommand(false /*from_context_menu*/, command_id,
......
...@@ -117,9 +117,7 @@ void ShelfContextMenuModel::ExecuteCommand(int command_id, int event_flags) { ...@@ -117,9 +117,7 @@ void ShelfContextMenuModel::ExecuteCommand(int command_id, int event_flags) {
default: default:
if (delegate_) { if (delegate_) {
if (IsCommandIdAnAppLaunch(command_id)) { if (IsCommandIdAnAppLaunch(command_id)) {
shell->app_list_controller()->RecordShelfAppLaunched( shell->app_list_controller()->RecordShelfAppLaunched();
base::nullopt /* recorded_app_list_view_state */,
base::nullopt /* recorded_home_launcher_shown */);
} }
delegate_->ExecuteCommand(true, command_id, event_flags, display_id_); delegate_->ExecuteCommand(true, command_id, event_flags, display_id_);
......
...@@ -589,7 +589,6 @@ void ShelfView::OnShelfButtonAboutToRequestFocusFromTabTraversal( ...@@ -589,7 +589,6 @@ void ShelfView::OnShelfButtonAboutToRequestFocusFromTabTraversal(
void ShelfView::ButtonPressed(views::Button* sender, void ShelfView::ButtonPressed(views::Button* sender,
const ui::Event& event, const ui::Event& event,
views::InkDrop* ink_drop) { views::InkDrop* ink_drop) {
if (!ShouldEventActivateButton(sender, event)) { if (!ShouldEventActivateButton(sender, event)) {
ink_drop->SnapToHidden(); ink_drop->SnapToHidden();
return; return;
...@@ -640,14 +639,6 @@ void ShelfView::ButtonPressed(views::Button* sender, ...@@ -640,14 +639,6 @@ void ShelfView::ButtonPressed(views::Button* sender,
break; break;
} }
// Record the current AppListViewState to be used later for metrics. The
// AppListViewState will change on app launch, so this will record the
// AppListViewState before the app was launched.
recorded_app_list_view_state_ =
Shell::Get()->app_list_controller()->GetAppListViewState();
app_list_visibility_before_app_launch_ =
Shell::Get()->app_list_controller()->IsVisible(GetDisplayIdForView(this));
// Run AfterItemSelected directly if the item has no delegate (ie. in tests). // Run AfterItemSelected directly if the item has no delegate (ie. in tests).
const ShelfItem& item = model_->items()[last_pressed_index_]; const ShelfItem& item = model_->items()[last_pressed_index_];
if (!model_->GetShelfItemDelegate(item.id)) { if (!model_->GetShelfItemDelegate(item.id)) {
...@@ -1547,8 +1538,7 @@ void ShelfView::OnFadeOutAnimationEnded() { ...@@ -1547,8 +1538,7 @@ void ShelfView::OnFadeOutAnimationEnded() {
StartFadeInLastVisibleItem(); StartFadeInLastVisibleItem();
} }
void ShelfView::StartFadeInLastVisibleItem() { void ShelfView::StartFadeInLastVisibleItem() {}
}
gfx::Rect ShelfView::GetMenuAnchorRect(const views::View& source, gfx::Rect ShelfView::GetMenuAnchorRect(const views::View& source,
const gfx::Point& location, const gfx::Point& location,
...@@ -1914,8 +1904,7 @@ void ShelfView::AfterItemSelected(const ShelfItem& item, ...@@ -1914,8 +1904,7 @@ void ShelfView::AfterItemSelected(const ShelfItem& item,
// Record AppList metric for any action considered an app launch. // Record AppList metric for any action considered an app launch.
if (action == SHELF_ACTION_NEW_WINDOW_CREATED || if (action == SHELF_ACTION_NEW_WINDOW_CREATED ||
action == SHELF_ACTION_WINDOW_ACTIVATED) { action == SHELF_ACTION_WINDOW_ACTIVATED) {
Shell::Get()->app_list_controller()->RecordShelfAppLaunched( Shell::Get()->app_list_controller()->RecordShelfAppLaunched();
recorded_app_list_view_state_, app_list_visibility_before_app_launch_);
} }
// The app list handles its own ink drop effect state changes. // The app list handles its own ink drop effect state changes.
......
...@@ -611,16 +611,6 @@ class ASH_EXPORT ShelfView : public views::AccessiblePaneView, ...@@ -611,16 +611,6 @@ class ASH_EXPORT ShelfView : public views::AccessiblePaneView,
// Used to call SpeedUpDragScrolling. // Used to call SpeedUpDragScrolling.
base::OneShotTimer speed_up_drag_scrolling_; base::OneShotTimer speed_up_drag_scrolling_;
// The AppListViewState recorded before a button press, used to record app
// launching metrics. This allows an accurate AppListViewState to be recorded
// before AppListViewState changes.
AppListViewState recorded_app_list_view_state_;
// Whether the applist was shown before a button press, used to record app
// launching metrics. This is recorded because AppList visibility can change
// before the metric is recorded.
bool app_list_visibility_before_app_launch_ = false;
// Whether this view should focus its last focusable child (instead of its // Whether this view should focus its last focusable child (instead of its
// first) when focused. // first) when focused.
bool default_last_focusable_child_ = false; bool default_last_focusable_child_ = false;
......
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