| 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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/chromeos/cros/network_parser.h" |
| 9 #include "base/compiler_specific.h" // for OVERRIDE | 10 #include "base/compiler_specific.h" // for OVERRIDE |
| 10 #include "chrome/browser/chromeos/cros/network_parser.h" | |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 // This is the network device parser that parses the data from the | 14 // This is the network device parser that parses the data from the |
| 15 // network stack on the native platform. Currently it parses | 15 // network stack on the native platform. Currently it parses |
| 16 // FlimFlam-provided information. | 16 // FlimFlam-provided information. |
| 17 class NativeNetworkDeviceParser : public NetworkDeviceParser { | 17 class NativeNetworkDeviceParser : public NetworkDeviceParser { |
| 18 public: | 18 public: |
| 19 NativeNetworkDeviceParser(); | 19 NativeNetworkDeviceParser(); |
| 20 virtual ~NativeNetworkDeviceParser(); | 20 virtual ~NativeNetworkDeviceParser(); |
| 21 | |
| 22 virtual bool ParseValue(PropertyIndex index, | 21 virtual bool ParseValue(PropertyIndex index, |
| 23 Value* value, | 22 const Value& value, |
| 24 NetworkDevice* device) OVERRIDE; | 23 NetworkDevice* device) OVERRIDE; |
| 25 | |
| 26 protected: | 24 protected: |
| 27 virtual ConnectionType ParseType(const std::string& type) OVERRIDE; | 25 virtual ConnectionType ParseType(const std::string& type) OVERRIDE; |
| 28 | 26 |
| 29 // Parsing helper routines specific to native network devices. | 27 // Parsing helper routines specific to native network devices. |
| 30 virtual bool ParseApnList(const ListValue& list, CellularApnList* apn_list); | 28 virtual bool ParseApnList(const ListValue& list, CellularApnList* apn_list); |
| 31 virtual bool ParseFoundNetworksFromList(const ListValue& list, | 29 virtual bool ParseFoundNetworksFromList(const ListValue& list, |
| 32 CellularNetworkList* found_networks); | 30 CellularNetworkList* found_networks); |
| 33 virtual SimLockState ParseSimLockState(const std::string& state); | 31 virtual SimLockState ParseSimLockState(const std::string& state); |
| 34 virtual bool ParseSimLockStateFromDictionary(const DictionaryValue& info, | 32 virtual bool ParseSimLockStateFromDictionary(const DictionaryValue& info, |
| 35 SimLockState* out_state, | 33 SimLockState* out_state, |
| 36 int* out_retries); | 34 int* out_retries); |
| 37 virtual TechnologyFamily ParseTechnologyFamily( | 35 virtual TechnologyFamily ParseTechnologyFamily( |
| 38 const std::string& technology_family); | 36 const std::string& technology_family); |
| 39 | 37 |
| 40 private: | 38 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(NativeNetworkDeviceParser); | 39 DISALLOW_COPY_AND_ASSIGN(NativeNetworkDeviceParser); |
| 42 }; | 40 }; |
| 43 | 41 |
| 44 // This is the network parser that parses the data from the network | 42 // This is the network parser that parses the data from the network |
| 45 // stack on the native platform. Currently it parses | 43 // stack on the native platform. Currently it parses |
| 46 // FlimFlam-provided information. | 44 // FlimFlam-provided information. |
| 47 class NativeNetworkParser : public NetworkParser { | 45 class NativeNetworkParser : public NetworkParser { |
| 48 public: | 46 public: |
| 49 NativeNetworkParser(); | 47 NativeNetworkParser(); |
| 50 virtual ~NativeNetworkParser(); | 48 virtual ~NativeNetworkParser(); |
| 51 | |
| 52 static const EnumMapper<PropertyIndex>* property_mapper(); | 49 static const EnumMapper<PropertyIndex>* property_mapper(); |
| 53 static const ConnectionType ParseConnectionType(const std::string& type); | 50 static const ConnectionType ParseConnectionType(const std::string& type); |
| 54 | |
| 55 protected: | 51 protected: |
| 56 virtual bool ParseValue(PropertyIndex index, | 52 virtual bool ParseValue(PropertyIndex index, |
| 57 Value* value, | 53 const Value& value, |
| 58 Network* network) OVERRIDE; | 54 Network* network) OVERRIDE; |
| 59 virtual ConnectionType ParseType(const std::string& type) OVERRIDE; | 55 virtual ConnectionType ParseType(const std::string& type) OVERRIDE; |
| 60 virtual ConnectionType ParseTypeFromDictionary( | 56 virtual ConnectionType ParseTypeFromDictionary( |
| 61 const DictionaryValue& info) OVERRIDE; | 57 const DictionaryValue& info) OVERRIDE; |
| 62 virtual ConnectionMode ParseMode(const std::string& mode) OVERRIDE; | 58 virtual ConnectionMode ParseMode(const std::string& mode) OVERRIDE; |
| 63 virtual ConnectionState ParseState(const std::string& state) OVERRIDE; | 59 virtual ConnectionState ParseState(const std::string& state) OVERRIDE; |
| 64 virtual ConnectionError ParseError(const std::string& error) OVERRIDE; | 60 virtual ConnectionError ParseError(const std::string& error) OVERRIDE; |
| 65 | |
| 66 private: | 61 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(NativeNetworkParser); | 62 DISALLOW_COPY_AND_ASSIGN(NativeNetworkParser); |
| 68 }; | 63 }; |
| 69 | 64 |
| 70 // Below are specific types of network parsers. | 65 // Below are specific types of network parsers. |
| 71 class NativeEthernetNetworkParser : public NativeNetworkParser { | 66 class NativeEthernetNetworkParser : public NativeNetworkParser { |
| 72 public: | 67 public: |
| 73 NativeEthernetNetworkParser(); | 68 NativeEthernetNetworkParser(); |
| 74 virtual ~NativeEthernetNetworkParser(); | 69 virtual ~NativeEthernetNetworkParser(); |
| 75 | |
| 76 private: | 70 private: |
| 77 // NOTE: Uses base class ParseValue, etc. | 71 // NOTE: Uses base class ParseValue, etc. |
| 78 | 72 |
| 79 DISALLOW_COPY_AND_ASSIGN(NativeEthernetNetworkParser); | 73 DISALLOW_COPY_AND_ASSIGN(NativeEthernetNetworkParser); |
| 80 }; | 74 }; |
| 81 | 75 |
| 82 // Base for wireless networks. | 76 // Base for wireless networks. |
| 83 class NativeWirelessNetworkParser : public NativeNetworkParser { | 77 class NativeWirelessNetworkParser : public NativeNetworkParser { |
| 84 public: | 78 public: |
| 85 NativeWirelessNetworkParser(); | 79 NativeWirelessNetworkParser(); |
| 86 virtual ~NativeWirelessNetworkParser(); | 80 virtual ~NativeWirelessNetworkParser(); |
| 87 virtual bool ParseValue(PropertyIndex index, | 81 virtual bool ParseValue(PropertyIndex index, |
| 88 Value* value, | 82 const Value& value, |
| 89 Network* network) OVERRIDE; | 83 Network* network) OVERRIDE; |
| 90 | |
| 91 private: | 84 private: |
| 92 DISALLOW_COPY_AND_ASSIGN(NativeWirelessNetworkParser); | 85 DISALLOW_COPY_AND_ASSIGN(NativeWirelessNetworkParser); |
| 93 }; | 86 }; |
| 94 | 87 |
| 95 class NativeWifiNetworkParser : public NativeWirelessNetworkParser { | 88 class NativeWifiNetworkParser : public NativeWirelessNetworkParser { |
| 96 public: | 89 public: |
| 97 NativeWifiNetworkParser(); | 90 NativeWifiNetworkParser(); |
| 98 virtual ~NativeWifiNetworkParser(); | 91 virtual ~NativeWifiNetworkParser(); |
| 99 virtual bool ParseValue(PropertyIndex index, | 92 virtual bool ParseValue(PropertyIndex index, |
| 100 Value* value, | 93 const Value& value, |
| 101 Network* network) OVERRIDE; | 94 Network* network) OVERRIDE; |
| 102 | |
| 103 protected: | 95 protected: |
| 104 ConnectionSecurity ParseSecurity(const std::string& security); | 96 ConnectionSecurity ParseSecurity(const std::string& security); |
| 105 EAPMethod ParseEAPMethod(const std::string& method); | 97 EAPMethod ParseEAPMethod(const std::string& method); |
| 106 EAPPhase2Auth ParseEAPPhase2Auth(const std::string& auth); | 98 EAPPhase2Auth ParseEAPPhase2Auth(const std::string& auth); |
| 107 | |
| 108 private: | 99 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(NativeWifiNetworkParser); | 100 DISALLOW_COPY_AND_ASSIGN(NativeWifiNetworkParser); |
| 110 }; | 101 }; |
| 111 | 102 |
| 112 class NativeCellularNetworkParser : public NativeWirelessNetworkParser { | 103 class NativeCellularNetworkParser : public NativeWirelessNetworkParser { |
| 113 public: | 104 public: |
| 114 NativeCellularNetworkParser(); | 105 NativeCellularNetworkParser(); |
| 115 virtual ~NativeCellularNetworkParser(); | 106 virtual ~NativeCellularNetworkParser(); |
| 116 virtual bool ParseValue(PropertyIndex index, | 107 virtual bool ParseValue(PropertyIndex index, |
| 117 Value* value, | 108 const Value& value, |
| 118 Network* network) OVERRIDE; | 109 Network* network) OVERRIDE; |
| 119 | |
| 120 protected: | 110 protected: |
| 121 ActivationState ParseActivationState(const std::string& state); | 111 ActivationState ParseActivationState(const std::string& state); |
| 122 NetworkTechnology ParseNetworkTechnology(const std::string& technology); | 112 NetworkTechnology ParseNetworkTechnology( |
| 123 NetworkRoamingState ParseRoamingState(const std::string& roaming_state); | 113 const std::string& technology); |
| 124 | 114 NetworkRoamingState ParseRoamingState( |
| 115 const std::string& roaming_state); |
| 125 private: | 116 private: |
| 126 DISALLOW_COPY_AND_ASSIGN(NativeCellularNetworkParser); | 117 DISALLOW_COPY_AND_ASSIGN(NativeCellularNetworkParser); |
| 127 }; | 118 }; |
| 128 | 119 |
| 129 class NativeVirtualNetworkParser : public NativeNetworkParser { | 120 class NativeVirtualNetworkParser : public NativeNetworkParser { |
| 130 public: | 121 public: |
| 131 NativeVirtualNetworkParser(); | 122 NativeVirtualNetworkParser(); |
| 132 virtual ~NativeVirtualNetworkParser(); | 123 virtual ~NativeVirtualNetworkParser(); |
| 133 virtual bool ParseValue(PropertyIndex index, | 124 virtual bool ParseValue(PropertyIndex index, |
| 134 Value* value, | 125 const Value& value, |
| 135 Network* network) OVERRIDE; | 126 Network* network) OVERRIDE; |
| 136 virtual bool UpdateNetworkFromInfo(const DictionaryValue& info, | 127 virtual bool UpdateNetworkFromInfo(const DictionaryValue& info, |
| 137 Network* network) OVERRIDE; | 128 Network* network) OVERRIDE; |
| 138 | |
| 139 protected: | 129 protected: |
| 140 bool ParseProviderValue(PropertyIndex index, | 130 bool ParseProviderValue(PropertyIndex index, |
| 141 const Value& value, | 131 const Value& value, |
| 142 VirtualNetwork* network); | 132 VirtualNetwork* network); |
| 143 ProviderType ParseProviderType(const std::string& type); | 133 ProviderType ParseProviderType(const std::string& type); |
| 144 | |
| 145 private: | 134 private: |
| 146 DISALLOW_COPY_AND_ASSIGN(NativeVirtualNetworkParser); | 135 DISALLOW_COPY_AND_ASSIGN(NativeVirtualNetworkParser); |
| 147 }; | 136 }; |
| 148 | 137 |
| 138 |
| 149 } // namespace chromeos | 139 } // namespace chromeos |
| 150 | 140 |
| 151 #endif // CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_ | 141 #endif // CHROME_BROWSER_CHROMEOS_CROS_NATIVE_NETWORK_PARSER_H_ |
| OLD | NEW |