display_observer.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2012 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. #include "ui/display/display_observer.h"
  5. #include "ui/display/screen.h"
  6. #include "ui/display/tablet_state.h"
  7. namespace display {
  8. DisplayObserver::~DisplayObserver() {}
  9. void DisplayObserver::OnWillProcessDisplayChanges() {}
  10. void DisplayObserver::OnDidProcessDisplayChanges() {}
  11. void DisplayObserver::OnDisplayAdded(const Display& new_display) {}
  12. void DisplayObserver::OnDisplayRemoved(const Display& old_display) {}
  13. void DisplayObserver::OnDidRemoveDisplays() {}
  14. void DisplayObserver::OnDisplayMetricsChanged(const Display& display,
  15. uint32_t changed_metrics) {}
  16. void DisplayObserver::OnCurrentWorkspaceChanged(
  17. const std::string& new_workspace) {}
  18. void DisplayObserver::OnDisplayTabletStateChanged(TabletState state) {}
  19. ScopedOptionalDisplayObserver::ScopedOptionalDisplayObserver(
  20. DisplayObserver* observer) {
  21. if (auto* screen = display::Screen::GetScreen()) {
  22. observer_ = observer;
  23. screen->AddObserver(observer_);
  24. }
  25. }
  26. ScopedOptionalDisplayObserver::~ScopedOptionalDisplayObserver() {
  27. if (!observer_)
  28. return;
  29. if (auto* screen = display::Screen::GetScreen())
  30. screen->RemoveObserver(observer_);
  31. }
  32. ScopedDisplayObserver::ScopedDisplayObserver(DisplayObserver* observer)
  33. : ScopedOptionalDisplayObserver(observer) {
  34. CHECK(Screen::GetScreen());
  35. }
  36. } // namespace display