lock_screen_action_background_controller_impl.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2017 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 ASH_LOCK_SCREEN_ACTION_LOCK_SCREEN_ACTION_BACKGROUND_CONTROLLER_IMPL_H_
  5. #define ASH_LOCK_SCREEN_ACTION_LOCK_SCREEN_ACTION_BACKGROUND_CONTROLLER_IMPL_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/lock_screen_action/lock_screen_action_background_controller.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "base/scoped_observation.h"
  10. #include "ui/views/widget/widget.h"
  11. #include "ui/views/widget/widget_observer.h"
  12. namespace aura {
  13. class Window;
  14. }
  15. namespace ash {
  16. class LockScreenActionBackgroundView;
  17. // The LockScreenActionBackgroundController implementation that shows lock
  18. // screen action background as a non activable window that is shown/hidden with
  19. // an ink drop animation that covers the whole window contents in black from the
  20. // top right window corner.
  21. class ASH_EXPORT LockScreenActionBackgroundControllerImpl
  22. : public LockScreenActionBackgroundController,
  23. public views::WidgetObserver {
  24. public:
  25. LockScreenActionBackgroundControllerImpl();
  26. LockScreenActionBackgroundControllerImpl(
  27. const LockScreenActionBackgroundControllerImpl&) = delete;
  28. LockScreenActionBackgroundControllerImpl& operator=(
  29. const LockScreenActionBackgroundControllerImpl&) = delete;
  30. ~LockScreenActionBackgroundControllerImpl() override;
  31. // LockScreenActionBackgroundController:
  32. bool IsBackgroundWindow(aura::Window* window) const override;
  33. bool ShowBackground() override;
  34. bool HideBackgroundImmediately() override;
  35. bool HideBackground() override;
  36. // views::WidgetObserver:
  37. void OnWidgetDestroyed(views::Widget* widget) override;
  38. private:
  39. friend class LockScreenActionBackgroundControllerImplTestApi;
  40. // Creates the widget to be used as the background widget.
  41. views::Widget* CreateWidget();
  42. // Called when the background widget view is fully shown, i.e. when the ink
  43. // drop animation associated with showing the widget ends.
  44. void OnBackgroundShown();
  45. // Called when the background widget view is fully hidden, i.e. when the ink
  46. // drop animation associated with hiding the widget ends.
  47. void OnBackgroundHidden();
  48. // The background widget used (and created) by the controller to display the
  49. // lock screen action background.
  50. // The widget is owned by its native (aura) window - it will be deleted when
  51. // the window gets closed/destroyed.
  52. views::Widget* background_widget_ = nullptr;
  53. LockScreenActionBackgroundView* contents_view_ = nullptr;
  54. base::ScopedObservation<views::Widget, views::WidgetObserver>
  55. widget_observation_{this};
  56. base::WeakPtrFactory<LockScreenActionBackgroundControllerImpl>
  57. weak_ptr_factory_{this};
  58. };
  59. } // namespace ash
  60. #endif // ASH_LOCK_SCREEN_ACTION_LOCK_SCREEN_ACTION_BACKGROUND_CONTROLLER_IMPL_H_