Commit 2c552b51 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

split view: Move ShowAppCannotSnapToast() to split_view_utils

The present CL moves ShowAppCannotSnapToast() from split_view_controller
to split_view_utils. The latter is a much more natural choice, because
the function is used outside split_view_controller, it does not use
anything inside split_view_controller, and it goes hand in hand with
CanSnapInSplitview() which is already in split_view_utils.

Test: manual
Bug: 970013
Change-Id: I6bd4e2044a0622d5604adbb287045befcdf20eaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1639666Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666054}
parent b459edee
......@@ -507,7 +507,7 @@ void OverviewController::OnOverviewButtonTrayLongPressed(
// Show a toast if the window cannot be snapped.
if (!CanSnapInSplitview(active_window)) {
split_view_controller->ShowAppCannotSnapToast();
ShowAppCannotSnapToast();
return;
}
......
......@@ -246,7 +246,7 @@ void OverviewWindowDragController::ActivateDraggedWindow() {
} else {
split_view_controller_->EndSplitView();
overview_session_->SelectWindow(item_);
split_view_controller_->ShowAppCannotSnapToast();
ShowAppCannotSnapToast();
}
current_drag_behavior_ = DragBehavior::kNoDrag;
UnpauseOcclusionTracker();
......
......@@ -15,9 +15,6 @@
#include "ash/screen_util.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/toast/toast_data.h"
#include "ash/system/toast/toast_manager.h"
#include "ash/wm/desks/desks_controller.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_controller.h"
......@@ -44,7 +41,6 @@
#include "ui/aura/window_delegate.h"
#include "ui/base/class_property.h"
#include "ui/base/hit_test.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/animation/tween.h"
......@@ -80,10 +76,6 @@ constexpr float kBlackScrimOpacity = 0.4f;
// tablet_mode_window_drag_delegate.cc.
constexpr int kDividerSnapDurationMs = 300;
// Toast data.
constexpr char kAppCannotSnapToastId[] = "split_view_app_cannot_snap";
constexpr int kAppCannotSnapToastDurationMs = 2500;
// Histogram names that record presentation time of resize operation with
// following conditions, a) single snapped window, empty overview, b) two
// snapped windows, c) single snapped window and non empty overview.
......@@ -667,14 +659,6 @@ void SplitViewController::EndResize(const gfx::Point& location_in_screen) {
}
}
void SplitViewController::ShowAppCannotSnapToast() {
ash::ToastData toast(
kAppCannotSnapToastId,
l10n_util::GetStringUTF16(IDS_ASH_SPLIT_VIEW_CANNOT_SNAP),
kAppCannotSnapToastDurationMs, base::Optional<base::string16>());
ash::Shell::Get()->toast_manager()->Show(toast);
}
void SplitViewController::EndSplitView(EndReason end_reason) {
if (!InSplitViewMode())
return;
......
......@@ -141,10 +141,6 @@ class ASH_EXPORT SplitViewController : public SplitViewNotifier,
void Resize(const gfx::Point& location_in_screen);
void EndResize(const gfx::Point& location_in_screen);
// Displays a toast notifying users the application selected for split view is
// not compatible.
void ShowAppCannotSnapToast();
// Ends the split view mode.
void EndSplitView(EndReason end_reason = EndReason::kNormal);
......
......@@ -10,12 +10,16 @@
#include "ash/public/cpp/ash_switches.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/toast/toast_data.h"
#include "ash/system/toast/toast_manager.h"
#include "ash/wm/screen_pinning_controller.h"
#include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h"
#include "base/command_line.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animator.h"
......@@ -52,6 +56,10 @@ constexpr base::TimeDelta kWindowTransform =
constexpr float kHighlightOpacity = 0.3f;
constexpr float kPreviewAreaHighlightOpacity = 0.18f;
// Toast data.
constexpr char kAppCannotSnapToastId[] = "split_view_app_cannot_snap";
constexpr int kAppCannotSnapToastDurationMs = 2500;
// Gets the duration, tween type and delay before animation based on |type|.
void GetAnimationValuesForType(
SplitviewAnimationType type,
......@@ -268,6 +276,13 @@ bool CanSnapInSplitview(aura::Window* window) {
return true;
}
void ShowAppCannotSnapToast() {
ash::Shell::Get()->toast_manager()->Show(ash::ToastData(
kAppCannotSnapToastId,
l10n_util::GetStringUTF16(IDS_ASH_SPLIT_VIEW_CANNOT_SNAP),
kAppCannotSnapToastDurationMs, base::Optional<base::string16>()));
}
bool IsPhysicalLeftOrTop(SplitViewController::SnapPosition position) {
DCHECK_NE(SplitViewController::NONE, position);
return position == (IsCurrentScreenOrientationPrimary()
......
......@@ -91,6 +91,10 @@ ASH_EXPORT bool ShouldAllowSplitView();
// tablet mode.
ASH_EXPORT bool CanSnapInSplitview(aura::Window* window);
// Displays a toast notifying users the application selected for split view is
// not compatible.
ASH_EXPORT void ShowAppCannotSnapToast();
ASH_EXPORT bool IsPhysicalLeftOrTop(SplitViewController::SnapPosition position);
} // namespace ash
......
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