| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 user_manager->IsLoggedInAsKioskApp()); | 77 user_manager->IsLoggedInAsKioskApp()); |
| 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::internal::DisplayLayoutStore* layout_store = | 82 ash::internal::DisplayLayoutStore* layout_store = |
| 83 GetDisplayManager()->layout_store(); | 83 GetDisplayManager()->layout_store(); |
| 84 | 84 |
| 85 const base::DictionaryValue* layouts = local_state->GetDictionary( | 85 const base::DictionaryValue* layouts = local_state->GetDictionary( |
| 86 prefs::kSecondaryDisplays); | 86 prefs::kSecondaryDisplays); |
| 87 for (DictionaryValue::Iterator it(*layouts); !it.IsAtEnd(); it.Advance()) { | 87 for (base::DictionaryValue::Iterator it(*layouts); |
| 88 !it.IsAtEnd(); it.Advance()) { |
| 88 ash::DisplayLayout layout; | 89 ash::DisplayLayout layout; |
| 89 if (!ash::DisplayLayout::ConvertFromValue(it.value(), &layout)) { | 90 if (!ash::DisplayLayout::ConvertFromValue(it.value(), &layout)) { |
| 90 LOG(WARNING) << "Invalid preference value for " << it.key(); | 91 LOG(WARNING) << "Invalid preference value for " << it.key(); |
| 91 continue; | 92 continue; |
| 92 } | 93 } |
| 93 | 94 |
| 94 if (it.key().find(",") != std::string::npos) { | 95 if (it.key().find(",") != std::string::npos) { |
| 95 std::vector<std::string> ids; | 96 std::vector<std::string> ids; |
| 96 base::SplitString(it.key(), ',', &ids); | 97 base::SplitString(it.key(), ',', &ids); |
| 97 int64 id1 = gfx::Display::kInvalidDisplayID; | 98 int64 id1 = gfx::Display::kInvalidDisplayID; |
| 98 int64 id2 = gfx::Display::kInvalidDisplayID; | 99 int64 id2 = gfx::Display::kInvalidDisplayID; |
| 99 if (!base::StringToInt64(ids[0], &id1) || | 100 if (!base::StringToInt64(ids[0], &id1) || |
| 100 !base::StringToInt64(ids[1], &id2) || | 101 !base::StringToInt64(ids[1], &id2) || |
| 101 id1 == gfx::Display::kInvalidDisplayID || | 102 id1 == gfx::Display::kInvalidDisplayID || |
| 102 id2 == gfx::Display::kInvalidDisplayID) { | 103 id2 == gfx::Display::kInvalidDisplayID) { |
| 103 continue; | 104 continue; |
| 104 } | 105 } |
| 105 layout_store->RegisterLayoutForDisplayIdPair(id1, id2, layout); | 106 layout_store->RegisterLayoutForDisplayIdPair(id1, id2, layout); |
| 106 } | 107 } |
| 107 } | 108 } |
| 108 } | 109 } |
| 109 | 110 |
| 110 void LoadDisplayProperties() { | 111 void LoadDisplayProperties() { |
| 111 PrefService* local_state = g_browser_process->local_state(); | 112 PrefService* local_state = g_browser_process->local_state(); |
| 112 const base::DictionaryValue* properties = local_state->GetDictionary( | 113 const base::DictionaryValue* properties = local_state->GetDictionary( |
| 113 prefs::kDisplayProperties); | 114 prefs::kDisplayProperties); |
| 114 for (DictionaryValue::Iterator it(*properties); !it.IsAtEnd(); it.Advance()) { | 115 for (base::DictionaryValue::Iterator it(*properties); |
| 116 !it.IsAtEnd(); it.Advance()) { |
| 115 const base::DictionaryValue* dict_value = NULL; | 117 const base::DictionaryValue* dict_value = NULL; |
| 116 if (!it.value().GetAsDictionary(&dict_value) || dict_value == NULL) | 118 if (!it.value().GetAsDictionary(&dict_value) || dict_value == NULL) |
| 117 continue; | 119 continue; |
| 118 int64 id = gfx::Display::kInvalidDisplayID; | 120 int64 id = gfx::Display::kInvalidDisplayID; |
| 119 if (!base::StringToInt64(it.key(), &id) || | 121 if (!base::StringToInt64(it.key(), &id) || |
| 120 id == gfx::Display::kInvalidDisplayID) { | 122 id == gfx::Display::kInvalidDisplayID) { |
| 121 continue; | 123 continue; |
| 122 } | 124 } |
| 123 gfx::Display::Rotation rotation = gfx::Display::ROTATE_0; | 125 gfx::Display::Rotation rotation = gfx::Display::ROTATE_0; |
| 124 float ui_scale = 1.0f; | 126 float ui_scale = 1.0f; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 const ash::DisplayLayout& layout) { | 300 const ash::DisplayLayout& layout) { |
| 299 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); | 301 StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); |
| 300 } | 302 } |
| 301 | 303 |
| 302 // Stores the given |power_state|. | 304 // Stores the given |power_state|. |
| 303 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 305 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 304 StoreDisplayPowerState(power_state); | 306 StoreDisplayPowerState(power_state); |
| 305 } | 307 } |
| 306 | 308 |
| 307 } // namespace chromeos | 309 } // namespace chromeos |
| OLD | NEW |