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/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return; | 60 return; |
61 | 61 |
62 // Avoid nested calls of this function due to OnDisplayConfigurationChanged | 62 // Avoid nested calls of this function due to OnDisplayConfigurationChanged |
63 // being called by rotations here. | 63 // being called by rotations here. |
64 rotation_in_progress_ = true; | 64 rotation_in_progress_ = true; |
65 | 65 |
66 ash::DisplayManager* const display_manager = | 66 ash::DisplayManager* const display_manager = |
67 ash::Shell::GetInstance()->display_manager(); | 67 ash::Shell::GetInstance()->display_manager(); |
68 const size_t num_displays = display_manager->GetNumDisplays(); | 68 const size_t num_displays = display_manager->GetNumDisplays(); |
69 for (size_t i = 0; i < num_displays; ++i) { | 69 for (size_t i = 0; i < num_displays; ++i) { |
70 const gfx::Display& display = display_manager->GetDisplayAt(i); | 70 const display::Display& display = display_manager->GetDisplayAt(i); |
71 const int64_t id = display.id(); | 71 const int64_t id = display.id(); |
72 if (rotated_displays_.find(id) == rotated_displays_.end()) { | 72 if (rotated_displays_.find(id) == rotated_displays_.end()) { |
73 rotated_displays_.insert(id); | 73 rotated_displays_.insert(id); |
74 if (display.rotation() != display_rotation_default_) { | 74 if (display.rotation() != display_rotation_default_) { |
75 display_manager->SetDisplayRotation(id, display_rotation_default_, | 75 display_manager->SetDisplayRotation( |
76 gfx::Display::ROTATION_SOURCE_ACTIVE); | 76 id, display_rotation_default_, |
| 77 display::Display::ROTATION_SOURCE_ACTIVE); |
77 } | 78 } |
78 } | 79 } |
79 } | 80 } |
80 rotation_in_progress_ = false; | 81 rotation_in_progress_ = false; |
81 } | 82 } |
82 | 83 |
83 bool DisplayRotationDefaultHandler::UpdateFromCrosSettings() { | 84 bool DisplayRotationDefaultHandler::UpdateFromCrosSettings() { |
84 int new_rotation; | 85 int new_rotation; |
85 bool new_policy_enabled = chromeos::CrosSettings::Get()->GetInteger( | 86 bool new_policy_enabled = chromeos::CrosSettings::Get()->GetInteger( |
86 chromeos::kDisplayRotationDefault, &new_rotation); | 87 chromeos::kDisplayRotationDefault, &new_rotation); |
87 gfx::Display::Rotation new_display_rotation_default = gfx::Display::ROTATE_0; | 88 display::Display::Rotation new_display_rotation_default = |
| 89 display::Display::ROTATE_0; |
88 if (new_policy_enabled) { | 90 if (new_policy_enabled) { |
89 if (new_rotation >= gfx::Display::ROTATE_0 && | 91 if (new_rotation >= display::Display::ROTATE_0 && |
90 new_rotation <= gfx::Display::ROTATE_270) { | 92 new_rotation <= display::Display::ROTATE_270) { |
91 new_display_rotation_default = | 93 new_display_rotation_default = |
92 static_cast<gfx::Display::Rotation>(new_rotation); | 94 static_cast<display::Display::Rotation>(new_rotation); |
93 } else { | 95 } else { |
94 LOG(ERROR) << "CrosSettings contains invalid value " << new_rotation | 96 LOG(ERROR) << "CrosSettings contains invalid value " << new_rotation |
95 << " for DisplayRotationDefault. Ignoring setting."; | 97 << " for DisplayRotationDefault. Ignoring setting."; |
96 new_policy_enabled = false; | 98 new_policy_enabled = false; |
97 } | 99 } |
98 } | 100 } |
99 if (new_policy_enabled != policy_enabled_ || | 101 if (new_policy_enabled != policy_enabled_ || |
100 (new_policy_enabled && | 102 (new_policy_enabled && |
101 new_display_rotation_default != display_rotation_default_)) { | 103 new_display_rotation_default != display_rotation_default_)) { |
102 policy_enabled_ = new_policy_enabled; | 104 policy_enabled_ = new_policy_enabled; |
103 display_rotation_default_ = new_display_rotation_default; | 105 display_rotation_default_ = new_display_rotation_default; |
104 return true; | 106 return true; |
105 } | 107 } |
106 return false; | 108 return false; |
107 } | 109 } |
108 | 110 |
109 } // namespace policy | 111 } // namespace policy |
OLD | NEW |