display_configuration_observer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) 2013 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_DISPLAY_DISPLAY_CONFIGURATION_OBSERVER_H_
  5. #define ASH_DISPLAY_DISPLAY_CONFIGURATION_OBSERVER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/display/window_tree_host_manager.h"
  8. #include "ash/public/cpp/tablet_mode_observer.h"
  9. #include "base/compiler_specific.h"
  10. #include "base/memory/weak_ptr.h"
  11. namespace ash {
  12. // DisplayConfigurationObserver observes and saves
  13. // the change of display configurations.
  14. class ASH_EXPORT DisplayConfigurationObserver
  15. : public WindowTreeHostManager::Observer,
  16. public TabletModeObserver {
  17. public:
  18. DisplayConfigurationObserver();
  19. DisplayConfigurationObserver(const DisplayConfigurationObserver&) = delete;
  20. DisplayConfigurationObserver& operator=(const DisplayConfigurationObserver&) =
  21. delete;
  22. ~DisplayConfigurationObserver() override;
  23. protected:
  24. // WindowTreeHostManager::Observer:
  25. void OnDisplaysInitialized() override;
  26. void OnDisplayConfigurationChanged() override;
  27. // TabletModeObserver:
  28. void OnTabletModeStarted() override;
  29. void OnTabletModeEnded() override;
  30. private:
  31. void StartMirrorMode();
  32. void EndMirrorMode();
  33. // True if the device was in mirror mode before siwtching to tablet mode.
  34. bool was_in_mirror_mode_ = false;
  35. base::WeakPtrFactory<DisplayConfigurationObserver> weak_ptr_factory_{this};
  36. };
  37. } // namespace ash
  38. #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_OBSERVER_H_