Commit e7bae45a authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Fix crash when clicking home launcher shelf item.

Bug: 891579
Change-Id: I0151617076021d7ed0923853302faa733782b662
Reviewed-on: https://chromium-review.googlesource.com/c/1258610Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596354}
parent 1d4fbfe0
...@@ -33,16 +33,6 @@ ...@@ -33,16 +33,6 @@
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
namespace {
int64_t GetDisplayIdToShowAppListOn() {
return display::Screen::GetScreen()
->GetDisplayNearestWindow(ash::Shell::GetRootWindowForNewWindows())
.id();
}
} // namespace
namespace ash { namespace ash {
AppListControllerImpl::AppListControllerImpl(ws::WindowService* window_service) AppListControllerImpl::AppListControllerImpl(ws::WindowService* window_service)
...@@ -387,15 +377,14 @@ void AppListControllerImpl::OnAppListItemAdded(app_list::AppListItem* item) { ...@@ -387,15 +377,14 @@ void AppListControllerImpl::OnAppListItemAdded(app_list::AppListItem* item) {
void AppListControllerImpl::OnActiveUserPrefServiceChanged( void AppListControllerImpl::OnActiveUserPrefServiceChanged(
PrefService* /* pref_service */) { PrefService* /* pref_service */) {
if (!IsHomeLauncherEnabledInTabletMode() || if (!IsHomeLauncherEnabledInTabletMode()) {
!display::Display::HasInternalDisplay()) {
DismissAppList(); DismissAppList();
return; return;
} }
// Show the app list after signing in in tablet mode. // Show the app list after signing in in tablet mode.
Show(display::Display::InternalDisplayId(), Show(GetDisplayIdToShowAppListOn(), app_list::AppListShowSource::kTabletMode,
app_list::AppListShowSource::kTabletMode, base::TimeTicks()); base::TimeTicks());
// The app list is not dismissed before switching user, suggestion chips will // The app list is not dismissed before switching user, suggestion chips will
// not be shown. So reset app list state and trigger an initial search here to // not be shown. So reset app list state and trigger an initial search here to
...@@ -536,7 +525,7 @@ void AppListControllerImpl::OnTabletModeStarted() { ...@@ -536,7 +525,7 @@ void AppListControllerImpl::OnTabletModeStarted() {
presenter_.GetView()->OnTabletModeChanged(true); presenter_.GetView()->OnTabletModeChanged(true);
} }
if (!is_home_launcher_enabled_ || !display::Display::HasInternalDisplay()) if (!is_home_launcher_enabled_)
return; return;
SessionController const* session_controller = SessionController const* session_controller =
...@@ -545,8 +534,7 @@ void AppListControllerImpl::OnTabletModeStarted() { ...@@ -545,8 +534,7 @@ void AppListControllerImpl::OnTabletModeStarted() {
return; return;
// Show the app list if the tablet mode starts. // Show the app list if the tablet mode starts.
Show(display::Display::InternalDisplayId(), app_list::kTabletMode, Show(GetDisplayIdToShowAppListOn(), app_list::kTabletMode, base::TimeTicks());
base::TimeTicks());
UpdateHomeLauncherVisibility(); UpdateHomeLauncherVisibility();
Shelf::ForWindow(presenter_.GetWindow())->MaybeUpdateShelfBackground(); Shelf::ForWindow(presenter_.GetWindow())->MaybeUpdateShelfBackground();
} }
...@@ -865,4 +853,16 @@ void AppListControllerImpl::UpdateAssistantVisibility() { ...@@ -865,4 +853,16 @@ void AppListControllerImpl::UpdateAssistantVisibility() {
controller->allowed_state() == mojom::AssistantAllowedState::ALLOWED); controller->allowed_state() == mojom::AssistantAllowedState::ALLOWED);
} }
int64_t AppListControllerImpl::GetDisplayIdToShowAppListOn() {
if (IsHomeLauncherEnabledInTabletMode()) {
return display::Display::HasInternalDisplay()
? display::Display::InternalDisplayId()
: display::Screen::GetScreen()->GetPrimaryDisplay().id();
}
return display::Screen::GetScreen()
->GetDisplayNearestWindow(ash::Shell::GetRootWindowForNewWindows())
.id();
}
} // namespace ash } // namespace ash
...@@ -235,6 +235,8 @@ class ASH_EXPORT AppListControllerImpl ...@@ -235,6 +235,8 @@ class ASH_EXPORT AppListControllerImpl
// Update the visibility of Assistant functionality. // Update the visibility of Assistant functionality.
void UpdateAssistantVisibility(); void UpdateAssistantVisibility();
int64_t GetDisplayIdToShowAppListOn();
ws::WindowService* window_service_; ws::WindowService* window_service_;
base::string16 last_raw_query_; base::string16 last_raw_query_;
......
...@@ -1124,9 +1124,6 @@ class AppListPresenterDelegateHomeLauncherTest ...@@ -1124,9 +1124,6 @@ class AppListPresenterDelegateHomeLauncherTest
app_list_features::kEnableBackgroundBlur}, app_list_features::kEnableBackgroundBlur},
{}); {});
AppListPresenterDelegateTest::SetUp(); AppListPresenterDelegateTest::SetUp();
// Home launcher is only enabled on internal display.
display::test::DisplayManagerTestApi(Shell::Get()->display_manager())
.SetFirstDisplayAsInternalDisplay();
GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->WaitUntilIdle();
} }
......
...@@ -136,6 +136,7 @@ void AppListPresenterImpl::Show(int64_t display_id, ...@@ -136,6 +136,7 @@ void AppListPresenterImpl::Show(int64_t display_id,
delegate_->Init(view, display_id, current_apps_page_); delegate_->Init(view, display_id, current_apps_page_);
SetView(view); SetView(view);
} }
view_->ShowWhenReady();
delegate_->OnShown(display_id); delegate_->OnShown(display_id);
NotifyTargetVisibilityChanged(GetTargetVisibility()); NotifyTargetVisibilityChanged(GetTargetVisibility());
NotifyVisibilityChanged(GetTargetVisibility(), display_id); NotifyVisibilityChanged(GetTargetVisibility(), display_id);
...@@ -279,7 +280,6 @@ void AppListPresenterImpl::SetView(AppListView* view) { ...@@ -279,7 +280,6 @@ void AppListPresenterImpl::SetView(AppListView* view) {
// Sync the |onscreen_keyboard_shown_| in case |view_| is not initiated when // Sync the |onscreen_keyboard_shown_| in case |view_| is not initiated when
// the on-screen is shown. // the on-screen is shown.
view_->set_onscreen_keyboard_shown(delegate_->GetOnScreenKeyboardShown()); view_->set_onscreen_keyboard_shown(delegate_->GetOnScreenKeyboardShown());
view_->ShowWhenReady();
} }
void AppListPresenterImpl::ResetView() { void AppListPresenterImpl::ResetView() {
......
...@@ -75,6 +75,8 @@ void AppListShelfItemDelegate::ItemSelected(std::unique_ptr<ui::Event> event, ...@@ -75,6 +75,8 @@ void AppListShelfItemDelegate::ItemSelected(std::unique_ptr<ui::Event> event,
if (back_action) if (back_action)
Shell::Get()->app_list_controller()->Back(); Shell::Get()->app_list_controller()->Back();
std::move(callback).Run(SHELF_ACTION_APP_LIST_SHOWN, base::nullopt);
} }
void AppListShelfItemDelegate::ExecuteCommand(bool from_context_menu, void AppListShelfItemDelegate::ExecuteCommand(bool from_context_menu,
......
...@@ -598,7 +598,7 @@ void ShelfView::ButtonPressed(views::Button* sender, ...@@ -598,7 +598,7 @@ void ShelfView::ButtonPressed(views::Button* sender,
// Notify the item of its selection; handle the result in AfterItemSelected. // Notify the item of its selection; handle the result in AfterItemSelected.
model_->GetShelfItemDelegate(item.id)->ItemSelected( model_->GetShelfItemDelegate(item.id)->ItemSelected(
ui::Event::Clone(event), GetDisplayIdForView(this), LAUNCH_FROM_UNKNOWN, ui::Event::Clone(event), GetDisplayIdForView(this), LAUNCH_FROM_UNKNOWN,
base::Bind(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(), base::BindOnce(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(),
item, sender, base::Passed(ui::Event::Clone(event)), item, sender, base::Passed(ui::Event::Clone(event)),
ink_drop)); ink_drop));
} }
......
...@@ -2814,6 +2814,9 @@ TEST_F(SplitViewTabDraggingTest, SourceWindowBackgroundTest) { ...@@ -2814,6 +2814,9 @@ TEST_F(SplitViewTabDraggingTest, SourceWindowBackgroundTest) {
EXPECT_TRUE(window3->IsVisible()); EXPECT_TRUE(window3->IsVisible());
EXPECT_TRUE(window4->IsVisible()); EXPECT_TRUE(window4->IsVisible());
if (Shell::Get()->app_list_controller()->IsHomeLauncherEnabledInTabletMode())
EXPECT_TRUE(Shell::Get()->app_list_controller()->IsVisible());
// 1) Start dragging |window1|. |window2| is the source window. // 1) Start dragging |window1|. |window2| is the source window.
std::unique_ptr<WindowResizer> resizer = std::unique_ptr<WindowResizer> resizer =
StartDrag(window1.get(), window2.get()); StartDrag(window1.get(), window2.get());
......
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