fullscreen_controller.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2020 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_SESSION_FULLSCREEN_CONTROLLER_H_
  5. #define ASH_SESSION_FULLSCREEN_CONTROLLER_H_
  6. #include <memory>
  7. #include "base/time/time.h"
  8. #include "chromeos/dbus/power/power_manager_client.h"
  9. class PrefRegistrySimple;
  10. namespace chromeos {
  11. class KeepFullscreenForUrlChecker;
  12. } // namespace chromeos
  13. namespace ash {
  14. class SessionControllerImpl;
  15. class FullscreenNotificationBubble;
  16. class FullscreenController : public chromeos::PowerManagerClient::Observer {
  17. public:
  18. explicit FullscreenController(SessionControllerImpl* session_controller);
  19. FullscreenController(const FullscreenController&) = delete;
  20. FullscreenController& operator=(const FullscreenController&) = delete;
  21. ~FullscreenController() override;
  22. static void RegisterProfilePrefs(PrefRegistrySimple* registry);
  23. // Checks the window state, user pref and, if required, sends a request to
  24. // Lacros to determine whether it should exit full screen mode before the
  25. // session is locked. |callback| will be invoked to signal readiness for
  26. // session lock.
  27. void MaybeExitFullscreenBeforeLock(base::OnceClosure callback);
  28. private:
  29. void MaybeShowNotification();
  30. // chromeos::PowerManagerClient::Observer:
  31. void SuspendImminent(power_manager::SuspendImminent::Reason reason) override;
  32. void ScreenIdleStateChanged(
  33. const power_manager::ScreenIdleState& proto) override;
  34. void ScreenBrightnessChanged(
  35. const power_manager::BacklightBrightnessChange& change) override;
  36. void LidEventReceived(chromeos::PowerManagerClient::LidState state,
  37. base::TimeTicks timestamp) override;
  38. const SessionControllerImpl* const session_controller_;
  39. std::unique_ptr<FullscreenNotificationBubble> bubble_;
  40. std::unique_ptr<chromeos::KeepFullscreenForUrlChecker>
  41. keep_fullscreen_checker_;
  42. // Whether the screen brightness is low enough to make display dark.
  43. bool device_in_dark_ = false;
  44. };
  45. } // namespace ash
  46. #endif // ASH_SESSION_FULLSCREEN_CONTROLLER_H_