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