| OLD | NEW |
| 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 #ifndef CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ | 5 #ifndef CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ |
| 6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ | 6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Returns true if |key| corresponds to a passphrase property. | 74 // Returns true if |key| corresponds to a passphrase property. |
| 75 bool IsPassphraseKey(const std::string& key); | 75 bool IsPassphraseKey(const std::string& key); |
| 76 | 76 |
| 77 // Parses |value| (which should be a Dictionary). Returns true and sets | 77 // Parses |value| (which should be a Dictionary). Returns true and sets |
| 78 // |home_provider_id| if |value| was succesfully parsed. | 78 // |home_provider_id| if |value| was succesfully parsed. |
| 79 bool GetHomeProviderFromProperty(const base::Value& value, | 79 bool GetHomeProviderFromProperty(const base::Value& value, |
| 80 std::string* home_provider_id); | 80 std::string* home_provider_id); |
| 81 | 81 |
| 82 } // namespace shill_property_util | 82 } // namespace shill_property_util |
| 83 | 83 |
| 84 class CHROMEOS_EXPORT NetworkTypePattern { | |
| 85 public: | |
| 86 // Matches any network. | |
| 87 static NetworkTypePattern Default(); | |
| 88 | |
| 89 // Matches wireless (WiFi, cellular, etc.) networks | |
| 90 static NetworkTypePattern Wireless(); | |
| 91 | |
| 92 // Matches cellular or wimax networks. | |
| 93 static NetworkTypePattern Mobile(); | |
| 94 | |
| 95 // Matches non virtual networks. | |
| 96 static NetworkTypePattern NonVirtual(); | |
| 97 | |
| 98 // Matches ethernet networks (with or without EAP). | |
| 99 static NetworkTypePattern Ethernet(); | |
| 100 | |
| 101 static NetworkTypePattern WiFi(); | |
| 102 static NetworkTypePattern Cellular(); | |
| 103 static NetworkTypePattern VPN(); | |
| 104 static NetworkTypePattern Wimax(); | |
| 105 | |
| 106 // Matches only networks of exactly the type |shill_network_type|, which must | |
| 107 // be one of the types defined in service_constants.h (e.g. | |
| 108 // shill::kTypeWifi). | |
| 109 // Note: Shill distinguishes Ethernet without EAP from Ethernet with EAP. If | |
| 110 // unsure, better use one of the matchers above. | |
| 111 static NetworkTypePattern Primitive(const std::string& shill_network_type); | |
| 112 | |
| 113 bool Equals(const NetworkTypePattern& other) const; | |
| 114 bool MatchesType(const std::string& shill_network_type) const; | |
| 115 | |
| 116 // Returns true if this pattern matches at least one network type that | |
| 117 // |other_pattern| matches (according to MatchesType). Thus MatchesPattern is | |
| 118 // symmetric and reflexive but not transitive. | |
| 119 // See the unit test for examples. | |
| 120 bool MatchesPattern(const NetworkTypePattern& other_pattern) const; | |
| 121 | |
| 122 std::string ToDebugString() const; | |
| 123 | |
| 124 private: | |
| 125 explicit NetworkTypePattern(int pattern); | |
| 126 | |
| 127 // The bit array of the matching network types. | |
| 128 int pattern_; | |
| 129 | |
| 130 DISALLOW_ASSIGN(NetworkTypePattern); | |
| 131 }; | |
| 132 | |
| 133 } // namespace chromeos | 84 } // namespace chromeos |
| 134 | 85 |
| 135 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ | 86 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_ |
| OLD | NEW |