| 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_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/display_pref_util.h" | 10 #include "ash/display/display_pref_util.h" |
| 11 #include "ash/display/display_util.h" | |
| 12 #include "ash/display/json_converter.h" | 11 #include "ash/display/json_converter.h" |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 18 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
| 19 #include "base/values.h" | 18 #include "base/values.h" |
| 20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 22 #include "components/prefs/pref_registry_simple.h" | 21 #include "components/prefs/pref_registry_simple.h" |
| 23 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 24 #include "components/prefs/scoped_user_pref_update.h" | 23 #include "components/prefs/scoped_user_pref_update.h" |
| 25 #include "components/user_manager/user_manager.h" | 24 #include "components/user_manager/user_manager.h" |
| 26 #include "third_party/cros_system_api/dbus/service_constants.h" | 25 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 27 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
| 28 #include "ui/display/manager/display_layout_store.h" | 27 #include "ui/display/manager/display_layout_store.h" |
| 28 #include "ui/display/manager/display_manager_utilities.h" |
| 29 #include "ui/gfx/geometry/insets.h" | 29 #include "ui/gfx/geometry/insets.h" |
| 30 #include "url/url_canon.h" | 30 #include "url/url_canon.h" |
| 31 #include "url/url_util.h" | 31 #include "url/url_util.h" |
| 32 | 32 |
| 33 namespace chromeos { | 33 namespace chromeos { |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 const char kInsetsTopKey[] = "insets_top"; | 36 const char kInsetsTopKey[] = "insets_top"; |
| 37 const char kInsetsLeftKey[] = "insets_left"; | 37 const char kInsetsLeftKey[] = "insets_left"; |
| 38 const char kInsetsBottomKey[] = "insets_bottom"; | 38 const char kInsetsBottomKey[] = "insets_bottom"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::vector<int64_t> ids; | 130 std::vector<int64_t> ids; |
| 131 for (std::string id_str : ids_str) { | 131 for (std::string id_str : ids_str) { |
| 132 int64_t id; | 132 int64_t id; |
| 133 if (!base::StringToInt64(id_str, &id)) | 133 if (!base::StringToInt64(id_str, &id)) |
| 134 continue; | 134 continue; |
| 135 ids.push_back(id); | 135 ids.push_back(id); |
| 136 } | 136 } |
| 137 display::DisplayIdList list = | 137 display::DisplayIdList list = |
| 138 ash::GenerateDisplayIdList(ids.begin(), ids.end()); | 138 display::GenerateDisplayIdList(ids.begin(), ids.end()); |
| 139 layout_store->RegisterLayoutForDisplayIdList(list, std::move(layout)); | 139 layout_store->RegisterLayoutForDisplayIdList(list, std::move(layout)); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void LoadDisplayProperties() { | 144 void LoadDisplayProperties() { |
| 145 PrefService* local_state = g_browser_process->local_state(); | 145 PrefService* local_state = g_browser_process->local_state(); |
| 146 const base::DictionaryValue* properties = local_state->GetDictionary( | 146 const base::DictionaryValue* properties = local_state->GetDictionary( |
| 147 prefs::kDisplayProperties); | 147 prefs::kDisplayProperties); |
| 148 for (base::DictionaryValue::Iterator it(*properties); | 148 for (base::DictionaryValue::Iterator it(*properties); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 int rotation = display::Display::ROTATE_0; | 207 int rotation = display::Display::ROTATE_0; |
| 208 if (!properties->GetInteger("orientation", &rotation)) | 208 if (!properties->GetInteger("orientation", &rotation)) |
| 209 return; | 209 return; |
| 210 | 210 |
| 211 GetDisplayManager()->RegisterDisplayRotationProperties( | 211 GetDisplayManager()->RegisterDisplayRotationProperties( |
| 212 rotation_lock, static_cast<display::Display::Rotation>(rotation)); | 212 rotation_lock, static_cast<display::Display::Rotation>(rotation)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void StoreDisplayLayoutPref(const display::DisplayIdList& list, | 215 void StoreDisplayLayoutPref(const display::DisplayIdList& list, |
| 216 const display::DisplayLayout& display_layout) { | 216 const display::DisplayLayout& display_layout) { |
| 217 std::string name = ash::DisplayIdListToString(list); | 217 std::string name = display::DisplayIdListToString(list); |
| 218 | 218 |
| 219 PrefService* local_state = g_browser_process->local_state(); | 219 PrefService* local_state = g_browser_process->local_state(); |
| 220 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); | 220 DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); |
| 221 base::DictionaryValue* pref_data = update.Get(); | 221 base::DictionaryValue* pref_data = update.Get(); |
| 222 std::unique_ptr<base::Value> layout_value(new base::DictionaryValue()); | 222 std::unique_ptr<base::Value> layout_value(new base::DictionaryValue()); |
| 223 if (pref_data->HasKey(name)) { | 223 if (pref_data->HasKey(name)) { |
| 224 base::Value* value = nullptr; | 224 base::Value* value = nullptr; |
| 225 if (pref_data->Get(name, &value) && value != nullptr) | 225 if (pref_data->Get(name, &value) && value != nullptr) |
| 226 layout_value.reset(value->DeepCopy()); | 226 layout_value.reset(value->DeepCopy()); |
| 227 } | 227 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 const display::DisplayLayout& layout) { | 394 const display::DisplayLayout& layout) { |
| 395 StoreDisplayLayoutPref(list, layout); | 395 StoreDisplayLayoutPref(list, layout); |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Stores the given |power_state|. | 398 // Stores the given |power_state|. |
| 399 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { | 399 void StoreDisplayPowerStateForTest(DisplayPowerState power_state) { |
| 400 StoreDisplayPowerState(power_state); | 400 StoreDisplayPowerState(power_state); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace chromeos | 403 } // namespace chromeos |
| OLD | NEW |