scoped_window_event_targeting_blocker.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_AURA_SCOPED_WINDOW_EVENT_TARGETING_BLOCKER_H_
  5. #define UI_AURA_SCOPED_WINDOW_EVENT_TARGETING_BLOCKER_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "ui/aura/aura_export.h"
  8. #include "ui/aura/window_observer.h"
  9. namespace aura {
  10. class Window;
  11. // Temporarily blocks the event targeting by setting kNone targeting policy to
  12. // |window_|. The original event targeting policy will be restored if all
  13. // targeting blockers are removed from |window_|.
  14. class AURA_EXPORT ScopedWindowEventTargetingBlocker : public WindowObserver {
  15. public:
  16. explicit ScopedWindowEventTargetingBlocker(Window* window);
  17. ScopedWindowEventTargetingBlocker(const ScopedWindowEventTargetingBlocker&) =
  18. delete;
  19. ScopedWindowEventTargetingBlocker& operator=(
  20. const ScopedWindowEventTargetingBlocker&) = delete;
  21. ~ScopedWindowEventTargetingBlocker() override;
  22. // WindowObserver:
  23. void OnWindowDestroying(Window* window) override;
  24. private:
  25. raw_ptr<Window> window_;
  26. };
  27. } // namespace aura
  28. #endif // UI_AURA_SCOPED_WINDOW_EVENT_TARGETING_BLOCKER_H_