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/onc/onc_utils.h" | 5 #include "chromeos/network/onc/onc_utils.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 if (type == ::onc::network_type::kWiFi) | 665 if (type == ::onc::network_type::kWiFi) |
666 return NetworkTypePattern::WiFi(); | 666 return NetworkTypePattern::WiFi(); |
667 if (type == ::onc::network_type::kWimax) | 667 if (type == ::onc::network_type::kWimax) |
668 return NetworkTypePattern::Wimax(); | 668 return NetworkTypePattern::Wimax(); |
669 if (type == ::onc::network_type::kWireless) | 669 if (type == ::onc::network_type::kWireless) |
670 return NetworkTypePattern::Wireless(); | 670 return NetworkTypePattern::Wireless(); |
671 NOTREACHED(); | 671 NOTREACHED(); |
672 return NetworkTypePattern::Default(); | 672 return NetworkTypePattern::Default(); |
673 } | 673 } |
674 | 674 |
| 675 bool IsRecommendedValue(const base::DictionaryValue* onc, |
| 676 const std::string& property_key) { |
| 677 std::string property_basename, recommended_property_key; |
| 678 size_t pos = property_key.find_last_of('.'); |
| 679 if (pos != std::string::npos) { |
| 680 // 'WiFi.AutoConnect' -> 'AutoConnect', 'WiFi.Recommended' |
| 681 property_basename = property_key.substr(pos + 1); |
| 682 recommended_property_key = |
| 683 property_key.substr(0, pos + 1) + ::onc::kRecommended; |
| 684 } else { |
| 685 // 'Name' -> 'Name', 'Recommended' |
| 686 property_basename = property_key; |
| 687 recommended_property_key = ::onc::kRecommended; |
| 688 } |
| 689 |
| 690 const base::ListValue* recommended_keys = NULL; |
| 691 return (onc->GetList(recommended_property_key, &recommended_keys) && |
| 692 recommended_keys->Find(base::StringValue(property_basename)) != |
| 693 recommended_keys->end()); |
| 694 } |
| 695 |
675 } // namespace onc | 696 } // namespace onc |
676 } // namespace chromeos | 697 } // namespace chromeos |
OLD | NEW |