Commit 369d8230 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: Unify ways of checking tablet mode

Bug: None
Change-Id: Ie5ce5db5a2dfb13f96ab370102f9f1f56782d663
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049949Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741094}
parent f06e3e2b
......@@ -61,17 +61,13 @@ constexpr int kScrollVelocityThreshold = 6;
// this ratio.
constexpr float kWidthRatio = 0.8f;
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller()->InTabletMode();
}
// Checks if |window| can be hidden or shown with a gesture.
bool CanProcessWindow(aura::Window* window,
HomeLauncherGestureHandler::Mode mode) {
if (!window)
return false;
if (!IsTabletMode())
if (!Shell::Get()->IsInTabletMode())
return false;
if (!window->IsVisible() &&
......@@ -769,7 +765,7 @@ bool HomeLauncherGestureHandler::SetUpWindows(Mode mode, aura::Window* window) {
return false;
}
if (IsTabletMode() && overview_active_on_gesture_start_ &&
if (Shell::Get()->IsInTabletMode() && overview_active_on_gesture_start_ &&
!split_view_active && mode == Mode::kSlideUpToShow) {
active_window_.reset();
return true;
......@@ -936,7 +932,7 @@ bool HomeLauncherGestureHandler::OnDragEnded(const gfx::PointF& location,
} else {
// In clamshell mode, AppListView::SetIsInDrag is called explicitly so it
// does not need the notification from HomeLauncherGestureHandler.
if (IsTabletMode()) {
if (Shell::Get()->IsInTabletMode()) {
HomeScreenDelegate* home_screen_delegate = GetHomeScreenDelegate();
DCHECK(home_screen_delegate);
home_screen_delegate->OnHomeLauncherDragEnd();
......
......@@ -34,7 +34,7 @@ constexpr base::TimeDelta kAssistantAnimationDelay =
// Returns true if the button should appear activatable.
bool CanActivate() {
return Shell::Get()->tablet_mode_controller()->InTabletMode() ||
return Shell::Get()->IsInTabletMode() ||
!Shell::Get()->app_list_controller()->IsVisible();
}
......@@ -178,7 +178,7 @@ void HomeButtonController::StartAssistantAnimation() {
void HomeButtonController::OnAppListShown() {
// 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())
if (!Shell::Get()->IsInTabletMode())
button_->AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
is_showing_app_list_ = true;
RootWindowController::ForWindow(button_->GetWidget()->GetNativeWindow())
......
......@@ -114,17 +114,6 @@ int GetGestureDragThreshold() {
return ShelfConfig::Get()->button_size() / 2;
}
bool IsInTabletMode() {
TabletModeController* tablet_mode_controller =
Shell::Get()->tablet_mode_controller();
// TabletModeController is destructed before ScrollableShelfView.
if (!tablet_mode_controller || !tablet_mode_controller->InTabletMode())
return false;
return true;
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
......@@ -332,7 +321,7 @@ class ScrollableShelfAnimationMetricsReporter
// ui::AnimationMetricsReporter:
void Report(int value) override {
base::UmaHistogramPercentage(kAnimationSmoothnessHistogram, value);
if (IsInTabletMode()) {
if (Shell::Get()->IsInTabletMode()) {
if (Shell::Get()->app_list_controller()->IsVisible()) {
base::UmaHistogramPercentage(
kAnimationSmoothnessTabletLauncherVisibleHistogram, value);
......@@ -550,12 +539,14 @@ void ScrollableShelfView::OnFocusRingActivationChanged(bool activated) {
if (activated) {
focus_ring_activated_ = true;
SetPaneFocusAndFocusDefault();
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat())
if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat())
GetShelf()->shelf_widget()->ForceToShowHotseat();
} else {
// Shows the gradient shader when the focus ring is disabled.
focus_ring_activated_ = false;
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat())
if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat())
GetShelf()->shelf_widget()->ForceToHideHotseat();
}
......@@ -1084,7 +1075,8 @@ void ScrollableShelfView::OnShelfButtonAboutToRequestFocusFromTabTraversal(
ShelfWidget* shelf_widget = GetShelf()->shelf_widget();
// In tablet mode, when the hotseat is not extended but one of the buttons
// gets focused, it should update the visibility of the hotseat.
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat() &&
if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat() &&
!shelf_widget->hotseat_widget()->IsExtended()) {
shelf_widget->shelf_layout_manager()->UpdateVisibilityState();
}
......@@ -1103,7 +1095,8 @@ void ScrollableShelfView::ButtonPressed(views::Button* sender,
void ScrollableShelfView::HandleAccessibleActionScrollToMakeVisible(
ShelfButton* button) {
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat()) {
if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat()) {
// Only in tablet mode with hotseat enabled, may scrollable shelf be hidden.
GetShelf()->shelf_widget()->ForceToShowHotseat();
}
......@@ -1485,7 +1478,7 @@ bool ScrollableShelfView::ProcessGestureEvent(const ui::GestureEvent& event) {
// end.
if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
DCHECK(!presentation_time_recorder_);
if (IsInTabletMode()) {
if (Shell::Get()->IsInTabletMode()) {
if (Shell::Get()->app_list_controller()->IsVisible()) {
presentation_time_recorder_ = CreatePresentationTimeHistogramRecorder(
GetWidget()->GetCompositor(),
......@@ -2004,8 +1997,8 @@ void ScrollableShelfView::UpdateAvailableSpace() {
gfx::Rect ScrollableShelfView::CalculateVisibleSpace(
LayoutStrategy layout_strategy) const {
const bool in_hotseat_tablet =
chromeos::switches::ShouldShowShelfHotseat() && IsInTabletMode();
const bool in_hotseat_tablet = chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode();
if (layout_strategy == kNotShowArrowButtons && !in_hotseat_tablet)
return GetAvailableLocalBounds(/*use_target_bounds=*/false);
......@@ -2040,8 +2033,8 @@ gfx::Rect ScrollableShelfView::CalculateVisibleSpace(
gfx::Insets ScrollableShelfView::CalculateRipplePaddingInsets() const {
// Indicates whether it is in tablet mode with hotseat enabled.
const bool in_hotseat_tablet =
chromeos::switches::ShouldShowShelfHotseat() && IsInTabletMode();
const bool in_hotseat_tablet = chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode();
const int ripple_padding =
ShelfConfig::Get()->scrollable_shelf_ripple_padding();
......@@ -2060,7 +2053,8 @@ gfx::Insets ScrollableShelfView::CalculateRipplePaddingInsets() const {
gfx::RoundedCornersF
ScrollableShelfView::CalculateShelfContainerRoundedCorners() const {
if (!chromeos::switches::ShouldShowShelfHotseat() || !IsInTabletMode())
if (!chromeos::switches::ShouldShowShelfHotseat() ||
!Shell::Get()->IsInTabletMode())
return gfx::RoundedCornersF();
const bool is_horizontal_alignment = GetShelf()->IsHorizontalAlignment();
......
......@@ -27,12 +27,6 @@ namespace {
// dense shelf will be active.
const int kDenseShelfScreenSizeThreshold = 600;
// Returns whether tablet mode is currently active.
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
// Whether the the shelf control buttons must be shown for accessibility
// reasons.
bool ShelfControlsForcedShownForAccessibility() {
......@@ -185,7 +179,8 @@ int ShelfConfig::system_shelf_size() const {
}
int ShelfConfig::hotseat_size() const {
if (!chromeos::switches::ShouldShowShelfHotseat() || !IsTabletMode()) {
if (!chromeos::switches::ShouldShowShelfHotseat() ||
!Shell::Get()->IsInTabletMode()) {
return shelf_size();
}
return is_dense_ ? 48 : 56;
......@@ -211,7 +206,7 @@ int ShelfConfig::control_size() const {
if (!chromeos::switches::ShouldShowShelfHotseat())
return 40;
if (!IsTabletMode())
if (!Shell::Get()->IsInTabletMode())
return 36;
return is_dense_ ? 36 : 40;
......@@ -219,7 +214,7 @@ int ShelfConfig::control_size() const {
int ShelfConfig::control_border_radius() const {
return (chromeos::switches::ShouldShowShelfHotseat() && is_in_app() &&
IsTabletMode())
Shell::Get()->IsInTabletMode())
? control_size() / 2 - in_app_control_button_height_inset_
: control_size() / 2;
}
......@@ -230,7 +225,7 @@ int ShelfConfig::overflow_button_margin() const {
int ShelfConfig::control_button_edge_spacing(bool is_primary_axis_edge) const {
if (is_primary_axis_edge)
return IsTabletMode() ? 8 : 6;
return Shell::Get()->IsInTabletMode() ? 8 : 6;
return (shelf_size() - control_size()) / 2;
}
......@@ -265,7 +260,7 @@ void ShelfConfig::UpdateConfig(bool app_list_visible) {
const gfx::Rect screen_size =
display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
const bool in_tablet_mode = IsTabletMode();
const bool in_tablet_mode = Shell::Get()->IsInTabletMode();
const bool new_is_dense =
chromeos::switches::ShouldShowShelfHotseat() &&
(!in_tablet_mode ||
......@@ -297,7 +292,7 @@ int ShelfConfig::GetShelfSize(bool ignore_in_app_state) const {
return 56;
// In clamshell mode, the shelf always has the same size.
if (!IsTabletMode())
if (!Shell::Get()->IsInTabletMode())
return 48;
if (!ignore_in_app_state && is_in_app())
......@@ -310,7 +305,8 @@ SkColor ShelfConfig::GetShelfControlButtonColor() const {
const session_manager::SessionState session_state =
Shell::Get()->session_controller()->GetSessionState();
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() &&
if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode() &&
session_state == session_manager::SessionState::ACTIVE) {
return is_in_app() ? SK_ColorTRANSPARENT : GetDefaultShelfColor();
} else if (session_state == session_manager::SessionState::OOBE) {
......@@ -359,10 +355,10 @@ SkColor ShelfConfig::GetDefaultShelfColor() const {
AshColorProvider::BaseLayerType layer_type;
if (!chromeos::switches::ShouldShowShelfHotseat()) {
layer_type = IsTabletMode()
layer_type = Shell::Get()->IsInTabletMode()
? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent80;
} else if (IsTabletMode()) {
} else if (Shell::Get()->IsInTabletMode()) {
layer_type = is_in_app() ? AshColorProvider::BaseLayerType::kTransparent90
: AshColorProvider::BaseLayerType::kTransparent60;
} else {
......@@ -377,15 +373,16 @@ SkColor ShelfConfig::GetDefaultShelfColor() const {
int ShelfConfig::GetShelfControlButtonBlurRadius() const {
if (features::IsBackgroundBlurEnabled() &&
chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() &&
!is_in_app()) {
chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode() && !is_in_app()) {
return shelf_blur_radius_;
}
return 0;
}
int ShelfConfig::GetAppIconEndPadding() const {
return (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode())
return (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode())
? app_icon_end_padding_
: 0;
}
......
......@@ -42,8 +42,7 @@ class ShelfControlButtonHighlightPathGenerator
visual_bounds.ClampToCenteredSize(
gfx::SizeF(shelf_config->control_size(), shelf_config->control_size()));
if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->tablet_mode_controller()->InTabletMode() &&
shelf_config->is_in_app()) {
Shell::Get()->IsInTabletMode() && shelf_config->is_in_app()) {
visual_bounds.Inset(0,
shelf_config->in_app_control_button_height_inset());
}
......
......@@ -42,7 +42,6 @@
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/screen_pinning_controller.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/work_area_insets.h"
......@@ -139,15 +138,9 @@ bool IsAppListWindow(const aura::Window* window) {
return parent && parent->id() == kShellWindowId_AppListContainer;
}
bool IsTabletModeEnabled() {
// Shell could be destroying. Shell destroys TabletModeController before
// closing all windows.
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
bool IsHotseatEnabled() {
return IsTabletModeEnabled() && chromeos::switches::ShouldShowShelfHotseat();
return Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat();
}
int GetOffset(int offset, bool from_touchpad) {
......@@ -197,7 +190,7 @@ int GetShelfInset(ShelfVisibilityState visibility_state, int size) {
// window.
aura::Window* GetWindowForDragToHomeOrOverview(
const gfx::Point& location_in_screen) {
if (!IsTabletModeEnabled())
if (!Shell::Get()->IsInTabletMode())
return nullptr;
auto mru_windows =
......@@ -475,7 +468,8 @@ gfx::Rect ShelfLayoutManager::GetIdealBounds() const {
}
gfx::Rect ShelfLayoutManager::GetIdealBoundsForWorkAreaCalculation() const {
if (!IsTabletModeEnabled() || !chromeos::switches::ShouldShowShelfHotseat() ||
if (!Shell::Get()->IsInTabletMode() ||
!chromeos::switches::ShouldShowShelfHotseat() ||
state_.session_state != session_manager::SessionState::ACTIVE) {
return GetIdealBounds();
}
......@@ -787,7 +781,7 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
const bool in_overview =
Shell::Get()->overview_controller() &&
Shell::Get()->overview_controller()->InOverviewSession();
if (IsTabletModeEnabled()) {
if (Shell::Get()->IsInTabletMode()) {
if (app_list_is_visible) {
// If the home launcher is shown or mostly shown, show the home launcher
// background. If it is mostly hidden, show the in-app or overview
......@@ -819,7 +813,8 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
// When a window is maximized, if the auto-hide shelf is enabled and we are
// in clamshell mode, the shelf will keep the default transparent
// background.
if (!IsTabletModeEnabled() && state_.visibility_state == SHELF_AUTO_HIDE)
if (!Shell::Get()->IsInTabletMode() &&
state_.visibility_state == SHELF_AUTO_HIDE)
return ShelfBackgroundType::kDefaultBg;
return ShelfBackgroundType::kMaximized;
......@@ -1583,7 +1578,7 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(bool animate) {
bool ShelfLayoutManager::IsDraggingWindowFromTopOrCaptionArea() const {
// Currently dragging maximized or fullscreen window from the top or the
// caption area is only allowed in tablet mode.
if (!IsTabletModeEnabled())
if (!Shell::Get()->IsInTabletMode())
return false;
// TODO(minch): Check active window directly if removed search field
......@@ -1865,7 +1860,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (shelf_->auto_hide_lock())
return state_.auto_hide_state;
const bool in_tablet_mode = IsTabletModeEnabled();
const bool in_tablet_mode = Shell::Get()->IsInTabletMode();
// Don't let the shelf auto-hide when in tablet mode and Chromevox is on.
if (in_tablet_mode &&
Shell::Get()->accessibility_controller()->spoken_feedback_enabled()) {
......@@ -1937,7 +1932,7 @@ base::Optional<ShelfAutoHideState>
ShelfLayoutManager::CalculateAutoHideStateBasedOnCursorLocation() const {
// No mouse is available in tablet mode. So there is no point to calculate
// the auto-hide state by the cursor location in this scenario.
const bool in_tablet_mode = IsTabletModeEnabled();
const bool in_tablet_mode = Shell::Get()->IsInTabletMode();
if (in_tablet_mode)
return base::nullopt;
......@@ -2023,7 +2018,8 @@ void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
float ShelfLayoutManager::ComputeTargetOpacity(const State& state) const {
// The shelf should not become transparent during the animation to or from
// HomeLauncher.
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletModeEnabled() &&
if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode() &&
Shell::Get()->app_list_controller()->home_launcher_transition_state() !=
AppListControllerImpl::HomeLauncherTransitionState::kFinished) {
return 1.0f;
......@@ -2054,7 +2050,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 (!IsTabletModeEnabled() &&
if (!Shell::Get()->IsInTabletMode() &&
Shell::Get()->app_list_controller()->GetTargetVisibility()) {
return false;
}
......@@ -2258,7 +2254,7 @@ bool ShelfLayoutManager::StartAppListDrag(
float scroll_y_hint) {
// If the home screen is available, gesture dragging is handled by
// HomeLauncherGestureHandler.
if (IsTabletModeEnabled() && event_in_screen.IsGestureEvent())
if (Shell::Get()->IsInTabletMode() && event_in_screen.IsGestureEvent())
return false;
// Fullscreen app list can only be dragged from bottom alignment shelf.
......@@ -2304,7 +2300,7 @@ bool ShelfLayoutManager::StartShelfDrag(const ui::LocatedEvent& event_in_screen,
const gfx::Vector2dF& scroll_hint) {
// Disable the shelf dragging if the fullscreen app list is opened.
if (Shell::Get()->app_list_controller()->IsVisible() &&
!IsTabletModeEnabled())
!Shell::Get()->IsInTabletMode())
return false;
// Also disable shelf drags until the overflow shelf is closed.
......@@ -2430,7 +2426,8 @@ void ShelfLayoutManager::CompleteDrag(const ui::LocatedEvent& event_in_screen) {
window_drag_controller_->FinalizeDraggedWindow();
// Hotseat gestures are meaningful only in tablet mode with hotseat enabled.
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletModeEnabled()) {
if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode()) {
base::Optional<InAppShelfGestures> gesture_to_record =
CalculateHotseatGestureToRecord(window_drag_result,
transitioned_from_overview_to_home,
......@@ -2643,7 +2640,7 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf(
const gfx::Vector2dF& scroll) {
if (!features::IsDragFromShelfToHomeOrOverviewEnabled())
return false;
if (!IsTabletModeEnabled())
if (!Shell::Get()->IsInTabletMode())
return false;
if (drag_status_ != kDragInProgress)
return false;
......
......@@ -33,11 +33,6 @@ namespace {
constexpr base::TimeDelta kButtonOpacityAnimationDuration =
base::TimeDelta::FromMilliseconds(50);
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
// Returns the bounds for the first button shown in this view (the back
// button in tablet mode, the home button otherwise).
gfx::Rect GetFirstButtonBounds(bool is_shelf_horizontal) {
......@@ -68,8 +63,8 @@ bool IsBackButtonShown() {
if (!ShelfConfig::Get()->shelf_controls_shown())
return false;
return chromeos::switches::ShouldShowShelfHotseat()
? IsTabletMode() && ShelfConfig::Get()->is_in_app()
: IsTabletMode();
? Shell::Get()->IsInTabletMode() && ShelfConfig::Get()->is_in_app()
: Shell::Get()->IsInTabletMode();
}
bool IsHomeButtonShown() {
......@@ -185,8 +180,8 @@ void ShelfNavigationWidget::Delegate::UpdateOpaqueBackground() {
return;
}
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() &&
ShelfConfig::Get()->is_in_app()) {
if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode() && ShelfConfig::Get()->is_in_app()) {
opaque_background_.SetVisible(false);
return;
}
......@@ -477,7 +472,8 @@ void ShelfNavigationWidget::UpdateTargetBoundsForGesture() {
const gfx::Point shelf_origin =
shelf_->shelf_widget()->GetTargetBounds().origin();
if (shelf_->IsHorizontalAlignment()) {
if (!IsTabletMode() || !chromeos::switches::ShouldShowShelfHotseat()) {
if (!Shell::Get()->IsInTabletMode() ||
!chromeos::switches::ShouldShowShelfHotseat()) {
target_bounds_.set_y(shelf_origin.y() +
ShelfConfig::Get()->button_spacing());
}
......
......@@ -74,11 +74,6 @@ views::View* FindFirstOrLastFocusableChild(views::View* root,
&dummy_focus_traversable, &dummy_focus_traversable_view);
}
bool IsInTabletMode() {
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
} // namespace
// The contents view of the Shelf. In an active session, this is used to
......@@ -304,7 +299,7 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
const Shelf* shelf = shelf_widget_->shelf();
const ShelfBackgroundType background_type =
shelf_widget_->GetBackgroundType();
const bool tablet_mode = IsInTabletMode();
const bool tablet_mode = Shell::Get()->IsInTabletMode();
const bool in_app = ShelfConfig::Get()->is_in_app();
bool show_opaque_background =
......@@ -350,7 +345,7 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
}
void ShelfWidget::DelegateView::UpdateDragHandle() {
if (!IsInTabletMode() || !ShelfConfig::Get()->is_in_app() ||
if (!Shell::Get()->IsInTabletMode() || !ShelfConfig::Get()->is_in_app() ||
!chromeos::switches::ShouldShowShelfHotseat() ||
hide_background_for_transitions_) {
drag_handle_->SetVisible(false);
......@@ -588,7 +583,7 @@ void ShelfWidget::RegisterHotseatWidget(HotseatWidget* hotseat_widget) {
void ShelfWidget::OnTabletModeChanged() {
// Resets |is_hotseat_forced_to_show| when leaving the tablet mode.
if (!IsInTabletMode())
if (!Shell::Get()->IsInTabletMode())
is_hotseat_forced_to_show_ = false;
}
......
......@@ -416,6 +416,10 @@ void Shell::OnDictationEnded() {
observer.OnDictationEnded();
}
bool Shell::IsInTabletMode() const {
return tablet_mode_controller()->InTabletMode();
}
bool Shell::ShouldSaveDisplaySettings() {
return !(
screen_orientation_controller_->ignore_display_configuration_updates() ||
......
......@@ -284,7 +284,12 @@ class ASH_EXPORT Shell : public SessionObserver,
// Called when dictation is ended.
void OnDictationEnded();
// Test if TabletModeWindowManager is not enabled, and if
// Returns whether the device is currently in tablet mode. If the tablet
// mode controller isn't available, we assume the device is not in
// tablet mode.
bool IsInTabletMode() const;
// Tests if TabletModeWindowManager is not enabled, and if
// TabletModeController is not currently setting a display rotation. Or if
// the |resolution_notification_controller_| is not showing its confirmation
// dialog. If true then changes to display settings can be saved.
......@@ -470,7 +475,7 @@ class ASH_EXPORT Shell : public SessionObserver,
SystemTrayNotifier* system_tray_notifier() {
return system_tray_notifier_.get();
}
TabletModeController* tablet_mode_controller() {
TabletModeController* tablet_mode_controller() const {
return tablet_mode_controller_.get();
}
ToastManagerImpl* toast_manager() { return toast_manager_.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