| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/display/display_layout_store.h" | 9 #include "ash/display/display_layout_store.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); | 366 DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); |
| 367 base::DictionaryValue* pref_data = update.Get(); | 367 base::DictionaryValue* pref_data = update.Get(); |
| 368 pref_data->SetBoolean("lock", rotation_lock); | 368 pref_data->SetBoolean("lock", rotation_lock); |
| 369 gfx::Display::Rotation rotation = | 369 gfx::Display::Rotation rotation = |
| 370 GetDisplayManager() | 370 GetDisplayManager() |
| 371 ->GetDisplayInfo(gfx::Display::InternalDisplayId()) | 371 ->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
| 372 .GetRotation(gfx::Display::ROTATION_SOURCE_ACCELEROMETER); | 372 .GetRotation(gfx::Display::ROTATION_SOURCE_ACCELEROMETER); |
| 373 pref_data->SetInteger("orientation", static_cast<int>(rotation)); | 373 pref_data->SetInteger("orientation", static_cast<int>(rotation)); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void SetCurrentDisplayLayout(const ash::DisplayLayout& layout) { | |
| 377 GetDisplayManager()->SetLayoutForCurrentDisplays(layout); | |
| 378 } | |
| 379 | |
| 380 void LoadDisplayPreferences(bool first_run_after_boot) { | 376 void LoadDisplayPreferences(bool first_run_after_boot) { |
| 381 LoadDisplayLayouts(); | 377 LoadDisplayLayouts(); |
| 382 LoadDisplayProperties(); | 378 LoadDisplayProperties(); |
| 383 LoadDisplayRotationState(); | 379 LoadDisplayRotationState(); |
| 384 if (!first_run_after_boot) { | 380 if (!first_run_after_boot) { |
| 385 PrefService* local_state = g_browser_process->local_state(); | 381 PrefService* local_state = g_browser_process->local_state(); |
| 386 // Restore DisplayPowerState: | 382 // Restore DisplayPowerState: |
| 387 std::string value = local_state->GetString(prefs::kDisplayPowerState); | 383 std::string value = local_state->GetString(prefs::kDisplayPowerState); |
| 388 chromeos::DisplayPowerState power_state; | 384 chromeos::DisplayPowerState power_state; |
| 389 if (GetDisplayPowerStateFromString(value, &power_state)) { | 385 if (GetDisplayPowerStateFromString(value, &power_state)) { |
| 390 ash::Shell::GetInstance()->display_configurator()->SetInitialDisplayPower( | 386 ash::Shell::GetInstance()->display_configurator()->SetInitialDisplayPower( |
| 391 power_state); | 387 power_state); |
| 392 } | 388 } |
| 393 } | 389 } |
| 394 } | 390 } |
| 395 | 391 |
| 396 // Stores the display layout for given display pairs. | 392 // Stores the display layout for given display pairs. |
| 397 void StoreDisplayLayoutPrefForTest(int64_t id1, | 393 void StoreDisplayLayoutPrefForTest(int64_t id1, |
| 398 int64_t id2, | 394 int64_t id2, |
| 399 const ash::DisplayLayout& layout) { | 395 const ash::DisplayLayout& layout) { |
| 400 StoreDisplayLayoutPref(ash::CreateDisplayIdPair(id1, id2), layout); | 396 StoreDisplayLayoutPref(ash::CreateDisplayIdPair(id1, id2), layout); |
| 401 } | 397 } |
| 402 | 398 |
| 403 // Stores the given |power_state|. | 399 // Stores the given |power_state|. |
| 404 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 400 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 405 StoreDisplayPowerState(power_state); | 401 StoreDisplayPowerState(power_state); |
| 406 } | 402 } |
| 407 | 403 |
| 408 } // namespace chromeos | 404 } // namespace chromeos |
| OLD | NEW |