high_contrast_controller.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 "ash/high_contrast/high_contrast_controller.h"
  5. #include "ash/shell.h"
  6. #include "ui/aura/window_event_dispatcher.h"
  7. #include "ui/compositor/layer.h"
  8. namespace ash {
  9. HighContrastController::HighContrastController() : enabled_(false) {
  10. Shell::Get()->AddShellObserver(this);
  11. }
  12. HighContrastController::~HighContrastController() {
  13. Shell::Get()->RemoveShellObserver(this);
  14. }
  15. void HighContrastController::SetEnabled(bool enabled) {
  16. enabled_ = enabled;
  17. // Update all active displays.
  18. aura::Window::Windows root_window_list = Shell::GetAllRootWindows();
  19. for (aura::Window::Windows::iterator it = root_window_list.begin();
  20. it != root_window_list.end(); it++) {
  21. UpdateDisplay(*it);
  22. }
  23. }
  24. void HighContrastController::UpdateDisplay(aura::Window* root_window) {
  25. root_window->layer()->SetLayerInverted(enabled_);
  26. }
  27. void HighContrastController::OnRootWindowAdded(aura::Window* root_window) {
  28. UpdateDisplay(root_window);
  29. }
  30. } // namespace ash