| 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_layout_store.h" | 7 #include "ash/display/display_layout_store.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/display/display_pref_util.h" | 9 #include "ash/display/display_pref_util.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 base::DictionaryValue* pref_data = update.Get(); | 244 base::DictionaryValue* pref_data = update.Get(); |
| 245 | 245 |
| 246 size_t num = display_manager->GetNumDisplays(); | 246 size_t num = display_manager->GetNumDisplays(); |
| 247 for (size_t i = 0; i < num; ++i) { | 247 for (size_t i = 0; i < num; ++i) { |
| 248 const gfx::Display& display = display_manager->GetDisplayAt(i); | 248 const gfx::Display& display = display_manager->GetDisplayAt(i); |
| 249 int64 id = display.id(); | 249 int64 id = display.id(); |
| 250 ash::DisplayInfo info = display_manager->GetDisplayInfo(id); | 250 ash::DisplayInfo info = display_manager->GetDisplayInfo(id); |
| 251 | 251 |
| 252 scoped_ptr<base::DictionaryValue> property_value( | 252 scoped_ptr<base::DictionaryValue> property_value( |
| 253 new base::DictionaryValue()); | 253 new base::DictionaryValue()); |
| 254 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); | 254 property_value->SetInteger( |
| 255 "rotation", |
| 256 static_cast<int>(info.GetRotation(gfx::Display::ROTATION_SOURCE_USER))); |
| 255 property_value->SetInteger( | 257 property_value->SetInteger( |
| 256 "ui-scale", | 258 "ui-scale", |
| 257 static_cast<int>(info.configured_ui_scale() * 1000)); | 259 static_cast<int>(info.configured_ui_scale() * 1000)); |
| 258 ash::DisplayMode mode; | 260 ash::DisplayMode mode; |
| 259 if (!display.IsInternal() && | 261 if (!display.IsInternal() && |
| 260 display_manager->GetSelectedModeForDisplayId(id, &mode) && | 262 display_manager->GetSelectedModeForDisplayId(id, &mode) && |
| 261 !mode.native) { | 263 !mode.native) { |
| 262 property_value->SetInteger("width", mode.size.width()); | 264 property_value->SetInteger("width", mode.size.width()); |
| 263 property_value->SetInteger("height", mode.size.height()); | 265 property_value->SetInteger("height", mode.size.height()); |
| 264 property_value->SetInteger( | 266 property_value->SetInteger( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 if (!gfx::Display::HasInternalDisplay()) | 353 if (!gfx::Display::HasInternalDisplay()) |
| 352 return; | 354 return; |
| 353 | 355 |
| 354 PrefService* local_state = g_browser_process->local_state(); | 356 PrefService* local_state = g_browser_process->local_state(); |
| 355 DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); | 357 DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); |
| 356 base::DictionaryValue* pref_data = update.Get(); | 358 base::DictionaryValue* pref_data = update.Get(); |
| 357 pref_data->SetBoolean("lock", rotation_lock); | 359 pref_data->SetBoolean("lock", rotation_lock); |
| 358 gfx::Display::Rotation rotation = | 360 gfx::Display::Rotation rotation = |
| 359 GetDisplayManager() | 361 GetDisplayManager() |
| 360 ->GetDisplayInfo(gfx::Display::InternalDisplayId()) | 362 ->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
| 361 .rotation(); | 363 .GetRotation(gfx::Display::ROTATION_SOURCE_ACCELEROMETER); |
| 362 pref_data->SetInteger("orientation", static_cast<int>(rotation)); | 364 pref_data->SetInteger("orientation", static_cast<int>(rotation)); |
| 363 } | 365 } |
| 364 | 366 |
| 365 void SetCurrentDisplayLayout(const ash::DisplayLayout& layout) { | 367 void SetCurrentDisplayLayout(const ash::DisplayLayout& layout) { |
| 366 GetDisplayManager()->SetLayoutForCurrentDisplays(layout); | 368 GetDisplayManager()->SetLayoutForCurrentDisplays(layout); |
| 367 } | 369 } |
| 368 | 370 |
| 369 void LoadDisplayPreferences(bool first_run_after_boot) { | 371 void LoadDisplayPreferences(bool first_run_after_boot) { |
| 370 LoadDisplayLayouts(); | 372 LoadDisplayLayouts(); |
| 371 LoadDisplayProperties(); | 373 LoadDisplayProperties(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 388 const ash::DisplayLayout& layout) { | 390 const ash::DisplayLayout& layout) { |
| 389 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 391 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 390 } | 392 } |
| 391 | 393 |
| 392 // Stores the given |power_state|. | 394 // Stores the given |power_state|. |
| 393 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 395 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 394 StoreDisplayPowerState(power_state); | 396 StoreDisplayPowerState(power_state); |
| 395 } | 397 } |
| 396 | 398 |
| 397 } // namespace chromeos | 399 } // namespace chromeos |
| OLD | NEW |