| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/display/json_converter.h" | 5 #include "ui/display/manager/json_converter.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/display/display_pref_util.h" | |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/values.h" | 12 #include "base/values.h" |
| 14 #include "ui/display/display_layout.h" | 13 #include "ui/display/display_layout.h" |
| 14 #include "ui/display/manager/display_pref_util.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace display { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // Persistent key names | 20 // Persistent key names |
| 21 const char kMirroredKey[] = "mirrored"; | 21 const char kMirroredKey[] = "mirrored"; |
| 22 const char kDefaultUnifiedKey[] = "default_unified"; | 22 const char kDefaultUnifiedKey[] = "default_unified"; |
| 23 const char kPrimaryIdKey[] = "primary-id"; | 23 const char kPrimaryIdKey[] = "primary-id"; |
| 24 const char kDisplayPlacementKey[] = "display_placement"; | 24 const char kDisplayPlacementKey[] = "display_placement"; |
| 25 | 25 |
| 26 // DisplayPlacement key names | 26 // DisplayPlacement key names |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 template <> | 88 template <> |
| 89 bool UpdateFromDict(const base::DictionaryValue* dict_value, | 89 bool UpdateFromDict(const base::DictionaryValue* dict_value, |
| 90 const std::string& field_name, | 90 const std::string& field_name, |
| 91 display::DisplayPlacement::Position* output) { | 91 display::DisplayPlacement::Position* output) { |
| 92 bool (base::Value::*getter)(std::string*) const = &base::Value::GetAsString; | 92 bool (base::Value::*getter)(std::string*) const = &base::Value::GetAsString; |
| 93 std::string value; | 93 std::string value; |
| 94 if (!UpdateFromDict(dict_value, field_name, getter, &value)) | 94 if (!UpdateFromDict(dict_value, field_name, getter, &value)) |
| 95 return false; | 95 return false; |
| 96 | 96 |
| 97 return value.empty() ? true : display::DisplayPlacement::StringToPosition( | 97 return value.empty() |
| 98 value, output); | 98 ? true |
| 99 : display::DisplayPlacement::StringToPosition(value, output); |
| 99 } | 100 } |
| 100 | 101 |
| 101 template <> | 102 template <> |
| 102 bool UpdateFromDict(const base::DictionaryValue* dict_value, | 103 bool UpdateFromDict(const base::DictionaryValue* dict_value, |
| 103 const std::string& field_name, | 104 const std::string& field_name, |
| 104 int64_t* output) { | 105 int64_t* output) { |
| 105 bool (base::Value::*getter)(std::string*) const = &base::Value::GetAsString; | 106 bool (base::Value::*getter)(std::string*) const = &base::Value::GetAsString; |
| 106 std::string value; | 107 std::string value; |
| 107 if (!UpdateFromDict(dict_value, field_name, getter, &value)) | 108 if (!UpdateFromDict(dict_value, field_name, getter, &value)) |
| 108 return false; | 109 return false; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 base::Int64ToString(placement.display_id)); | 192 base::Int64ToString(placement.display_id)); |
| 192 placement_value->SetString( | 193 placement_value->SetString( |
| 193 kDisplayPlacementParentDisplayIdKey, | 194 kDisplayPlacementParentDisplayIdKey, |
| 194 base::Int64ToString(placement.parent_display_id)); | 195 base::Int64ToString(placement.parent_display_id)); |
| 195 placement_list->Append(std::move(placement_value)); | 196 placement_list->Append(std::move(placement_value)); |
| 196 } | 197 } |
| 197 dict_value->Set(kDisplayPlacementKey, std::move(placement_list)); | 198 dict_value->Set(kDisplayPlacementKey, std::move(placement_list)); |
| 198 return true; | 199 return true; |
| 199 } | 200 } |
| 200 | 201 |
| 201 } // namespace ash | 202 } // namespace display |
| OLD | NEW |