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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" // for OVERRIDE | 11 #include "base/compiler_specific.h" // for OVERRIDE |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chromeos/cros/network_parser.h" | 15 #include "chrome/browser/chromeos/cros/network_parser.h" |
16 #include "chrome/browser/chromeos/cros/network_ui_data.h" | 16 #include "chrome/browser/chromeos/cros/network_ui_data.h" |
| 17 #include "chromeos/network/onc/onc_constants.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class DictionaryValue; | 20 class DictionaryValue; |
20 class ListValue; | 21 class ListValue; |
21 class Value; | 22 class Value; |
22 } | 23 } |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class ProxyServer; | 26 class ProxyServer; |
26 } | 27 } |
(...skipping 20 matching lines...) Expand all Loading... |
47 // For ONC file format, see: http://dev.chromium.org/chromium-os/ | 48 // For ONC file format, see: http://dev.chromium.org/chromium-os/ |
48 // chromiumos-design-docs/open-network-configuration | 49 // chromiumos-design-docs/open-network-configuration |
49 class OncNetworkParser : public NetworkParser { | 50 class OncNetworkParser : public NetworkParser { |
50 public: | 51 public: |
51 typedef bool (*ParserPointer)(OncNetworkParser*, | 52 typedef bool (*ParserPointer)(OncNetworkParser*, |
52 PropertyIndex, | 53 PropertyIndex, |
53 const base::Value&, | 54 const base::Value&, |
54 Network*); | 55 Network*); |
55 | 56 |
56 OncNetworkParser(const base::ListValue& network_configs, | 57 OncNetworkParser(const base::ListValue& network_configs, |
57 NetworkUIData::ONCSource onc_source); | 58 onc::ONCSource onc_source); |
58 virtual ~OncNetworkParser(); | 59 virtual ~OncNetworkParser(); |
59 static const EnumMapper<PropertyIndex>* property_mapper(); | 60 static const EnumMapper<PropertyIndex>* property_mapper(); |
60 | 61 |
61 // Returns the number of networks in the "NetworkConfigs" list. | 62 // Returns the number of networks in the "NetworkConfigs" list. |
62 int GetNetworkConfigsSize() const; | 63 int GetNetworkConfigsSize() const; |
63 | 64 |
64 // Returns the network configuration dictionary for the nth network. CHECKs if | 65 // Returns the network configuration dictionary for the nth network. CHECKs if |
65 // |n| is out of range and returns NULL on parse errors. | 66 // |n| is out of range and returns NULL on parse errors. |
66 const base::DictionaryValue* GetNetworkConfig(int n); | 67 const base::DictionaryValue* GetNetworkConfig(int n); |
67 | 68 |
(...skipping 10 matching lines...) Expand all Loading... |
78 // If Value is not the proper type or there is an error in parsing | 79 // If Value is not the proper type or there is an error in parsing |
79 // any individual field, VLOGs diagnostics, and returns false. | 80 // any individual field, VLOGs diagnostics, and returns false. |
80 bool ParseNestedObject(Network* network, | 81 bool ParseNestedObject(Network* network, |
81 const std::string& onc_type, | 82 const std::string& onc_type, |
82 const base::Value& value, | 83 const base::Value& value, |
83 OncValueSignature* signature, | 84 OncValueSignature* signature, |
84 ParserPointer parser); | 85 ParserPointer parser); |
85 | 86 |
86 // Expands |value| with user account specific paramaters. | 87 // Expands |value| with user account specific paramaters. |
87 static std::string GetUserExpandedValue(const base::Value& value, | 88 static std::string GetUserExpandedValue(const base::Value& value, |
88 NetworkUIData::ONCSource source); | 89 onc::ONCSource source); |
89 | 90 |
90 const std::string& parse_error() const { return parse_error_; } | 91 const std::string& parse_error() const { return parse_error_; } |
91 | 92 |
92 NetworkUIData::ONCSource onc_source() const { return onc_source_; } | 93 onc::ONCSource onc_source() const { return onc_source_; } |
93 | 94 |
94 protected: | 95 protected: |
95 OncNetworkParser(); | 96 OncNetworkParser(); |
96 | 97 |
97 virtual Network* CreateNewNetwork(ConnectionType type, | 98 virtual Network* CreateNewNetwork(ConnectionType type, |
98 const std::string& service_path) OVERRIDE; | 99 const std::string& service_path) OVERRIDE; |
99 virtual ConnectionType ParseType(const std::string& type) OVERRIDE; | 100 virtual ConnectionType ParseType(const std::string& type) OVERRIDE; |
100 virtual ConnectionType ParseTypeFromDictionary( | 101 virtual ConnectionType ParseTypeFromDictionary( |
101 const base::DictionaryValue& info) OVERRIDE; | 102 const base::DictionaryValue& info) OVERRIDE; |
102 | 103 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 static bool ParseIssuerSubjectPattern(IssuerSubjectPattern* pattern, | 175 static bool ParseIssuerSubjectPattern(IssuerSubjectPattern* pattern, |
175 OncNetworkParser* parser, | 176 OncNetworkParser* parser, |
176 PropertyIndex index, | 177 PropertyIndex index, |
177 const base::Value& value, | 178 const base::Value& value, |
178 Network* network); | 179 Network* network); |
179 | 180 |
180 // Error message from the JSON parser, if applicable. | 181 // Error message from the JSON parser, if applicable. |
181 std::string parse_error_; | 182 std::string parse_error_; |
182 | 183 |
183 // Where the ONC blob comes from. | 184 // Where the ONC blob comes from. |
184 NetworkUIData::ONCSource onc_source_; | 185 onc::ONCSource onc_source_; |
185 | 186 |
186 scoped_ptr<base::ListValue> network_configs_; | 187 scoped_ptr<base::ListValue> network_configs_; |
187 | 188 |
188 DISALLOW_COPY_AND_ASSIGN(OncNetworkParser); | 189 DISALLOW_COPY_AND_ASSIGN(OncNetworkParser); |
189 }; | 190 }; |
190 | 191 |
191 // Class for parsing Ethernet networks. | 192 // Class for parsing Ethernet networks. |
192 class OncEthernetNetworkParser : public OncNetworkParser { | 193 class OncEthernetNetworkParser : public OncNetworkParser { |
193 public: | 194 public: |
194 OncEthernetNetworkParser(); | 195 OncEthernetNetworkParser(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 const base::Value& value, | 277 const base::Value& value, |
277 Network* network); | 278 Network* network); |
278 | 279 |
279 private: | 280 private: |
280 DISALLOW_COPY_AND_ASSIGN(OncVirtualNetworkParser); | 281 DISALLOW_COPY_AND_ASSIGN(OncVirtualNetworkParser); |
281 }; | 282 }; |
282 | 283 |
283 } // namespace chromeos | 284 } // namespace chromeos |
284 | 285 |
285 #endif // CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ | 286 #endif // CHROME_BROWSER_CHROMEOS_CROS_ONC_NETWORK_PARSER_H_ |
OLD | NEW |