OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/policy/display_rotation_default_handler.h" | 5 #include "chrome/browser/chromeos/policy/display_rotation_default_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
10 #include "ash/display/display_manager.h" | |
11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
12 #include "base/bind.h" | 11 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
14 #include "base/location.h" | 13 #include "base/location.h" |
15 #include "base/logging.h" | 14 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
17 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
19 #include "chromeos/settings/cros_settings_names.h" | 18 #include "chromeos/settings/cros_settings_names.h" |
| 19 #include "ui/display/manager/display_manager.h" |
20 | 20 |
21 namespace policy { | 21 namespace policy { |
22 | 22 |
23 DisplayRotationDefaultHandler::DisplayRotationDefaultHandler() { | 23 DisplayRotationDefaultHandler::DisplayRotationDefaultHandler() { |
24 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); | 24 ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); |
25 ash::WmShell::Get()->AddShellObserver(this); | 25 ash::WmShell::Get()->AddShellObserver(this); |
26 settings_observer_ = chromeos::CrosSettings::Get()->AddSettingsObserver( | 26 settings_observer_ = chromeos::CrosSettings::Get()->AddSettingsObserver( |
27 chromeos::kDisplayRotationDefault, | 27 chromeos::kDisplayRotationDefault, |
28 base::Bind(&DisplayRotationDefaultHandler::OnCrosSettingsChanged, | 28 base::Bind(&DisplayRotationDefaultHandler::OnCrosSettingsChanged, |
29 base::Unretained(this))); | 29 base::Unretained(this))); |
(...skipping 27 matching lines...) Expand all Loading... |
57 } | 57 } |
58 | 58 |
59 void DisplayRotationDefaultHandler::RotateDisplays() { | 59 void DisplayRotationDefaultHandler::RotateDisplays() { |
60 if (!policy_enabled_ || rotation_in_progress_) | 60 if (!policy_enabled_ || rotation_in_progress_) |
61 return; | 61 return; |
62 | 62 |
63 // Avoid nested calls of this function due to OnDisplayConfigurationChanged | 63 // Avoid nested calls of this function due to OnDisplayConfigurationChanged |
64 // being called by rotations here. | 64 // being called by rotations here. |
65 rotation_in_progress_ = true; | 65 rotation_in_progress_ = true; |
66 | 66 |
67 ash::DisplayManager* const display_manager = | 67 display::DisplayManager* const display_manager = |
68 ash::Shell::GetInstance()->display_manager(); | 68 ash::Shell::GetInstance()->display_manager(); |
69 const size_t num_displays = display_manager->GetNumDisplays(); | 69 const size_t num_displays = display_manager->GetNumDisplays(); |
70 for (size_t i = 0; i < num_displays; ++i) { | 70 for (size_t i = 0; i < num_displays; ++i) { |
71 const display::Display& display = display_manager->GetDisplayAt(i); | 71 const display::Display& display = display_manager->GetDisplayAt(i); |
72 const int64_t id = display.id(); | 72 const int64_t id = display.id(); |
73 if (rotated_displays_.find(id) == rotated_displays_.end()) { | 73 if (rotated_displays_.find(id) == rotated_displays_.end()) { |
74 rotated_displays_.insert(id); | 74 rotated_displays_.insert(id); |
75 if (display.rotation() != display_rotation_default_) { | 75 if (display.rotation() != display_rotation_default_) { |
76 display_manager->SetDisplayRotation( | 76 display_manager->SetDisplayRotation( |
77 id, display_rotation_default_, | 77 id, display_rotation_default_, |
(...skipping 25 matching lines...) Expand all Loading... |
103 (new_policy_enabled && | 103 (new_policy_enabled && |
104 new_display_rotation_default != display_rotation_default_)) { | 104 new_display_rotation_default != display_rotation_default_)) { |
105 policy_enabled_ = new_policy_enabled; | 105 policy_enabled_ = new_policy_enabled; |
106 display_rotation_default_ = new_display_rotation_default; | 106 display_rotation_default_ = new_display_rotation_default; |
107 return true; | 107 return true; |
108 } | 108 } |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 } // namespace policy | 112 } // namespace policy |
OLD | NEW |