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