Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: chromeos/network/policy_util.cc

Issue 513143004: Renaming CreateShillConfiguration argument for clarification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/network/policy_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy_util.h" 5 #include "chromeos/network/policy_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chromeos/network/network_profile.h" 9 #include "chromeos/network/network_profile.h"
10 #include "chromeos/network/network_ui_data.h" 10 #include "chromeos/network/network_ui_data.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 return false; 125 return false;
126 } 126 }
127 127
128 } // namespace 128 } // namespace
129 129
130 scoped_ptr<base::DictionaryValue> CreateShillConfiguration( 130 scoped_ptr<base::DictionaryValue> CreateShillConfiguration(
131 const NetworkProfile& profile, 131 const NetworkProfile& profile,
132 const std::string& guid, 132 const std::string& guid,
133 const base::DictionaryValue* policy, 133 const base::DictionaryValue* policy,
134 const base::DictionaryValue* settings) { 134 const base::DictionaryValue* user_settings) {
135 scoped_ptr<base::DictionaryValue> effective; 135 scoped_ptr<base::DictionaryValue> effective;
136 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE; 136 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE;
137 if (policy) { 137 if (policy) {
138 if (profile.type() == NetworkProfile::TYPE_SHARED) { 138 if (profile.type() == NetworkProfile::TYPE_SHARED) {
139 effective = onc::MergeSettingsAndPoliciesToEffective( 139 effective = onc::MergeSettingsAndPoliciesToEffective(
140 NULL, // no user policy 140 NULL, // no user policy
141 policy, // device policy 141 policy, // device policy
142 NULL, // no user settings 142 NULL, // no user settings
143 settings); // shared settings 143 user_settings); // shared settings
144 onc_source = ::onc::ONC_SOURCE_DEVICE_POLICY; 144 onc_source = ::onc::ONC_SOURCE_DEVICE_POLICY;
145 } else if (profile.type() == NetworkProfile::TYPE_USER) { 145 } else if (profile.type() == NetworkProfile::TYPE_USER) {
146 effective = onc::MergeSettingsAndPoliciesToEffective( 146 effective = onc::MergeSettingsAndPoliciesToEffective(
147 policy, // user policy 147 policy, // user policy
148 NULL, // no device policy 148 NULL, // no device policy
149 settings, // user settings 149 user_settings, // user settings
150 NULL); // no shared settings 150 NULL); // no shared settings
151 onc_source = ::onc::ONC_SOURCE_USER_POLICY; 151 onc_source = ::onc::ONC_SOURCE_USER_POLICY;
152 } else { 152 } else {
153 NOTREACHED(); 153 NOTREACHED();
154 } 154 }
155 } else if (settings) { 155 } else if (user_settings) {
156 effective.reset(settings->DeepCopy()); 156 effective.reset(user_settings->DeepCopy());
157 // TODO(pneubeck): change to source ONC_SOURCE_USER 157 // TODO(pneubeck): change to source ONC_SOURCE_USER
158 onc_source = ::onc::ONC_SOURCE_NONE; 158 onc_source = ::onc::ONC_SOURCE_NONE;
159 } else { 159 } else {
160 NOTREACHED(); 160 NOTREACHED();
161 onc_source = ::onc::ONC_SOURCE_NONE; 161 onc_source = ::onc::ONC_SOURCE_NONE;
162 } 162 }
163 163
164 RemoveFakeCredentials(onc::kNetworkConfigurationSignature, 164 RemoveFakeCredentials(onc::kNetworkConfigurationSignature,
165 effective.get()); 165 effective.get());
166 166
167 effective->SetStringWithoutPathExpansion(::onc::network_config::kGUID, guid); 167 effective->SetStringWithoutPathExpansion(::onc::network_config::kGUID, guid);
168 168
169 // Remove irrelevant fields. 169 // Remove irrelevant fields.
170 onc::Normalizer normalizer(true /* remove recommended fields */); 170 onc::Normalizer normalizer(true /* remove recommended fields */);
171 effective = normalizer.NormalizeObject(&onc::kNetworkConfigurationSignature, 171 effective = normalizer.NormalizeObject(&onc::kNetworkConfigurationSignature,
172 *effective); 172 *effective);
173 173
174 scoped_ptr<base::DictionaryValue> shill_dictionary( 174 scoped_ptr<base::DictionaryValue> shill_dictionary(
175 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature, 175 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature,
176 *effective)); 176 *effective));
177 177
178 shill_dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty, 178 shill_dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty,
179 profile.path); 179 profile.path);
180 180
181 scoped_ptr<NetworkUIData> ui_data(NetworkUIData::CreateFromONC(onc_source)); 181 scoped_ptr<NetworkUIData> ui_data(NetworkUIData::CreateFromONC(onc_source));
182 182
183 if (settings) { 183 if (user_settings) {
184 // Shill doesn't know that sensitive data is contained in the UIData 184 // Shill doesn't know that sensitive data is contained in the UIData
185 // property and might write it into logs or other insecure places. Thus, we 185 // property and might write it into logs or other insecure places. Thus, we
186 // have to remove or mask credentials. 186 // have to remove or mask credentials.
187 // 187 //
188 // Shill's GetProperties doesn't return credentials. Masking credentials 188 // Shill's GetProperties doesn't return credentials. Masking credentials
189 // instead of just removing them, allows remembering if a credential is set 189 // instead of just removing them, allows remembering if a credential is set
190 // or not. 190 // or not.
191 scoped_ptr<base::DictionaryValue> sanitized_settings( 191 scoped_ptr<base::DictionaryValue> sanitized_user_settings(
192 onc::MaskCredentialsInOncObject(onc::kNetworkConfigurationSignature, 192 onc::MaskCredentialsInOncObject(onc::kNetworkConfigurationSignature,
193 *settings, 193 *user_settings,
194 kFakeCredential)); 194 kFakeCredential));
195 ui_data->set_user_settings(sanitized_settings.Pass()); 195 ui_data->set_user_settings(sanitized_user_settings.Pass());
196 } 196 }
197 197
198 shill_property_util::SetUIData(*ui_data, shill_dictionary.get()); 198 shill_property_util::SetUIData(*ui_data, shill_dictionary.get());
199 199
200 VLOG(2) << "Created Shill properties: " << *shill_dictionary; 200 VLOG(2) << "Created Shill properties: " << *shill_dictionary;
201 201
202 return shill_dictionary.Pass(); 202 return shill_dictionary.Pass();
203 } 203 }
204 204
205 const base::DictionaryValue* FindMatchingPolicy( 205 const base::DictionaryValue* FindMatchingPolicy(
206 const GuidToPolicyMap& policies, 206 const GuidToPolicyMap& policies,
207 const base::DictionaryValue& actual_network) { 207 const base::DictionaryValue& actual_network) {
208 for (GuidToPolicyMap::const_iterator it = policies.begin(); 208 for (GuidToPolicyMap::const_iterator it = policies.begin();
209 it != policies.end(); ++it) { 209 it != policies.end(); ++it) {
210 if (IsPolicyMatching(*it->second, actual_network)) 210 if (IsPolicyMatching(*it->second, actual_network))
211 return it->second; 211 return it->second;
212 } 212 }
213 return NULL; 213 return NULL;
214 } 214 }
215 215
216 } // namespace policy_util 216 } // namespace policy_util
217 217
218 } // namespace chromeos 218 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/policy_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698