diff --git a/ash/BUILD.gn b/ash/BUILD.gn index fa3929d44b672b..e144c2426a464d 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -527,6 +527,8 @@ component("ash") { "drag_drop/scoped_drag_drop_observer.h", "drag_drop/tab_drag_drop_delegate.cc", "drag_drop/tab_drag_drop_delegate.h", + "drag_drop/tab_drag_drop_windows_hider.cc", + "drag_drop/tab_drag_drop_windows_hider.h", "drag_drop/toplevel_window_drag_delegate.h", "events/accessibility_event_rewriter.cc", "events/accessibility_event_rewriter.h", @@ -2287,8 +2289,6 @@ component("ash") { "wm/overview/delayed_animation_observer.h", "wm/overview/delayed_animation_observer_impl.cc", "wm/overview/delayed_animation_observer_impl.h", - "wm/overview/drop_target_view.cc", - "wm/overview/drop_target_view.h", "wm/overview/overview_animation_state_waiter.cc", "wm/overview/overview_animation_state_waiter.h", "wm/overview/overview_constants.h", @@ -2390,8 +2390,6 @@ component("ash") { "wm/tablet_mode/internal_input_devices_event_blocker.h", "wm/tablet_mode/scoped_skip_user_session_blocked_check.cc", "wm/tablet_mode/scoped_skip_user_session_blocked_check.h", - "wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.cc", - "wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h", "wm/tablet_mode/tablet_mode_controller.cc", "wm/tablet_mode/tablet_mode_controller.h", "wm/tablet_mode/tablet_mode_multitask_cue.cc", @@ -2945,6 +2943,7 @@ test("ash_unittests") { "drag_drop/drag_drop_unittest.cc", "drag_drop/drag_image_view_unittest.cc", "drag_drop/tab_drag_drop_delegate_unittest.cc", + "drag_drop/tab_drag_drop_windows_hider_unittest.cc", "events/accessibility_event_rewriter_unittest.cc", "events/keyboard_capability_unittest.cc", "events/keyboard_driven_event_rewriter_unittest.cc", @@ -3419,7 +3418,6 @@ test("ash_unittests") { "wm/system_gesture_event_filter_unittest.cc", "wm/system_modal_container_layout_manager_unittest.cc", "wm/tablet_mode/accelerometer_test_data_literals.cc", - "wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider_unittest.cc", "wm/tablet_mode/tablet_mode_controller_unittest.cc", "wm/tablet_mode/tablet_mode_multitask_cue_unittest.cc", "wm/tablet_mode/tablet_mode_multitask_menu_event_handler_unittest.cc", diff --git a/ash/drag_drop/tab_drag_drop_delegate.cc b/ash/drag_drop/tab_drag_drop_delegate.cc index edb291d1b177b2..87340ce3fa9b39 100644 --- a/ash/drag_drop/tab_drag_drop_delegate.cc +++ b/ash/drag_drop/tab_drag_drop_delegate.cc @@ -6,6 +6,7 @@ #include "ash/constants/app_types.h" #include "ash/constants/ash_features.h" +#include "ash/drag_drop/tab_drag_drop_windows_hider.h" #include "ash/public/cpp/new_window_delegate.h" #include "ash/public/cpp/window_properties.h" #include "ash/screen_util.h" @@ -17,7 +18,6 @@ #include "ash/wm/splitview/split_view_controller.h" #include "ash/wm/splitview/split_view_drag_indicators.h" #include "ash/wm/splitview/split_view_utils.h" -#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h" #include "ash/wm/wm_metrics.h" #include "base/pickle.h" #include "base/strings/utf_string_conversions.h" @@ -300,9 +300,7 @@ void TabDragDropDelegate::UpdateSourceWindowBoundsIfNecessary( return; if (!windows_hider_) { - windows_hider_ = - std::make_unique( - source_window_, nullptr); + windows_hider_ = std::make_unique(source_window_); } gfx::Rect new_source_window_bounds; diff --git a/ash/drag_drop/tab_drag_drop_delegate.h b/ash/drag_drop/tab_drag_drop_delegate.h index 90f10133775f23..dfd05b02b0e9d0 100644 --- a/ash/drag_drop/tab_drag_drop_delegate.h +++ b/ash/drag_drop/tab_drag_drop_delegate.h @@ -9,6 +9,7 @@ #include "ash/ash_export.h" #include "ash/drag_drop/drag_drop_capture_delegate.h" +#include "ash/drag_drop/tab_drag_drop_windows_hider.h" #include "ash/wm/splitview/split_view_controller.h" #include "ui/aura/window_observer.h" #include "ui/gfx/geometry/point.h" @@ -20,12 +21,12 @@ class Window; namespace ui { class OSExchangeData; class PresentationTimeRecorder; -} +} // namespace ui namespace ash { class SplitViewDragIndicators; -class TabletModeBrowserWindowDragSessionWindowsHider; +class TabDragDropWindowsHider; // Provides special handling for Chrome tab drags on behalf of // DragDropController. This must be created at the beginning of a tab drag and @@ -105,8 +106,7 @@ class ASH_EXPORT TabDragDropDelegate : public DragDropCaptureDelegate, const gfx::Point start_location_in_screen_; std::unique_ptr split_view_drag_indicators_; - std::unique_ptr - windows_hider_; + std::unique_ptr windows_hider_; // Presentation time recorder for tab dragging in tablet mode with webui // tab strip enable. diff --git a/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.cc b/ash/drag_drop/tab_drag_drop_windows_hider.cc similarity index 74% rename from ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.cc rename to ash/drag_drop/tab_drag_drop_windows_hider.cc index aed62d2a1e947e..82e6d533905c3f 100644 --- a/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.cc +++ b/ash/drag_drop/tab_drag_drop_windows_hider.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h" +#include "ash/drag_drop/tab_drag_drop_windows_hider.h" #include @@ -21,15 +21,9 @@ namespace ash { -TabletModeBrowserWindowDragSessionWindowsHider:: - TabletModeBrowserWindowDragSessionWindowsHider(aura::Window* source_window, - aura::Window* dragged_window) - : source_window_(source_window), dragged_window_(dragged_window) { +TabDragDropWindowsHider::TabDragDropWindowsHider(aura::Window* source_window) + : source_window_(source_window) { DCHECK(source_window_); - if (dragged_window_) { - DCHECK_EQ(source_window_, - dragged_window_->GetProperty(kTabDraggingSourceWindowKey)); - } root_window_ = source_window_->GetRootWindow(); @@ -41,8 +35,7 @@ TabletModeBrowserWindowDragSessionWindowsHider:: std::vector windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList(kActiveDesk); for (aura::Window* window : windows) { - if (window == dragged_window_ || window == source_window_ || - window->GetRootWindow() != root_window_) { + if (window == source_window_ || window->GetRootWindow() != root_window_) { continue; } @@ -63,11 +56,11 @@ TabletModeBrowserWindowDragSessionWindowsHider:: ->SetWallpaperBlur(wallpaper_constants::kOverviewBlur); } -TabletModeBrowserWindowDragSessionWindowsHider:: - ~TabletModeBrowserWindowDragSessionWindowsHider() { +TabDragDropWindowsHider::~TabDragDropWindowsHider() { // It might be possible that |source_window_| is destroyed during dragging. - if (source_window_) + if (source_window_) { WindowBackdrop::Get(source_window_)->RestoreBackdrop(); + } for (auto iter = window_visibility_map_.begin(); iter != window_visibility_map_.end(); ++iter) { @@ -90,8 +83,7 @@ TabletModeBrowserWindowDragSessionWindowsHider:: ->SetWallpaperBlur(wallpaper_constants::kClear); } -void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowDestroying( - aura::Window* window) { +void TabDragDropWindowsHider::OnWindowDestroying(aura::Window* window) { if (window == source_window_) { source_window_ = nullptr; return; @@ -100,13 +92,13 @@ void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowDestroying( window->RemoveObserver(this); window_visibility_map_.erase(window); } -void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowVisibilityChanged( - aura::Window* window, - bool visible) { +void TabDragDropWindowsHider::OnWindowVisibilityChanged(aura::Window* window, + bool visible) { // The window object is not necessarily the one that is being observed. // So we only take action if the window is currently being observed. - if (window_visibility_map_.count(window) == 0) + if (window_visibility_map_.count(window) == 0) { return; + } if (visible) { // Do not let |window| change to visible during the lifetime of |this|. @@ -119,8 +111,7 @@ void TabletModeBrowserWindowDragSessionWindowsHider::OnWindowVisibilityChanged( // ignored. } -int TabletModeBrowserWindowDragSessionWindowsHider:: - GetWindowVisibilityMapSizeForTesting() const { +int TabDragDropWindowsHider::GetWindowVisibilityMapSizeForTesting() const { return window_visibility_map_.size(); } diff --git a/ash/drag_drop/tab_drag_drop_windows_hider.h b/ash/drag_drop/tab_drag_drop_windows_hider.h new file mode 100644 index 00000000000000..749097872b72c1 --- /dev/null +++ b/ash/drag_drop/tab_drag_drop_windows_hider.h @@ -0,0 +1,52 @@ +// Copyright 2020 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_DRAG_DROP_TAB_DRAG_DROP_WINDOWS_HIDER_H_ +#define ASH_DRAG_DROP_TAB_DRAG_DROP_WINDOWS_HIDER_H_ + +#include + +#include "ash/ash_export.h" +#include "ui/aura/window.h" +#include "ui/aura/window_observer.h" + +namespace ash { + +// Hides all visible windows except the source window from which the webui tab +// drag originates, and restores the windows' visibility upon its destruction. +// It also blurs and darkens the background, hides the home launcher if home +// launcher is enabled. Only need to do so if we need to scale up and down the +// source window when dragging a web ui tab out of it. +class ASH_EXPORT TabDragDropWindowsHider : public aura::WindowObserver { + public: + explicit TabDragDropWindowsHider(aura::Window* source_window); + + TabDragDropWindowsHider(const TabDragDropWindowsHider&) = delete; + TabDragDropWindowsHider& operator=(const TabDragDropWindowsHider&) = delete; + + ~TabDragDropWindowsHider() override; + + // aura::WindowObserver: + void OnWindowDestroying(aura::Window* window) override; + void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; + + int GetWindowVisibilityMapSizeForTesting() const; + + private: + // The window from which the drag originated. + aura::Window* source_window_; + + // The root window the drag is taking place within. Guaranteed to be + // non-null during the lifetime of |this|. + aura::Window* root_window_; + + // Maintains the map between windows and their visibilities. All windows + // except the dragged window and the source window should stay hidden during + // dragging. + std::map window_visibility_map_; +}; + +} // namespace ash + +#endif // ASH_DRAG_DROP_TAB_DRAG_DROP_WINDOWS_HIDER_H_ diff --git a/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider_unittest.cc b/ash/drag_drop/tab_drag_drop_windows_hider_unittest.cc similarity index 72% rename from ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider_unittest.cc rename to ash/drag_drop/tab_drag_drop_windows_hider_unittest.cc index 8223a732d88526..d9483ee97ab7e1 100644 --- a/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider_unittest.cc +++ b/ash/drag_drop/tab_drag_drop_windows_hider_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h" +#include "ash/drag_drop/tab_drag_drop_windows_hider.h" #include "ash/test/ash_test_base.h" namespace ash { -class TabletModeBrowserWindowDragSessionWindowsHiderTest : public AshTestBase { +class TabDragDropWindowsHiderTest : public AshTestBase { public: // AshTestBase: void SetUp() override { @@ -26,16 +26,14 @@ class TabletModeBrowserWindowDragSessionWindowsHiderTest : public AshTestBase { }; // Test for crbug.com/1330038 . -TEST_F(TabletModeBrowserWindowDragSessionWindowsHiderTest, - WindowVisibilityChangedDuringDrag) { +TEST_F(TabDragDropWindowsHiderTest, WindowVisibilityChangedDuringDrag) { std::unique_ptr source_window = CreateToplevelTestWindow(); // Create a sub window and hide it. std::unique_ptr sub_window = CreateTestWindow(); dummy_window_->AddChild(sub_window.get()); sub_window->Hide(); - auto hider = std::make_unique( - source_window.get(), nullptr); + auto hider = std::make_unique(source_window.get()); int size = hider->GetWindowVisibilityMapSizeForTesting(); // Show the sub window. Make sure the window observer list size remains the diff --git a/ash/resources/vector_icons/BUILD.gn b/ash/resources/vector_icons/BUILD.gn index a945edf775377a..0a742b2e2cdebc 100644 --- a/ash/resources/vector_icons/BUILD.gn +++ b/ash/resources/vector_icons/BUILD.gn @@ -222,7 +222,6 @@ aggregate_vector_icons("ash_vector_icons") { "notification_timer.icon", "overflow_shelf_left.icon", "overflow_shelf_right.icon", - "overview_drop_target_plus.icon", "overview_window_close.icon", "paint_brush.icon", "palette_action_create_note.icon", diff --git a/ash/resources/vector_icons/overview_drop_target_plus.icon b/ash/resources/vector_icons/overview_drop_target_plus.icon deleted file mode 100644 index 5a05f62bc4e857..00000000000000 --- a/ash/resources/vector_icons/overview_drop_target_plus.icon +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -CANVAS_DIMENSIONS, 48, -MOVE_TO, 38, 26, -H_LINE_TO, 26, -R_V_LINE_TO, 12, -R_H_LINE_TO, -4, -V_LINE_TO, 26, -H_LINE_TO, 10, -R_V_LINE_TO, -4, -R_H_LINE_TO, 12, -V_LINE_TO, 10, -R_H_LINE_TO, 4, -R_V_LINE_TO, 12, -R_H_LINE_TO, 12, -R_V_LINE_TO, 4, -CLOSE diff --git a/ash/wm/overview/drop_target_view.cc b/ash/wm/overview/drop_target_view.cc deleted file mode 100644 index 1f4ad543300e1c..00000000000000 --- a/ash/wm/overview/drop_target_view.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/overview/drop_target_view.h" - -#include - -#include "ash/resources/vector_icons/vector_icons.h" -#include "ash/wm/overview/overview_constants.h" -#include "ui/base/metadata/metadata_impl_macros.h" -#include "ui/gfx/paint_vector_icon.h" -#include "ui/views/background.h" -#include "ui/views/border.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/layout/layout_provider.h" - -namespace ash { -namespace { - -constexpr SkColor kDropTargetBackgroundColor = - SkColorSetARGB(0x24, 0xFF, 0XFF, 0XFF); -constexpr SkColor kDropTargetBorderColor = - SkColorSetARGB(0x4C, 0xE8, 0XEA, 0XED); -constexpr int kDropTargetBorderThickness = 2; -constexpr int kDropTargetMiddleSize = 96; - -// Values for the plus icon. -constexpr SkColor kPlusIconColor = SkColorSetARGB(0xFF, 0xE8, 0XEA, 0XED); -constexpr float kPlusIconSizeFirFraction = 0.5f; -constexpr float kPlusIconSizeSecFraction = 0.267f; -constexpr int kPlusIconMiddleSize = 48; -constexpr int kPlusIconLargestSize = 72; - -} // namespace - -DropTargetView::DropTargetView(bool has_plus_icon) { - const int corner_radius = views::LayoutProvider::Get()->GetCornerRadiusMetric( - views::Emphasis::kLow); - - background_view_ = AddChildView(std::make_unique()); - background_view_->SetBackground(views::CreateRoundedRectBackground( - kDropTargetBackgroundColor, corner_radius)); - - SetBorder(views::CreateRoundedRectBorder( - kDropTargetBorderThickness, corner_radius, kDropTargetBorderColor)); - - if (has_plus_icon) { - plus_icon_ = AddChildView(std::make_unique()); - plus_icon_->SetCanProcessEventsWithinSubtree(false); - plus_icon_->SetVerticalAlignment(views::ImageView::Alignment::kCenter); - plus_icon_->SetHorizontalAlignment(views::ImageView::Alignment::kCenter); - } -} - -void DropTargetView::UpdateBackgroundVisibility(bool visible) { - background_view_->SetVisible(visible); -} - -void DropTargetView::Layout() { - const gfx::Rect local_bounds = GetLocalBounds(); - background_view_->SetBoundsRect(local_bounds); - - if (!plus_icon_) - return; - - const int min_dimension = - std::min(local_bounds.width(), local_bounds.height()); - int plus_icon_size = 0; - if (min_dimension <= kDropTargetMiddleSize) { - plus_icon_size = kPlusIconSizeFirFraction * min_dimension; - } else { - plus_icon_size = std::max( - std::min(static_cast(kPlusIconSizeSecFraction * min_dimension), - kPlusIconLargestSize), - kPlusIconMiddleSize); - } - - gfx::Rect icon_bounds = local_bounds; - plus_icon_->SetImage(gfx::CreateVectorIcon(kOverviewDropTargetPlusIcon, - plus_icon_size, kPlusIconColor)); - icon_bounds.ClampToCenteredSize(gfx::Size(plus_icon_size, plus_icon_size)); - plus_icon_->SetBoundsRect(icon_bounds); -} - -BEGIN_METADATA(DropTargetView, views::View) -END_METADATA - -} // namespace ash diff --git a/ash/wm/overview/drop_target_view.h b/ash/wm/overview/drop_target_view.h deleted file mode 100644 index 71046afea395ec..00000000000000 --- a/ash/wm/overview/drop_target_view.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WM_OVERVIEW_DROP_TARGET_VIEW_H_ -#define ASH_WM_OVERVIEW_DROP_TARGET_VIEW_H_ - -#include "ui/base/metadata/metadata_header_macros.h" -#include "ui/views/view.h" - -namespace views { -class ImageView; -} - -namespace ash { - -// DropTargetView represents a transparent view with border in overview. It -// includes a background view and plus icon. Dragged window in tablet mode can -// be dragged into it and then dropped into overview. -class DropTargetView : public views::View { - public: - METADATA_HEADER(DropTargetView); - - explicit DropTargetView(bool has_plus_icon); - DropTargetView(const DropTargetView&) = delete; - DropTargetView& operator=(const DropTargetView&) = delete; - ~DropTargetView() override = default; - - // Updates the visibility of |background_view_| since it is only shown when - // drop target is selected in overview. - void UpdateBackgroundVisibility(bool visible); - - // views::View: - void Layout() override; - - private: - views::View* background_view_ = nullptr; - views::ImageView* plus_icon_ = nullptr; -}; - -} // namespace ash - -#endif // ASH_WM_OVERVIEW_DROP_TARGET_VIEW_H_ diff --git a/ash/wm/overview/overview_grid.cc b/ash/wm/overview/overview_grid.cc index aed4ffa4161b43..486ea2e7245556 100644 --- a/ash/wm/overview/overview_grid.cc +++ b/ash/wm/overview/overview_grid.cc @@ -39,7 +39,6 @@ #include "ash/wm/desks/templates/saved_desk_util.h" #include "ash/wm/desks/zero_state_button.h" #include "ash/wm/mru_window_tracker.h" -#include "ash/wm/overview/drop_target_view.h" #include "ash/wm/overview/overview_constants.h" #include "ash/wm/overview/overview_controller.h" #include "ash/wm/overview/overview_grid_event_handler.h" @@ -79,6 +78,7 @@ #include "ui/gfx/geometry/transform_util.h" #include "ui/gfx/geometry/vector2d_f.h" #include "ui/views/animation/animation_builder.h" +#include "ui/views/background.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" #include "ui/wm/core/coordinate_conversion.h" @@ -139,6 +139,12 @@ constexpr base::TimeDelta kZeroDesksBarSlideDuration = base::Milliseconds(250); constexpr char kMoveVisibleOnAllDesksWindowToastId[] = "ash.wm.overview.move_visible_on_all_desks_window_toast"; +constexpr SkColor kDropTargetBackgroundColor = + SkColorSetARGB(0x24, 0xFF, 0XFF, 0XFF); +constexpr SkColor kDropTargetBorderColor = + SkColorSetARGB(0x4C, 0xE8, 0XEA, 0XED); +constexpr int kDropTargetBorderThickness = 2; + // Histogram names for overview enter/exit smoothness in clamshell, // tablet mode and splitview. constexpr char kOverviewEnterClamshellHistogram[] = @@ -267,6 +273,42 @@ class ShutdownAnimationMetricsTrackerObserver : public OverviewObserver, OverviewExitMetricsTracker metrics_tracker_; }; +// DropTargetView represents a transparent view with border in overview. It +// includes a background view. Dragged window in tablet mode can be dragged +// into it and then dropped into overview. +class DropTargetView : public views::View { + public: + METADATA_HEADER(DropTargetView); + DropTargetView() { + SetUseDefaultFillLayout(true); + const int corner_radius = + views::LayoutProvider::Get()->GetCornerRadiusMetric( + views::Emphasis::kLow); + + background_view_ = AddChildView(std::make_unique()); + background_view_->SetBackground(views::CreateRoundedRectBackground( + kDropTargetBackgroundColor, corner_radius)); + + SetBorder(views::CreateRoundedRectBorder( + kDropTargetBorderThickness, corner_radius, kDropTargetBorderColor)); + } + DropTargetView(const DropTargetView&) = delete; + DropTargetView& operator=(const DropTargetView&) = delete; + ~DropTargetView() override = default; + + // Updates the visibility of `background_view_` since it is only shown when + // drop target is selected in overview. + void UpdateBackgroundVisibility(bool visible) { + background_view_->SetVisible(visible); + } + + private: + views::View* background_view_ = nullptr; +}; + +BEGIN_METADATA(DropTargetView, views::View) +END_METADATA + // Creates |drop_target_widget_|. It's created when a window or overview item is // dragged around, and destroyed when the drag ends. std::unique_ptr CreateDropTargetWidget( @@ -286,8 +328,7 @@ std::unique_ptr CreateDropTargetWidget( widget->Init(std::move(params)); widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); - widget->SetContentsView( - std::make_unique(/*has_plus_icon=*/false)); + widget->SetContentsView(std::make_unique()); aura::Window* drop_target_window = widget->GetNativeWindow(); drop_target_window->parent()->StackChildAtBottom(drop_target_window); widget->Show(); diff --git a/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h b/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h deleted file mode 100644 index 0ee925392845a3..00000000000000 --- a/ash/wm/tablet_mode/tablet_mode_browser_window_drag_session_windows_hider.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2020 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WM_TABLET_MODE_TABLET_MODE_BROWSER_WINDOW_DRAG_SESSION_WINDOWS_HIDER_H_ -#define ASH_WM_TABLET_MODE_TABLET_MODE_BROWSER_WINDOW_DRAG_SESSION_WINDOWS_HIDER_H_ - -#include - -#include "ash/ash_export.h" -#include "ui/aura/window.h" -#include "ui/aura/window_observer.h" - -namespace ash { - -// Hides all visible windows except the source window and the dragged -// window (if applicable), and restores the windows' visibility upon its -// destruction. It also blurs and darkens the background, hides the home -// launcher if home launcher is enabled. Only need to do so if we need -// to scale up and down the source window when dragging a tab window out -// of it. -// TODO(xdai): This class is now only used by `TabDragDropDelegate`, and -// `dragged_window` parameter is no longer needed. Clean up this class and move -// it to where it's used. -class ASH_EXPORT TabletModeBrowserWindowDragSessionWindowsHider - : public aura::WindowObserver { - public: - TabletModeBrowserWindowDragSessionWindowsHider(aura::Window* source_window, - aura::Window* dragged_window); - - TabletModeBrowserWindowDragSessionWindowsHider( - const TabletModeBrowserWindowDragSessionWindowsHider&) = delete; - TabletModeBrowserWindowDragSessionWindowsHider& operator=( - const TabletModeBrowserWindowDragSessionWindowsHider&) = delete; - - ~TabletModeBrowserWindowDragSessionWindowsHider() override; - - // aura::WindowObserver: - void OnWindowDestroying(aura::Window* window) override; - void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; - - int GetWindowVisibilityMapSizeForTesting() const; - - private: - // The window from which the drag originated. - aura::Window* source_window_; - - // The currently dragged window, if applicable. - aura::Window* dragged_window_; - - // The root window the drag is taking place within. Guaranteed to be - // non-null during the lifetime of |this|. - aura::Window* root_window_; - - // Maintains the map between windows and their visibilities. All windows - // except the dragged window and the source window should stay hidden during - // dragging. - std::map window_visibility_map_; -}; - -} // namespace ash - -#endif // ASH_WM_TABLET_MODE_TABLET_MODE_BROWSER_WINDOW_DRAG_SESSION_WINDOWS_HIDER_H_