Chromium Code Reviews| 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 LOG(ERROR) << "Store Resolution for:" << display.ToString(); | |
|
Jun Mukai
2013/08/01 02:41:00
remove this log
oshima
2013/08/01 06:02:50
Done.
| |
| 203 if (!display.IsInternal() && | |
| 204 display_manager->GetSelectedResolutionForDisplayId(id, &resolution)) { | |
| 205 property_value->SetInteger("width", resolution.width()); | |
| 206 property_value->SetInteger("height", resolution.height()); | |
| 207 } | |
| 208 | |
| 193 if (!info.overscan_insets_in_dip().empty()) | 209 if (!info.overscan_insets_in_dip().empty()) |
| 194 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); | 210 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); |
| 195 pref_data->Set(base::Int64ToString(id), property_value.release()); | 211 pref_data->Set(base::Int64ToString(id), property_value.release()); |
| 196 } | 212 } |
| 197 } | 213 } |
| 198 | 214 |
| 199 typedef std::map<chromeos::DisplayPowerState, std::string> | 215 typedef std::map<chromeos::DisplayPowerState, std::string> |
| 200 DisplayPowerStateToStringMap; | 216 DisplayPowerStateToStringMap; |
| 201 | 217 |
| 202 const DisplayPowerStateToStringMap* GetDisplayPowerStateToStringMap() { | 218 const DisplayPowerStateToStringMap* GetDisplayPowerStateToStringMap() { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 const ash::DisplayLayout& layout) { | 292 const ash::DisplayLayout& layout) { |
| 277 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 293 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 278 } | 294 } |
| 279 | 295 |
| 280 // Stores the given |power_state|. | 296 // Stores the given |power_state|. |
| 281 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 297 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 282 StoreDisplayPowerState(power_state); | 298 StoreDisplayPowerState(power_state); |
| 283 } | 299 } |
| 284 | 300 |
| 285 } // namespace chromeos | 301 } // namespace chromeos |
| OLD | NEW |