| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cros/onc_network_parser.h" | 5 #include "chrome/browser/chromeos/cros/onc_network_parser.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/json/json_value_serializer.h" | 8 #include "base/json/json_value_serializer.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (!value.IsType(base::Value::TYPE_DICTIONARY)) { | 478 if (!value.IsType(base::Value::TYPE_DICTIONARY)) { |
| 479 VLOG(1) << network->name() << ": expected object of type " << onc_type; | 479 VLOG(1) << network->name() << ": expected object of type " << onc_type; |
| 480 return false; | 480 return false; |
| 481 } | 481 } |
| 482 VLOG(2) << "Parsing nested object of type " << onc_type; | 482 VLOG(2) << "Parsing nested object of type " << onc_type; |
| 483 const DictionaryValue* dict = NULL; | 483 const DictionaryValue* dict = NULL; |
| 484 value.GetAsDictionary(&dict); | 484 value.GetAsDictionary(&dict); |
| 485 for (DictionaryValue::key_iterator iter = dict->begin_keys(); | 485 for (DictionaryValue::key_iterator iter = dict->begin_keys(); |
| 486 iter != dict->end_keys(); ++iter) { | 486 iter != dict->end_keys(); ++iter) { |
| 487 const std::string& key = *iter; | 487 const std::string& key = *iter; |
| 488 if (key == "Recommended") | |
| 489 continue; | |
| 490 | |
| 491 base::Value* inner_value = NULL; | 488 base::Value* inner_value = NULL; |
| 492 dict->GetWithoutPathExpansion(key, &inner_value); | 489 dict->GetWithoutPathExpansion(key, &inner_value); |
| 493 int field_index; | 490 int field_index; |
| 494 for (field_index = 0; signature[field_index].field != NULL; ++field_index) { | 491 for (field_index = 0; signature[field_index].field != NULL; ++field_index) { |
| 495 if (key == signature[field_index].field) | 492 if (key == signature[field_index].field) |
| 496 break; | 493 break; |
| 497 } | 494 } |
| 498 if (signature[field_index].field == NULL) { | 495 if (signature[field_index].field == NULL) { |
| 499 VLOG(1) << network->name() << ": unexpected field: " | 496 VLOG(1) << network->name() << ": unexpected field: " |
| 500 << key << ", in type: " << onc_type; | 497 << key << ", in type: " << onc_type; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 // Do a pass over |signature|, filling in UI data where applicable. | 648 // Do a pass over |signature|, filling in UI data where applicable. |
| 652 NetworkUIData ui_data; | 649 NetworkUIData ui_data; |
| 653 for (int i = 0; signature[i].field != NULL; ++i) { | 650 for (int i = 0; signature[i].field != NULL; ++i) { |
| 654 if (!signature[i].ui_data_key) | 651 if (!signature[i].ui_data_key) |
| 655 continue; | 652 continue; |
| 656 | 653 |
| 657 bool controlled_by_policy = | 654 bool controlled_by_policy = |
| 658 (onc_source_ == NetworkUIData::ONC_SOURCE_DEVICE_POLICY || | 655 (onc_source_ == NetworkUIData::ONC_SOURCE_DEVICE_POLICY || |
| 659 onc_source_ == NetworkUIData::ONC_SOURCE_USER_POLICY) && | 656 onc_source_ == NetworkUIData::ONC_SOURCE_USER_POLICY) && |
| 660 !all_recommended && | 657 !all_recommended && |
| 661 recommended.find(signature[i].field) == recommended.end(); | 658 recommended.find(signature[i].ui_data_key) == recommended.end(); |
| 662 const Value* default_value = NULL; | 659 const Value* default_value = NULL; |
| 663 network->GetProperty(signature[i].index, &default_value); | 660 network->GetProperty(signature[i].index, &default_value); |
| 664 NetworkPropertyUIData property_ui_data( | 661 NetworkPropertyUIData property_ui_data( |
| 665 controlled_by_policy ? NetworkPropertyUIData::CONTROLLER_POLICY : | 662 controlled_by_policy ? NetworkPropertyUIData::CONTROLLER_POLICY : |
| 666 NetworkPropertyUIData::CONTROLLER_USER, | 663 NetworkPropertyUIData::CONTROLLER_USER, |
| 667 default_value ? default_value->DeepCopy() : NULL); | 664 default_value ? default_value->DeepCopy() : NULL); |
| 668 ui_data.SetProperty(signature[i].ui_data_key, property_ui_data); | 665 ui_data.SetProperty(signature[i].ui_data_key, property_ui_data); |
| 669 } | 666 } |
| 670 | 667 |
| 671 // Merge the result into the network-level |ui_data| dictionary. | 668 // Merge the result into the network-level |ui_data| dictionary. |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 // on the value of AuthenticationType. | 1117 // on the value of AuthenticationType. |
| 1121 { "L2TP-IPsec", PROVIDER_TYPE_L2TP_IPSEC_PSK }, | 1118 { "L2TP-IPsec", PROVIDER_TYPE_L2TP_IPSEC_PSK }, |
| 1122 { "OpenVPN", PROVIDER_TYPE_OPEN_VPN }, | 1119 { "OpenVPN", PROVIDER_TYPE_OPEN_VPN }, |
| 1123 }; | 1120 }; |
| 1124 CR_DEFINE_STATIC_LOCAL(EnumMapper<ProviderType>, parser, | 1121 CR_DEFINE_STATIC_LOCAL(EnumMapper<ProviderType>, parser, |
| 1125 (table, arraysize(table), PROVIDER_TYPE_MAX)); | 1122 (table, arraysize(table), PROVIDER_TYPE_MAX)); |
| 1126 return parser.Get(type); | 1123 return parser.Get(type); |
| 1127 } | 1124 } |
| 1128 | 1125 |
| 1129 } // namespace chromeos | 1126 } // namespace chromeos |
| OLD | NEW |