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 "chromeos/network/network_ui_data.h" | 5 #include "chromeos/network/network_ui_data.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/values.h" | 10 #include "base/values.h" |
9 | 11 |
10 namespace chromeos { | 12 namespace chromeos { |
11 | 13 |
12 // Top-level UI data dictionary keys. | 14 // Top-level UI data dictionary keys. |
13 const char NetworkUIData::kKeyONCSource[] = "onc_source"; | 15 const char NetworkUIData::kKeyONCSource[] = "onc_source"; |
14 const char NetworkUIData::kKeyUserSettings[] = "user_settings"; | 16 const char NetworkUIData::kKeyUserSettings[] = "user_settings"; |
15 const char NetworkUIData::kONCSourceUserImport[] = "user_import"; | 17 const char NetworkUIData::kONCSourceUserImport[] = "user_import"; |
16 const char NetworkUIData::kONCSourceDevicePolicy[] = "device_policy"; | 18 const char NetworkUIData::kONCSourceDevicePolicy[] = "device_policy"; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 83 |
82 const base::DictionaryValue* user_settings = NULL; | 84 const base::DictionaryValue* user_settings = NULL; |
83 if (dict.GetDictionary(kKeyUserSettings, &user_settings)) | 85 if (dict.GetDictionary(kKeyUserSettings, &user_settings)) |
84 user_settings_.reset(user_settings->DeepCopy()); | 86 user_settings_.reset(user_settings->DeepCopy()); |
85 } | 87 } |
86 | 88 |
87 NetworkUIData::~NetworkUIData() { | 89 NetworkUIData::~NetworkUIData() { |
88 } | 90 } |
89 | 91 |
90 void NetworkUIData::set_user_settings(scoped_ptr<base::DictionaryValue> dict) { | 92 void NetworkUIData::set_user_settings(scoped_ptr<base::DictionaryValue> dict) { |
91 user_settings_ = dict.Pass(); | 93 user_settings_ = std::move(dict); |
92 } | 94 } |
93 | 95 |
94 std::string NetworkUIData::GetONCSourceAsString() const { | 96 std::string NetworkUIData::GetONCSourceAsString() const { |
95 return EnumToString(kONCSourceTable, onc_source_); | 97 return EnumToString(kONCSourceTable, onc_source_); |
96 } | 98 } |
97 | 99 |
98 void NetworkUIData::FillDictionary(base::DictionaryValue* dict) const { | 100 void NetworkUIData::FillDictionary(base::DictionaryValue* dict) const { |
99 dict->Clear(); | 101 dict->Clear(); |
100 | 102 |
101 std::string source_string = GetONCSourceAsString(); | 103 std::string source_string = GetONCSourceAsString(); |
102 if (!source_string.empty()) | 104 if (!source_string.empty()) |
103 dict->SetString(kKeyONCSource, source_string); | 105 dict->SetString(kKeyONCSource, source_string); |
104 | 106 |
105 if (user_settings_) | 107 if (user_settings_) |
106 dict->SetWithoutPathExpansion(kKeyUserSettings, | 108 dict->SetWithoutPathExpansion(kKeyUserSettings, |
107 user_settings_->DeepCopy()); | 109 user_settings_->DeepCopy()); |
108 } | 110 } |
109 | 111 |
110 // static | 112 // static |
111 scoped_ptr<NetworkUIData> NetworkUIData::CreateFromONC( | 113 scoped_ptr<NetworkUIData> NetworkUIData::CreateFromONC( |
112 ::onc::ONCSource onc_source) { | 114 ::onc::ONCSource onc_source) { |
113 scoped_ptr<NetworkUIData> ui_data(new NetworkUIData()); | 115 scoped_ptr<NetworkUIData> ui_data(new NetworkUIData()); |
114 | 116 |
115 ui_data->onc_source_ = onc_source; | 117 ui_data->onc_source_ = onc_source; |
116 | 118 |
117 return ui_data.Pass(); | 119 return ui_data; |
118 } | 120 } |
119 | 121 |
120 } // namespace chromeos | 122 } // namespace chromeos |
OLD | NEW |