OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/display/display_pref_util.h" | 10 #include "ash/display/display_pref_util.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 float ui_scale = 1.0f; | 128 float ui_scale = 1.0f; |
129 const gfx::Insets* insets_to_set = NULL; | 129 const gfx::Insets* insets_to_set = NULL; |
130 | 130 |
131 int rotation_value = 0; | 131 int rotation_value = 0; |
132 if (dict_value->GetInteger("rotation", &rotation_value)) { | 132 if (dict_value->GetInteger("rotation", &rotation_value)) { |
133 rotation = static_cast<gfx::Display::Rotation>(rotation_value); | 133 rotation = static_cast<gfx::Display::Rotation>(rotation_value); |
134 } | 134 } |
135 int ui_scale_value = 0; | 135 int ui_scale_value = 0; |
136 if (dict_value->GetInteger("ui-scale", &ui_scale_value)) | 136 if (dict_value->GetInteger("ui-scale", &ui_scale_value)) |
137 ui_scale = static_cast<float>(ui_scale_value) / 1000.0f; | 137 ui_scale = static_cast<float>(ui_scale_value) / 1000.0f; |
| 138 |
| 139 int width = 0, height = 0; |
| 140 dict_value->GetInteger("width", &width); |
| 141 dict_value->GetInteger("height", &height); |
| 142 gfx::Size resolution_in_pixels(width, height); |
| 143 |
138 gfx::Insets insets; | 144 gfx::Insets insets; |
139 if (ValueToInsets(*dict_value, &insets)) | 145 if (ValueToInsets(*dict_value, &insets)) |
140 insets_to_set = &insets; | 146 insets_to_set = &insets; |
141 GetDisplayManager()->RegisterDisplayProperty(id, | 147 GetDisplayManager()->RegisterDisplayProperty(id, |
142 rotation, | 148 rotation, |
143 ui_scale, | 149 ui_scale, |
144 insets_to_set); | 150 insets_to_set, |
| 151 resolution_in_pixels); |
145 } | 152 } |
146 } | 153 } |
147 | 154 |
148 void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, | 155 void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, |
149 const ash::DisplayLayout& display_layout) { | 156 const ash::DisplayLayout& display_layout) { |
150 std::string name = | 157 std::string name = |
151 base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); | 158 base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); |
152 | 159 |
153 PrefService* local_state = g_browser_process->local_state(); | 160 PrefService* local_state = g_browser_process->local_state(); |
154 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); | 161 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); |
(...skipping 20 matching lines...) Expand all Loading... |
175 | 182 |
176 void StoreCurrentDisplayProperties() { | 183 void StoreCurrentDisplayProperties() { |
177 ash::internal::DisplayManager* display_manager = GetDisplayManager(); | 184 ash::internal::DisplayManager* display_manager = GetDisplayManager(); |
178 PrefService* local_state = g_browser_process->local_state(); | 185 PrefService* local_state = g_browser_process->local_state(); |
179 | 186 |
180 DictionaryPrefUpdate update(local_state, prefs::kDisplayProperties); | 187 DictionaryPrefUpdate update(local_state, prefs::kDisplayProperties); |
181 base::DictionaryValue* pref_data = update.Get(); | 188 base::DictionaryValue* pref_data = update.Get(); |
182 | 189 |
183 size_t num = display_manager->GetNumDisplays(); | 190 size_t num = display_manager->GetNumDisplays(); |
184 for (size_t i = 0; i < num; ++i) { | 191 for (size_t i = 0; i < num; ++i) { |
185 int64 id = display_manager->GetDisplayAt(i).id(); | 192 const gfx::Display& display = display_manager->GetDisplayAt(i); |
| 193 int64 id = display.id(); |
186 ash::internal::DisplayInfo info = display_manager->GetDisplayInfo(id); | 194 ash::internal::DisplayInfo info = display_manager->GetDisplayInfo(id); |
187 | 195 |
188 scoped_ptr<base::DictionaryValue> property_value( | 196 scoped_ptr<base::DictionaryValue> property_value( |
189 new base::DictionaryValue()); | 197 new base::DictionaryValue()); |
190 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); | 198 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); |
191 property_value->SetInteger("ui-scale", | 199 property_value->SetInteger("ui-scale", |
192 static_cast<int>(info.ui_scale() * 1000)); | 200 static_cast<int>(info.ui_scale() * 1000)); |
| 201 gfx::Size resolution; |
| 202 if (!display.IsInternal() && |
| 203 display_manager->GetSelectedResolutionForDisplayId(id, &resolution)) { |
| 204 property_value->SetInteger("width", resolution.width()); |
| 205 property_value->SetInteger("height", resolution.height()); |
| 206 } |
| 207 |
193 if (!info.overscan_insets_in_dip().empty()) | 208 if (!info.overscan_insets_in_dip().empty()) |
194 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); | 209 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); |
195 pref_data->Set(base::Int64ToString(id), property_value.release()); | 210 pref_data->Set(base::Int64ToString(id), property_value.release()); |
196 } | 211 } |
197 } | 212 } |
198 | 213 |
199 typedef std::map<chromeos::DisplayPowerState, std::string> | 214 typedef std::map<chromeos::DisplayPowerState, std::string> |
200 DisplayPowerStateToStringMap; | 215 DisplayPowerStateToStringMap; |
201 | 216 |
202 const DisplayPowerStateToStringMap* GetDisplayPowerStateToStringMap() { | 217 const DisplayPowerStateToStringMap* GetDisplayPowerStateToStringMap() { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 const ash::DisplayLayout& layout) { | 291 const ash::DisplayLayout& layout) { |
277 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 292 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
278 } | 293 } |
279 | 294 |
280 // Stores the given |power_state|. | 295 // Stores the given |power_state|. |
281 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 296 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
282 StoreDisplayPowerState(power_state); | 297 StoreDisplayPowerState(power_state); |
283 } | 298 } |
284 | 299 |
285 } // namespace chromeos | 300 } // namespace chromeos |
OLD | NEW |