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/display/resolution_notification_controller.h" | 10 #include "ash/display/resolution_notification_controller.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 else if (value == "dynamic") | 85 else if (value == "dynamic") |
86 return ui::COLOR_PROFILE_DYNAMIC; | 86 return ui::COLOR_PROFILE_DYNAMIC; |
87 else if (value == "movie") | 87 else if (value == "movie") |
88 return ui::COLOR_PROFILE_MOVIE; | 88 return ui::COLOR_PROFILE_MOVIE; |
89 else if (value == "reading") | 89 else if (value == "reading") |
90 return ui::COLOR_PROFILE_READING; | 90 return ui::COLOR_PROFILE_READING; |
91 NOTREACHED(); | 91 NOTREACHED(); |
92 return ui::COLOR_PROFILE_STANDARD; | 92 return ui::COLOR_PROFILE_STANDARD; |
93 } | 93 } |
94 | 94 |
95 ash::internal::DisplayManager* GetDisplayManager() { | 95 ash::DisplayManager* GetDisplayManager() { |
96 return ash::Shell::GetInstance()->display_manager(); | 96 return ash::Shell::GetInstance()->display_manager(); |
97 } | 97 } |
98 | 98 |
99 // Returns true id the current user can write display preferences to | 99 // Returns true id the current user can write display preferences to |
100 // Local State. | 100 // Local State. |
101 bool UserCanSaveDisplayPreference() { | 101 bool UserCanSaveDisplayPreference() { |
102 UserManager* user_manager = UserManager::Get(); | 102 UserManager* user_manager = UserManager::Get(); |
103 return user_manager->IsUserLoggedIn() && | 103 return user_manager->IsUserLoggedIn() && |
104 (user_manager->IsLoggedInAsRegularUser() || | 104 (user_manager->IsLoggedInAsRegularUser() || |
105 user_manager->IsLoggedInAsLocallyManagedUser() || | 105 user_manager->IsLoggedInAsLocallyManagedUser() || |
106 user_manager->IsLoggedInAsKioskApp()); | 106 user_manager->IsLoggedInAsKioskApp()); |
107 } | 107 } |
108 | 108 |
109 void LoadDisplayLayouts() { | 109 void LoadDisplayLayouts() { |
110 PrefService* local_state = g_browser_process->local_state(); | 110 PrefService* local_state = g_browser_process->local_state(); |
111 ash::internal::DisplayLayoutStore* layout_store = | 111 ash::DisplayLayoutStore* layout_store = GetDisplayManager()->layout_store(); |
112 GetDisplayManager()->layout_store(); | |
113 | 112 |
114 const base::DictionaryValue* layouts = local_state->GetDictionary( | 113 const base::DictionaryValue* layouts = local_state->GetDictionary( |
115 prefs::kSecondaryDisplays); | 114 prefs::kSecondaryDisplays); |
116 for (base::DictionaryValue::Iterator it(*layouts); | 115 for (base::DictionaryValue::Iterator it(*layouts); |
117 !it.IsAtEnd(); it.Advance()) { | 116 !it.IsAtEnd(); it.Advance()) { |
118 ash::DisplayLayout layout; | 117 ash::DisplayLayout layout; |
119 if (!ash::DisplayLayout::ConvertFromValue(it.value(), &layout)) { | 118 if (!ash::DisplayLayout::ConvertFromValue(it.value(), &layout)) { |
120 LOG(WARNING) << "Invalid preference value for " << it.key(); | 119 LOG(WARNING) << "Invalid preference value for " << it.key(); |
121 continue; | 120 continue; |
122 } | 121 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return; | 208 return; |
210 } | 209 } |
211 | 210 |
212 ash::DisplayIdPair pair = GetDisplayManager()->GetCurrentDisplayIdPair(); | 211 ash::DisplayIdPair pair = GetDisplayManager()->GetCurrentDisplayIdPair(); |
213 ash::DisplayLayout display_layout = | 212 ash::DisplayLayout display_layout = |
214 GetDisplayManager()->layout_store()->GetRegisteredDisplayLayout(pair); | 213 GetDisplayManager()->layout_store()->GetRegisteredDisplayLayout(pair); |
215 StoreDisplayLayoutPref(pair, display_layout); | 214 StoreDisplayLayoutPref(pair, display_layout); |
216 } | 215 } |
217 | 216 |
218 void StoreCurrentDisplayProperties() { | 217 void StoreCurrentDisplayProperties() { |
219 ash::internal::DisplayManager* display_manager = GetDisplayManager(); | 218 ash::DisplayManager* display_manager = GetDisplayManager(); |
220 PrefService* local_state = g_browser_process->local_state(); | 219 PrefService* local_state = g_browser_process->local_state(); |
221 | 220 |
222 DictionaryPrefUpdate update(local_state, prefs::kDisplayProperties); | 221 DictionaryPrefUpdate update(local_state, prefs::kDisplayProperties); |
223 base::DictionaryValue* pref_data = update.Get(); | 222 base::DictionaryValue* pref_data = update.Get(); |
224 | 223 |
225 size_t num = display_manager->GetNumDisplays(); | 224 size_t num = display_manager->GetNumDisplays(); |
226 for (size_t i = 0; i < num; ++i) { | 225 for (size_t i = 0; i < num; ++i) { |
227 const gfx::Display& display = display_manager->GetDisplayAt(i); | 226 const gfx::Display& display = display_manager->GetDisplayAt(i); |
228 int64 id = display.id(); | 227 int64 id = display.id(); |
229 ash::internal::DisplayInfo info = display_manager->GetDisplayInfo(id); | 228 ash::DisplayInfo info = display_manager->GetDisplayInfo(id); |
230 | 229 |
231 scoped_ptr<base::DictionaryValue> property_value( | 230 scoped_ptr<base::DictionaryValue> property_value( |
232 new base::DictionaryValue()); | 231 new base::DictionaryValue()); |
233 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); | 232 property_value->SetInteger("rotation", static_cast<int>(info.rotation())); |
234 property_value->SetInteger( | 233 property_value->SetInteger( |
235 "ui-scale", | 234 "ui-scale", |
236 static_cast<int>(info.configured_ui_scale() * 1000)); | 235 static_cast<int>(info.configured_ui_scale() * 1000)); |
237 ash::internal::DisplayMode mode; | 236 ash::DisplayMode mode; |
238 if (!display.IsInternal() && | 237 if (!display.IsInternal() && |
239 display_manager->GetSelectedModeForDisplayId(id, &mode) && | 238 display_manager->GetSelectedModeForDisplayId(id, &mode) && |
240 !mode.native) { | 239 !mode.native) { |
241 property_value->SetInteger("width", mode.size.width()); | 240 property_value->SetInteger("width", mode.size.width()); |
242 property_value->SetInteger("height", mode.size.height()); | 241 property_value->SetInteger("height", mode.size.height()); |
243 } | 242 } |
244 if (!info.overscan_insets_in_dip().empty()) | 243 if (!info.overscan_insets_in_dip().empty()) |
245 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); | 244 InsetsToValue(info.overscan_insets_in_dip(), property_value.get()); |
246 if (info.color_profile() != ui::COLOR_PROFILE_STANDARD) { | 245 if (info.color_profile() != ui::COLOR_PROFILE_STANDARD) { |
247 property_value->SetString( | 246 property_value->SetString( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 const ash::DisplayLayout& layout) { | 338 const ash::DisplayLayout& layout) { |
340 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 339 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
341 } | 340 } |
342 | 341 |
343 // Stores the given |power_state|. | 342 // Stores the given |power_state|. |
344 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 343 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
345 StoreDisplayPowerState(power_state); | 344 StoreDisplayPowerState(power_state); |
346 } | 345 } |
347 | 346 |
348 } // namespace chromeos | 347 } // namespace chromeos |
OLD | NEW |