diff --git a/ash/capture_mode/capture_mode_controller.cc b/ash/capture_mode/capture_mode_controller.cc index 106f4e79a6d572..21b9384b55121c 100644 --- a/ash/capture_mode/capture_mode_controller.cc +++ b/ash/capture_mode/capture_mode_controller.cc @@ -330,10 +330,6 @@ CaptureModeController* CaptureModeController::Get() { return g_instance; } -bool CaptureModeController::IsActive() const { - return capture_mode_session_ && !capture_mode_session_->is_shutting_down(); -} - void CaptureModeController::SetSource(CaptureModeSource source) { if (source == source_) return; @@ -399,13 +395,11 @@ void CaptureModeController::Start(CaptureModeEntryType entry_type) { delegate_->OnSessionStateChanged(/*started=*/true); capture_mode_session_ = std::make_unique(this); - capture_mode_session_->Initialize(); } void CaptureModeController::Stop() { DCHECK(IsActive()); capture_mode_session_->ReportSessionHistograms(); - capture_mode_session_->Shutdown(); capture_mode_session_.reset(); delegate_->OnSessionStateChanged(/*started=*/false); diff --git a/ash/capture_mode/capture_mode_controller.h b/ash/capture_mode/capture_mode_controller.h index 77cfcf80a6ca62..7393c19de5128d 100644 --- a/ash/capture_mode/capture_mode_controller.h +++ b/ash/capture_mode/capture_mode_controller.h @@ -65,7 +65,7 @@ class ASH_EXPORT CaptureModeController bool is_recording_in_progress() const { return is_recording_in_progress_; } // Returns true if a capture mode session is currently active. - bool IsActive() const; + bool IsActive() const { return !!capture_mode_session_; } // Sets the capture source/type, which will be applied to an ongoing capture // session (if any), or to a future capture session when Start() is called. diff --git a/ash/capture_mode/capture_mode_session.cc b/ash/capture_mode/capture_mode_session.cc index be2207aa244bc9..929f6ab91b8c30 100644 --- a/ash/capture_mode/capture_mode_session.cc +++ b/ash/capture_mode/capture_mode_session.cc @@ -314,10 +314,6 @@ int GetMessageIdForCaptureSource(CaptureModeSource source, } } -void UpdateAutoclickMenuBoundsIfNeeded() { - Shell::Get()->accessibility_controller()->UpdateAutoclickMenuBoundsIfNeeded(); -} - } // namespace // ----------------------------------------------------------------------------- @@ -496,11 +492,7 @@ CaptureModeSession::CaptureModeSession(CaptureModeController* controller) current_root_(GetPreferredRootWindow()), magnifier_glass_(kMagnifierParams), cursor_setter_(std::make_unique()), - focus_cycler_(std::make_unique(this)) {} - -CaptureModeSession::~CaptureModeSession() = default; - -void CaptureModeSession::Initialize() { + focus_cycler_(std::make_unique(this)) { // A context menu may have input capture when entering a session. Remove // capture from it, otherwise subsequent mouse events will cause it to close, // and then we won't be able to take a screenshot of the menu. Store it so we @@ -571,12 +563,9 @@ void CaptureModeSession::Initialize() { controller_->type() == CaptureModeType::kImage ? IDS_ASH_SCREEN_CAPTURE_TYPE_SCREENSHOT : IDS_ASH_SCREEN_CAPTURE_TYPE_SCREEN_RECORDING))); - UpdateAutoclickMenuBoundsIfNeeded(); } -void CaptureModeSession::Shutdown() { - is_shutting_down_ = true; - +CaptureModeSession::~CaptureModeSession() { aura::Env::GetInstance()->RemovePreTargetHandler(this); display::Screen::GetScreen()->RemoveObserver(this); current_root_->RemoveObserver(this); @@ -606,7 +595,6 @@ void CaptureModeSession::Shutdown() { capture_mode_util::TriggerAccessibilityAlert( IDS_ASH_SCREEN_CAPTURE_ALERT_CLOSE); } - UpdateAutoclickMenuBoundsIfNeeded(); } aura::Window* CaptureModeSession::GetSelectedWindow() const { diff --git a/ash/capture_mode/capture_mode_session.h b/ash/capture_mode/capture_mode_session.h index f8bd90e6cd97d9..42ccd2220e826e 100644 --- a/ash/capture_mode/capture_mode_session.h +++ b/ash/capture_mode/capture_mode_session.h @@ -65,23 +65,11 @@ class ASH_EXPORT CaptureModeSession : public ui::LayerOwner, static constexpr int kCaptureButtonDistanceFromRegionDp = 24; aura::Window* current_root() const { return current_root_; } - views::Widget* capture_mode_bar_widget() { - return capture_mode_bar_widget_.get(); - } bool is_selecting_region() const { return is_selecting_region_; } bool is_drag_in_progress() const { return is_drag_in_progress_; } void set_a11y_alert_on_session_exit(bool value) { a11y_alert_on_session_exit_ = value; } - bool is_shutting_down() const { return is_shutting_down_; } - - // Initializes the capture mode session. This should be called right after the - // object is created. - void Initialize(); - - // Shuts down the capture mode session. This should be called right before the - // object is destroyed. - void Shutdown(); // Gets the current window selected for |kWindow| capture source. Returns // nullptr if no window is available for selection. @@ -345,9 +333,6 @@ class ASH_EXPORT CaptureModeSession : public ui::LayerOwner, // False only when we end the session to start recording. bool a11y_alert_on_session_exit_ = true; - // True once Shutdown() is called. - bool is_shutting_down_ = false; - // The object which handles tab focus while in a capture session. std::unique_ptr focus_cycler_; diff --git a/ash/capture_mode/capture_mode_unittests.cc b/ash/capture_mode/capture_mode_unittests.cc index 539ec70f2932c2..7fa99ae2aa5959 100644 --- a/ash/capture_mode/capture_mode_unittests.cc +++ b/ash/capture_mode/capture_mode_unittests.cc @@ -199,6 +199,10 @@ class CaptureModeSessionTestApi { return session_->capture_mode_bar_view_; } + views::Widget* capture_mode_bar_widget() const { + return session_->capture_mode_bar_widget_.get(); + } + CaptureModeSettingsView* capture_mode_settings_view() const { return session_->capture_mode_settings_view_; } @@ -261,7 +265,7 @@ class CaptureModeTest : public AshTestBase { views::Widget* GetCaptureModeBarWidget() const { auto* session = CaptureModeController::Get()->capture_mode_session(); DCHECK(session); - return session->capture_mode_bar_widget(); + return CaptureModeSessionTestApi(session).capture_mode_bar_widget(); } views::Widget* GetCaptureModeLabelWidget() const { @@ -507,7 +511,8 @@ TEST_F(CaptureModeTest, StartStop) { // Closing the session should close the native window of capture mode bar // immediately. - auto* bar_window = GetCaptureModeBarWidget()->GetNativeWindow(); + CaptureModeSessionTestApi test_api(controller->capture_mode_session()); + auto* bar_window = test_api.capture_mode_bar_widget()->GetNativeWindow(); aura::WindowTracker tracker({bar_window}); controller->Stop(); EXPECT_TRUE(tracker.windows().empty()); diff --git a/ash/wm/always_on_top_controller.cc b/ash/wm/always_on_top_controller.cc index c08db9dc198669..5ed17710374104 100644 --- a/ash/wm/always_on_top_controller.cc +++ b/ash/wm/always_on_top_controller.cc @@ -42,11 +42,6 @@ AlwaysOnTopController::~AlwaysOnTopController() { DCHECK(!pip_container_); } -// static -void AlwaysOnTopController::SetDisallowReparent(aura::Window* window) { - window->SetProperty(kDisallowReparentKey, true); -} - aura::Window* AlwaysOnTopController::GetContainer(aura::Window* window) const { DCHECK(always_on_top_container_); DCHECK(pip_container_); @@ -83,6 +78,10 @@ void AlwaysOnTopController::SetLayoutManagerForTest( always_on_top_container_->SetLayoutManager(layout_manager.release()); } +void AlwaysOnTopController::SetDisallowReparent(aura::Window* window) { + window->SetProperty(kDisallowReparentKey, true); +} + void AlwaysOnTopController::AddWindow(aura::Window* window) { window->AddObserver(this); WindowState::Get(window)->AddObserver(this); diff --git a/ash/wm/always_on_top_controller.h b/ash/wm/always_on_top_controller.h index 545b8bb95a570f..d7dc848db649b5 100644 --- a/ash/wm/always_on_top_controller.h +++ b/ash/wm/always_on_top_controller.h @@ -27,14 +27,14 @@ class ASH_EXPORT AlwaysOnTopController : public aura::WindowObserver, aura::Window* pip_container); ~AlwaysOnTopController() override; - static void SetDisallowReparent(aura::Window* window); - // Gets container for given |window| based on its "AlwaysOnTop" property. aura::Window* GetContainer(aura::Window* window) const; void SetLayoutManagerForTest( std::unique_ptr layout_manager); + static void SetDisallowReparent(aura::Window* window); + private: void AddWindow(aura::Window* window); void RemoveWindow(aura::Window* window); diff --git a/ash/wm/collision_detection/collision_detection_utils.cc b/ash/wm/collision_detection/collision_detection_utils.cc index 1a22b6d38af7f6..aeee409be78d69 100644 --- a/ash/wm/collision_detection/collision_detection_utils.cc +++ b/ash/wm/collision_detection/collision_detection_utils.cc @@ -4,10 +4,7 @@ #include "ash/wm/collision_detection/collision_detection_utils.h" -#include "ash/capture_mode/capture_mode_controller.h" -#include "ash/capture_mode/capture_mode_session.h" #include "ash/keyboard/ui/keyboard_ui_controller.h" -#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/shelf/shelf.h" @@ -155,19 +152,6 @@ std::vector CollectCollisionRects( /*parent=*/root_window)); } - // Check the capture bar if capture mode is active. - if (features::IsCaptureModeEnabled()) { - auto* capture_mode_controller = CaptureModeController::Get(); - if (capture_mode_controller->IsActive()) { - aura::Window* capture_bar_window = - capture_mode_controller->capture_mode_session() - ->capture_mode_bar_widget() - ->GetNativeWindow(); - rects.push_back(ComputeCollisionRectFromBounds( - capture_bar_window->GetTargetBounds(), capture_bar_window->parent())); - } - } - return rects; } diff --git a/ash/wm/workspace/workspace_layout_manager.h b/ash/wm/workspace/workspace_layout_manager.h index 6714e70045715d..a7f44d2da05e72 100644 --- a/ash/wm/workspace/workspace_layout_manager.h +++ b/ash/wm/workspace/workspace_layout_manager.h @@ -153,7 +153,7 @@ class ASH_EXPORT WorkspaceLayoutManager : public aura::LayoutManager, // Notifies windows about a change in a system ui area. This could be // the keyboard or any window in the SettingsBubbleContainer or - // |accessibility_bubble_container_|. Windows will only be notified about + // accessibility_bubble_container_. Windows will only be notified about // changes to system ui areas on the display they are on. void NotifySystemUiAreaChanged();