| 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_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 ash::DisplayController* GetDisplayController() { | 76 ash::DisplayController* GetDisplayController() { |
| 77 return ash::Shell::GetInstance()->display_controller(); | 77 return ash::Shell::GetInstance()->display_controller(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void LoadDisplayLayouts() { | 80 void LoadDisplayLayouts() { |
| 81 PrefService* local_state = g_browser_process->local_state(); | 81 PrefService* local_state = g_browser_process->local_state(); |
| 82 ash::DisplayController* display_controller = GetDisplayController(); | 82 ash::DisplayController* display_controller = GetDisplayController(); |
| 83 | 83 |
| 84 ash::DisplayLayout default_layout = ash::DisplayLayout::FromInts( | 84 ash::DisplayLayout default_layout = ash::DisplayLayout::FromInts( |
| 85 local_state->GetInteger(prefs::kSecondaryDisplayLayout), | 85 local_state->GetInteger(prefs::kSecondaryDisplayLayout), |
| 86 local_state->GetInteger(prefs::kSecondaryDisplayOffset)); | 86 local_state->GetInteger(prefs::kSecondaryDisplayOffset), |
| 87 false); |
| 87 display_controller->SetDefaultDisplayLayout(default_layout); | 88 display_controller->SetDefaultDisplayLayout(default_layout); |
| 88 | 89 |
| 89 const base::DictionaryValue* layouts = local_state->GetDictionary( | 90 const base::DictionaryValue* layouts = local_state->GetDictionary( |
| 90 prefs::kSecondaryDisplays); | 91 prefs::kSecondaryDisplays); |
| 91 for (DictionaryValue::Iterator it(*layouts); !it.IsAtEnd(); it.Advance()) { | 92 for (DictionaryValue::Iterator it(*layouts); !it.IsAtEnd(); it.Advance()) { |
| 92 ash::DisplayLayout layout; | 93 ash::DisplayLayout layout; |
| 93 if (!ash::DisplayLayout::ConvertFromValue(it.value(), &layout)) { | 94 if (!ash::DisplayLayout::ConvertFromValue(it.value(), &layout)) { |
| 94 LOG(WARNING) << "Invalid preference value for " << it.key(); | 95 LOG(WARNING) << "Invalid preference value for " << it.key(); |
| 95 continue; | 96 continue; |
| 96 } | 97 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 display_layout.offset); | 262 display_layout.offset); |
| 262 } | 263 } |
| 263 } | 264 } |
| 264 | 265 |
| 265 void LoadDisplayPreferences() { | 266 void LoadDisplayPreferences() { |
| 266 PrefService* local_state = g_browser_process->local_state(); | 267 PrefService* local_state = g_browser_process->local_state(); |
| 267 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( | 268 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( |
| 268 local_state->GetInt64(prefs::kPrimaryDisplayID)); | 269 local_state->GetInt64(prefs::kPrimaryDisplayID)); |
| 269 LoadDisplayLayouts(); | 270 LoadDisplayLayouts(); |
| 270 LoadDisplayProperties(); | 271 LoadDisplayProperties(); |
| 271 GetDisplayManager()->UpdateDisplays(); | |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Stores the display layout for given display pairs. | 274 // Stores the display layout for given display pairs. |
| 275 void StoreDisplayLayoutPrefForTest(int64 id1, | 275 void StoreDisplayLayoutPrefForTest(int64 id1, |
| 276 int64 id2, | 276 int64 id2, |
| 277 const ash::DisplayLayout& layout) { | 277 const ash::DisplayLayout& layout) { |
| 278 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 278 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace chromeos | 281 } // namespace chromeos |
| OLD | NEW |