Commit 58c2c84a authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS: Get rid of "IsHomeScreenAvailable"

Whether the home screen is available is strictly equivalent to whether
tablet mode is on. I understand the desire for the extra level of
indirection but it doesn't seem like this is changing anytime soon,
and if/when it does, it won't be hard to re-add :-) In the mean time,
I think we should favor readability / understandability.

Bug: 982512
Change-Id: Ifb34f316ae0fe579ee2854b70025a0b2de216d93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1826198Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Auto-Submit: Manu Cornet <manucornet@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700341}
parent aaf6b747
......@@ -64,10 +64,6 @@ namespace ash {
namespace {
bool IsHomeScreenAvailable() {
return Shell::Get()->home_screen_controller()->IsHomeScreenAvailable();
}
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller()->InTabletMode();
}
......@@ -474,7 +470,7 @@ void AppListControllerImpl::OnAppListItemAdded(app_list::AppListItem* item) {
void AppListControllerImpl::OnActiveUserPrefServiceChanged(
PrefService* /* pref_service */) {
if (!IsHomeScreenAvailable()) {
if (!IsTabletMode()) {
DismissAppList();
return;
}
......@@ -552,7 +548,7 @@ void AppListControllerImpl::UpdateYPositionAndOpacity(
int y_position_in_screen,
float background_opacity) {
// Avoid changing app list opacity and position when homecher is enabled.
if (IsHomeScreenAvailable())
if (IsTabletMode())
return;
presenter_.UpdateYPositionAndOpacity(y_position_in_screen,
background_opacity);
......@@ -561,7 +557,7 @@ void AppListControllerImpl::UpdateYPositionAndOpacity(
void AppListControllerImpl::EndDragFromShelf(
ash::AppListViewState app_list_state) {
// Avoid dragging app list when homecher is enabled.
if (IsHomeScreenAvailable())
if (IsTabletMode())
return;
presenter_.EndDragFromShelf(app_list_state);
}
......@@ -590,7 +586,7 @@ ash::AppListViewState AppListControllerImpl::GetAppListViewState() {
}
void AppListControllerImpl::OnShelfAlignmentChanged(aura::Window* root_window) {
if (!IsHomeScreenAvailable())
if (!IsTabletMode())
DismissAppList();
}
......@@ -601,7 +597,7 @@ void AppListControllerImpl::OnShellDestroying() {
}
void AppListControllerImpl::OnOverviewModeStarting() {
if (!IsHomeScreenAvailable())
if (!IsTabletMode())
DismissAppList();
}
......@@ -665,7 +661,6 @@ void AppListControllerImpl::OnDisplayConfigurationChanged() {
// expected if it's enabled and we're still in tablet mode.
// https://crbug.com/900956.
const bool should_be_shown = IsTabletMode();
DCHECK_EQ(should_be_shown, IsHomeScreenAvailable());
if (should_be_shown == GetTargetVisibility())
return;
......@@ -706,7 +701,7 @@ void AppListControllerImpl::OnUiVisibilityChanged(
// When Launcher is closing, we do not want to call
// |ShowEmbeddedAssistantUI(false)|, which will show previous state page
// in Launcher and make the UI flash.
if (IsHomeScreenAvailable()) {
if (IsTabletMode()) {
base::Optional<
app_list::ContentsView::ScopedSetActiveStateAnimationDisabler>
set_active_state_animation_disabler;
......@@ -811,7 +806,7 @@ ash::ShelfAction AppListControllerImpl::OnHomeButtonPressed(
int64_t display_id,
app_list::AppListShowSource show_source,
base::TimeTicks event_time_stamp) {
if (!IsHomeScreenAvailable())
if (!IsTabletMode())
return ToggleAppList(display_id, show_source, event_time_stamp);
bool handled = Shell::Get()->home_screen_controller()->GoHome(display_id);
......@@ -830,9 +825,9 @@ bool AppListControllerImpl::IsShowingEmbeddedAssistantUI() const {
void AppListControllerImpl::UpdateExpandArrowVisibility() {
bool should_show = false;
// Hide the expand arrow view when the home screen is available and there is
// no activatable window on the current active desk.
if (IsHomeScreenAvailable()) {
// Hide the expand arrow view when in tablet mode and there is no activatable
// window on the current active desk.
if (IsTabletMode()) {
should_show = !ash::Shell::Get()
->mru_window_tracker()
->BuildWindowForCycleList(kActiveDesk)
......@@ -884,7 +879,7 @@ void AppListControllerImpl::StartAssistant() {
return;
}
if (!IsHomeScreenAvailable())
if (!IsTabletMode())
DismissAppList();
ash::Shell::Get()->assistant_controller()->ui_controller()->ShowUi(
......@@ -1394,8 +1389,7 @@ void AppListControllerImpl::UpdateAssistantVisibility() {
}
int64_t AppListControllerImpl::GetDisplayIdToShowAppListOn() {
if (IsHomeScreenAvailable() &&
!Shell::Get()->display_manager()->IsInUnifiedMode()) {
if (IsTabletMode() && !Shell::Get()->display_manager()->IsInUnifiedMode()) {
return display::Display::HasInternalDisplay()
? display::Display::InternalDisplayId()
: display::Screen::GetScreen()->GetPrimaryDisplay().id();
......@@ -1407,7 +1401,7 @@ int64_t AppListControllerImpl::GetDisplayIdToShowAppListOn() {
}
void AppListControllerImpl::ResetHomeLauncherIfShown() {
if (!IsHomeScreenAvailable() || !presenter_.IsVisible())
if (!IsTabletMode() || !presenter_.IsVisible())
return;
auto* const keyboard_controller = keyboard::KeyboardUIController::Get();
......@@ -1462,7 +1456,7 @@ aura::Window* AppListControllerImpl::GetContainerForDisplayId(
}
bool AppListControllerImpl::ShouldLauncherShowBehindApps() const {
return IsHomeScreenAvailable() &&
return IsTabletMode() &&
model_->state() != ash::AppListState::kStateEmbeddedAssistant;
}
......
......@@ -58,12 +58,8 @@ HomeScreenController::~HomeScreenController() {
Shell::Get()->overview_controller()->RemoveObserver(this);
}
bool HomeScreenController::IsHomeScreenAvailable() {
return Shell::Get()->tablet_mode_controller()->InTabletMode();
}
void HomeScreenController::Show() {
DCHECK(IsHomeScreenAvailable());
DCHECK(Shell::Get()->tablet_mode_controller()->InTabletMode());
if (!Shell::Get()->session_controller()->IsActiveUserSessionStarted())
return;
......@@ -77,7 +73,7 @@ void HomeScreenController::Show() {
}
bool HomeScreenController::GoHome(int64_t display_id) {
DCHECK(IsHomeScreenAvailable());
DCHECK(Shell::Get()->tablet_mode_controller()->InTabletMode());
if (home_launcher_gesture_handler_->ShowHomeLauncher(
Shell::Get()->display_manager()->GetDisplayForId(display_id))) {
......@@ -160,7 +156,7 @@ void HomeScreenController::OnWallpaperPreviewEnded() {
}
void HomeScreenController::UpdateVisibility() {
if (!IsHomeScreenAvailable())
if (!Shell::Get()->tablet_mode_controller()->InTabletMode())
return;
aura::Window* window = delegate_->GetHomeScreenWindow();
......
......@@ -27,10 +27,6 @@ class ASH_EXPORT HomeScreenController : public OverviewObserver,
HomeScreenController();
~HomeScreenController() override;
// Returns true if the home screen can be shown (generally corresponds to the
// device being in tablet mode).
bool IsHomeScreenAvailable();
// Shows the home screen.
void Show();
......
......@@ -31,7 +31,7 @@ namespace {
// Returns true if the button should appear activatable.
bool CanActivate() {
return Shell::Get()->home_screen_controller()->IsHomeScreenAvailable() ||
return Shell::Get()->tablet_mode_controller()->InTabletMode() ||
!Shell::Get()->app_list_controller()->IsVisible();
}
......@@ -172,9 +172,9 @@ void HomeButtonController::StartAssistantAnimation() {
}
void HomeButtonController::OnAppListShown() {
// Do not show a highlight if the home screen is available, since the home
// screen view is always open in the background.
if (!Shell::Get()->home_screen_controller()->IsHomeScreenAvailable())
// Do not show a highlight in tablet mode, since the home screen view is
// always open in the background.
if (!Shell::Get()->tablet_mode_controller()->InTabletMode())
button_->AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
is_showing_app_list_ = true;
RootWindowController::ForWindow(button_->GetWidget()->GetNativeWindow())
......
......@@ -106,25 +106,14 @@ bool IsAppListWindow(const aura::Window* window) {
bool IsTabletModeEnabled() {
// Shell could be destroying. Shell destroys TabletModeController before
// closing all windows.
if (!Shell::Get()->tablet_mode_controller())
return false;
return Shell::Get()->tablet_mode_controller()->InTabletMode();
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
bool IsHotseatEnabled() {
return IsTabletModeEnabled() && chromeos::switches::ShouldShowShelfHotseat();
}
bool IsHomeScreenAvailable() {
// Shell could be destroying. Shell destroys HomeScreenController before
// closing all windows.
if (!Shell::Get() || !Shell::Get()->home_screen_controller())
return false;
return Shell::Get()->home_screen_controller()->IsHomeScreenAvailable();
}
// Returns the |WorkspaceWindowState| of the currently active desk on the root
// window of |shelf_window|.
WorkspaceWindowState GetShelfWorkspaceWindowState(aura::Window* shelf_window) {
......@@ -632,7 +621,7 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
->home_screen_controller()
->home_launcher_gesture_handler()
->GetActiveWindow());
if (IsHomeScreenAvailable()) {
if (IsTabletModeEnabled()) {
// If the home launcher is shown, being animated, or dragged, show the
// default background.
if (is_app_list_visible_ || home_launcher_animation_state_ == kShowing)
......@@ -1638,7 +1627,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (shelf_->auto_hide_lock())
return state_.auto_hide_state;
if (shelf_widget_->IsShowingAppList() && !IsHomeScreenAvailable())
if (shelf_widget_->IsShowingAppList() && !IsTabletModeEnabled())
return SHELF_AUTO_HIDE_SHOWN;
if (shelf_widget_->status_area_widget() &&
......@@ -1781,7 +1770,7 @@ float ShelfLayoutManager::ComputeTargetOpacity(const State& state) const {
bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const {
// If the non-fullscreen app list should be shown, the shelf should not be
// hidden.
if (!IsHomeScreenAvailable() &&
if (!IsTabletModeEnabled() &&
Shell::Get()->app_list_controller()->GetTargetVisibility()) {
return false;
}
......@@ -1957,7 +1946,7 @@ bool ShelfLayoutManager::StartAppListDrag(
float scroll_y_hint) {
// If the home screen is available, gesture dragging is handled by
// HomeLauncherGestureHandler.
if (IsHomeScreenAvailable() && event_in_screen.IsGestureEvent())
if (IsTabletModeEnabled() && event_in_screen.IsGestureEvent())
return false;
// Fullscreen app list can only be dragged from bottom alignment shelf.
......@@ -2002,7 +1991,7 @@ bool ShelfLayoutManager::StartAppListDrag(
bool ShelfLayoutManager::StartShelfDrag(
const ui::LocatedEvent& event_in_screen) {
// Disable the shelf dragging if the fullscreen app list is opened.
if (is_app_list_visible_ && !IsHomeScreenAvailable())
if (is_app_list_visible_ && !IsTabletModeEnabled())
return false;
// Also disable shelf drags until the overflow shelf is closed.
......
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