| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 !it.IsAtEnd(); it.Advance()) { | 120 !it.IsAtEnd(); it.Advance()) { |
| 121 scoped_ptr<ash::DisplayLayout> layout(new ash::DisplayLayout); | 121 scoped_ptr<ash::DisplayLayout> layout(new ash::DisplayLayout); |
| 122 if (!ash::JsonToDisplayLayout(it.value(), layout.get())) { | 122 if (!ash::JsonToDisplayLayout(it.value(), layout.get())) { |
| 123 LOG(WARNING) << "Invalid preference value for " << it.key(); | 123 LOG(WARNING) << "Invalid preference value for " << it.key(); |
| 124 continue; | 124 continue; |
| 125 } | 125 } |
| 126 | 126 |
| 127 if (it.key().find(",") != std::string::npos) { | 127 if (it.key().find(",") != std::string::npos) { |
| 128 std::vector<std::string> ids_str = base::SplitString( | 128 std::vector<std::string> ids_str = base::SplitString( |
| 129 it.key(), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 129 it.key(), ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 130 int64_t id1 = gfx::Display::kInvalidDisplayID; | 130 std::vector<int64_t> ids; |
| 131 int64_t id2 = gfx::Display::kInvalidDisplayID; | 131 for (std::string id_str : ids_str) { |
| 132 if (!base::StringToInt64(ids_str[0], &id1) || | 132 int64_t id; |
| 133 !base::StringToInt64(ids_str[1], &id2) || | 133 if (!base::StringToInt64(id_str, &id)) |
| 134 id1 == gfx::Display::kInvalidDisplayID || | 134 continue; |
| 135 id2 == gfx::Display::kInvalidDisplayID) { | 135 ids.push_back(id); |
| 136 continue; | |
| 137 } | 136 } |
| 138 int64_t ids[] = {id1, id2}; | |
| 139 ash::DisplayIdList list = | 137 ash::DisplayIdList list = |
| 140 ash::GenerateDisplayIdList(std::begin(ids), std::end(ids)); | 138 ash::GenerateDisplayIdList(ids.begin(), ids.end()); |
| 141 layout_store->RegisterLayoutForDisplayIdList(list, std::move(layout)); | 139 layout_store->RegisterLayoutForDisplayIdList(list, std::move(layout)); |
| 142 } | 140 } |
| 143 } | 141 } |
| 144 } | 142 } |
| 145 | 143 |
| 146 void LoadDisplayProperties() { | 144 void LoadDisplayProperties() { |
| 147 PrefService* local_state = g_browser_process->local_state(); | 145 PrefService* local_state = g_browser_process->local_state(); |
| 148 const base::DictionaryValue* properties = local_state->GetDictionary( | 146 const base::DictionaryValue* properties = local_state->GetDictionary( |
| 149 prefs::kDisplayProperties); | 147 prefs::kDisplayProperties); |
| 150 for (base::DictionaryValue::Iterator it(*properties); | 148 for (base::DictionaryValue::Iterator it(*properties); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 const ash::DisplayLayout& layout) { | 395 const ash::DisplayLayout& layout) { |
| 398 StoreDisplayLayoutPref(list, layout); | 396 StoreDisplayLayoutPref(list, layout); |
| 399 } | 397 } |
| 400 | 398 |
| 401 // Stores the given |power_state|. | 399 // Stores the given |power_state|. |
| 402 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 400 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 403 StoreDisplayPowerState(power_state); | 401 StoreDisplayPowerState(power_state); |
| 404 } | 402 } |
| 405 | 403 |
| 406 } // namespace chromeos | 404 } // namespace chromeos |
| OLD | NEW |