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

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

Issue 23872021: Use Name not SSID in CopyIdentifyingProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/options/wifi_config_view.cc ('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/shill_property_util.h" 5 #include "chromeos/network/shill_property_util.h"
6 6
7 #include "base/i18n/icu_encoding_detection.h" 7 #include "base/i18n/icu_encoding_detection.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 base::DictionaryValue ui_data_dict; 173 base::DictionaryValue ui_data_dict;
174 ui_data.FillDictionary(&ui_data_dict); 174 ui_data.FillDictionary(&ui_data_dict);
175 std::string ui_data_blob; 175 std::string ui_data_blob;
176 base::JSONWriter::Write(&ui_data_dict, &ui_data_blob); 176 base::JSONWriter::Write(&ui_data_dict, &ui_data_blob);
177 shill_dictionary->SetStringWithoutPathExpansion(flimflam::kUIDataProperty, 177 shill_dictionary->SetStringWithoutPathExpansion(flimflam::kUIDataProperty,
178 ui_data_blob); 178 ui_data_blob);
179 } 179 }
180 180
181 bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties, 181 bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
182 base::DictionaryValue* dest) { 182 base::DictionaryValue* dest) {
183 bool success = true;
184
185 // GUID is optional. 183 // GUID is optional.
186 CopyStringFromDictionary(service_properties, flimflam::kGuidProperty, dest); 184 CopyStringFromDictionary(service_properties, flimflam::kGuidProperty, dest);
187 185
188 std::string type; 186 std::string type;
189 service_properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty, 187 service_properties.GetStringWithoutPathExpansion(flimflam::kTypeProperty,
190 &type); 188 &type);
191 success &= !type.empty(); 189 if (type.empty()) {
190 NET_LOG_ERROR("CopyIdentifyingProperties", "Empty Type");
191 return false;
192 }
192 dest->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type); 193 dest->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type);
193 if (type == flimflam::kTypeWifi) { 194 if (type == flimflam::kTypeWifi) {
194 success &= CopyStringFromDictionary( 195 if (!CopyStringFromDictionary(
195 service_properties, flimflam::kSecurityProperty, dest); 196 service_properties, flimflam::kNameProperty, dest)) {
pneubeck (no reviews) 2013/09/13 07:15:10 I think that this change makes it even worse: From
196 success &= CopyStringFromDictionary( 197 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing Name");
197 service_properties, flimflam::kSSIDProperty, dest); 198 return false;
198 success &= CopyStringFromDictionary( 199 }
199 service_properties, flimflam::kModeProperty, dest); 200 if (!CopyStringFromDictionary(
201 service_properties, flimflam::kSecurityProperty, dest)) {
202 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing Security");
203 return false;
204 }
205 if (!CopyStringFromDictionary(
206 service_properties, flimflam::kModeProperty, dest)) {
207 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing Mode");
208 return false;
209 }
200 } else if (type == flimflam::kTypeVPN) { 210 } else if (type == flimflam::kTypeVPN) {
201 success &= CopyStringFromDictionary( 211 if (!CopyStringFromDictionary(
202 service_properties, flimflam::kNameProperty, dest); 212 service_properties, flimflam::kNameProperty, dest)) {
213 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing Name");
214 return false;
215 }
203 // VPN Provider values are read from the "Provider" dictionary, but written 216 // VPN Provider values are read from the "Provider" dictionary, but written
204 // with the keys "Provider.Type" and "Provider.Host". 217 // with the keys "Provider.Type" and "Provider.Host".
205 const base::DictionaryValue* provider_properties = NULL; 218 const base::DictionaryValue* provider_properties = NULL;
206 if (!service_properties.GetDictionaryWithoutPathExpansion( 219 if (!service_properties.GetDictionaryWithoutPathExpansion(
207 flimflam::kProviderProperty, &provider_properties)) { 220 flimflam::kProviderProperty, &provider_properties)) {
208 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing VPN provider dict"); 221 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing VPN Provider dict");
209 return false; 222 return false;
210 } 223 }
211 std::string vpn_provider_type; 224 std::string vpn_provider_type;
212 provider_properties->GetStringWithoutPathExpansion(flimflam::kTypeProperty, 225 provider_properties->GetStringWithoutPathExpansion(flimflam::kTypeProperty,
213 &vpn_provider_type); 226 &vpn_provider_type);
214 success &= !vpn_provider_type.empty(); 227 if (vpn_provider_type.empty()) {
228 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing Provider Type");
229 return false;
230 }
215 dest->SetStringWithoutPathExpansion(flimflam::kProviderTypeProperty, 231 dest->SetStringWithoutPathExpansion(flimflam::kProviderTypeProperty,
216 vpn_provider_type); 232 vpn_provider_type);
217 233
218 std::string vpn_provider_host; 234 std::string vpn_provider_host;
219 provider_properties->GetStringWithoutPathExpansion(flimflam::kHostProperty, 235 provider_properties->GetStringWithoutPathExpansion(flimflam::kHostProperty,
220 &vpn_provider_host); 236 &vpn_provider_host);
221 success &= !vpn_provider_host.empty(); 237 if (vpn_provider_host.empty()) {
238 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing Provider Host");
239 return false;
240 }
222 dest->SetStringWithoutPathExpansion(flimflam::kProviderHostProperty, 241 dest->SetStringWithoutPathExpansion(flimflam::kProviderHostProperty,
223 vpn_provider_host); 242 vpn_provider_host);
224 } else if (type == flimflam::kTypeEthernet || 243 } else if (type == flimflam::kTypeEthernet ||
225 type == shill::kTypeEthernetEap) { 244 type == shill::kTypeEthernetEap) {
226 // Ethernet and EthernetEAP don't have any additional identifying 245 // Ethernet and EthernetEAP don't have any additional identifying
227 // properties. 246 // properties.
228 } else { 247 } else {
229 NOTREACHED() << "Unsupported network type " << type; 248 NOTREACHED() << "Unsupported network type " << type;
230 success = false; 249 NET_LOG_ERROR("CopyIdentifyingProperties", "Bad Type: " + type);
250 return false;
231 } 251 }
232 if (!success) 252 return true;
233 NET_LOG_ERROR("CopyIdentifyingProperties", "Missing required properties");
234 return success;
235 } 253 }
236 254
237 } // namespace shill_property_util 255 } // namespace shill_property_util
238 256
239 namespace { 257 namespace {
240 258
241 const char kPatternDefault[] = "PatternDefault"; 259 const char kPatternDefault[] = "PatternDefault";
242 const char kPatternEthernet[] = "PatternEthernet"; 260 const char kPatternEthernet[] = "PatternEthernet";
243 const char kPatternWireless[] = "PatternWireless"; 261 const char kPatternWireless[] = "PatternWireless";
244 const char kPatternMobile[] = "PatternMobile"; 262 const char kPatternMobile[] = "PatternMobile";
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (!str.empty()) 383 if (!str.empty())
366 str += "|"; 384 str += "|";
367 str += shill_type_to_flag[i].shill_network_type; 385 str += shill_type_to_flag[i].shill_network_type;
368 } 386 }
369 return str; 387 return str;
370 } 388 }
371 389
372 NetworkTypePattern::NetworkTypePattern(int pattern) : pattern_(pattern) {} 390 NetworkTypePattern::NetworkTypePattern(int pattern) : pattern_(pattern) {}
373 391
374 } // namespace chromeos 392 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/options/wifi_config_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698