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_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.Rotation(gfx::Display::ROTATION_SOURCE_USER))); | |
|
jonross
2015/04/10 17:54:43
This is not just a refactor, but addresses the bug
tdanderson
2015/04/13 22:44:46
nit: Consider changing your CL title to mention th
jonross
2015/04/15 17:43:12
Done.
| |
| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 | 351 |
| 350 void StoreDisplayRotationPrefs(bool rotation_lock) { | 352 void StoreDisplayRotationPrefs(bool rotation_lock) { |
| 351 ash::DisplayManager* display_manager = GetDisplayManager(); | 353 ash::DisplayManager* display_manager = GetDisplayManager(); |
| 352 if (!display_manager->HasInternalDisplay()) | 354 if (!display_manager->HasInternalDisplay()) |
| 353 return; | 355 return; |
| 354 | 356 |
| 355 PrefService* local_state = g_browser_process->local_state(); | 357 PrefService* local_state = g_browser_process->local_state(); |
| 356 DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); | 358 DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); |
| 357 base::DictionaryValue* pref_data = update.Get(); | 359 base::DictionaryValue* pref_data = update.Get(); |
| 358 pref_data->SetBoolean("lock", rotation_lock); | 360 pref_data->SetBoolean("lock", rotation_lock); |
| 359 gfx::Display::Rotation rotation = display_manager-> | 361 gfx::Display::Rotation rotation = |
| 360 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); | 362 display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
| 363 .Rotation(gfx::Display::ROTATION_SOURCE_ACCELEROMETER); | |
| 361 pref_data->SetInteger("orientation", static_cast<int>(rotation)); | 364 pref_data->SetInteger("orientation", static_cast<int>(rotation)); |
| 362 } | 365 } |
| 363 | 366 |
| 364 void SetCurrentDisplayLayout(const ash::DisplayLayout& layout) { | 367 void SetCurrentDisplayLayout(const ash::DisplayLayout& layout) { |
| 365 GetDisplayManager()->SetLayoutForCurrentDisplays(layout); | 368 GetDisplayManager()->SetLayoutForCurrentDisplays(layout); |
| 366 } | 369 } |
| 367 | 370 |
| 368 void LoadDisplayPreferences(bool first_run_after_boot) { | 371 void LoadDisplayPreferences(bool first_run_after_boot) { |
| 369 LoadDisplayLayouts(); | 372 LoadDisplayLayouts(); |
| 370 LoadDisplayProperties(); | 373 LoadDisplayProperties(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 387 const ash::DisplayLayout& layout) { | 390 const ash::DisplayLayout& layout) { |
| 388 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 391 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 389 } | 392 } |
| 390 | 393 |
| 391 // Stores the given |power_state|. | 394 // Stores the given |power_state|. |
| 392 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 395 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 393 StoreDisplayPowerState(power_state); | 396 StoreDisplayPowerState(power_state); |
| 394 } | 397 } |
| 395 | 398 |
| 396 } // namespace chromeos | 399 } // namespace chromeos |
| OLD | NEW |