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_NETWORK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "chrome/browser/chromeos/cros/network_constants.h" | 22 #include "chrome/browser/chromeos/cros/network_constants.h" |
23 #include "chromeos/network/network_ip_config.h" | 23 #include "chromeos/network/network_ip_config.h" |
24 #include "chromeos/network/network_ui_data.h" | 24 #include "chromeos/network/network_ui_data.h" |
25 #include "chromeos/network/network_util.h" | 25 #include "chromeos/network/network_util.h" |
26 #include "chromeos/network/onc/onc_constants.h" | 26 #include "chromeos/network/onc/onc_constants.h" |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 | 29 |
| 30 class CertificatePattern; |
| 31 class EnrollmentDelegate; |
30 class NetworkDeviceParser; | 32 class NetworkDeviceParser; |
31 class NetworkParser; | 33 class NetworkParser; |
32 class CertificatePattern; | |
33 | 34 |
34 // This is the list of all implementation classes that are allowed | 35 // This is the list of all implementation classes that are allowed |
35 // access to the internals of the network library classes. | 36 // access to the internals of the network library classes. |
36 #define NETWORK_LIBRARY_IMPL_FRIENDS \ | 37 #define NETWORK_LIBRARY_IMPL_FRIENDS \ |
37 friend class NetworkLibraryImplBase; \ | 38 friend class NetworkLibraryImplBase; \ |
38 friend class NetworkLibraryImplCros; \ | 39 friend class NetworkLibraryImplCros; \ |
39 friend class NetworkLibraryImplStub; | 40 friend class NetworkLibraryImplStub; |
40 | 41 |
41 | 42 |
42 // Simple wrapper for property Cellular.FoundNetworks. | 43 // Simple wrapper for property Cellular.FoundNetworks. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 bool support_network_scan_; | 290 bool support_network_scan_; |
290 CellularApnList provider_apn_list_; | 291 CellularApnList provider_apn_list_; |
291 | 292 |
292 // This is the parser we use to parse messages from the native | 293 // This is the parser we use to parse messages from the native |
293 // network layer. | 294 // network layer. |
294 scoped_ptr<NetworkDeviceParser> device_parser_; | 295 scoped_ptr<NetworkDeviceParser> device_parser_; |
295 | 296 |
296 DISALLOW_COPY_AND_ASSIGN(NetworkDevice); | 297 DISALLOW_COPY_AND_ASSIGN(NetworkDevice); |
297 }; | 298 }; |
298 | 299 |
299 // A virtual class that can be used to handle certificate enrollment URIs when | |
300 // encountered. Also used by unit tests to avoid opening browser windows | |
301 // when testing. | |
302 class EnrollmentDelegate { | |
303 public: | |
304 EnrollmentDelegate() {} | |
305 virtual ~EnrollmentDelegate() {} | |
306 | |
307 // Implemented to handle a given certificate enrollment URI. Returns false | |
308 // if the enrollment URI doesn't use a scheme that we can handle, and in | |
309 // that case, this will be called for any remaining enrollment URIs. | |
310 // If enrollment succeeds, then the enrollment handler must run | |
311 // |post_action| to finish connecting. | |
312 virtual void Enroll(const std::vector<std::string>& uri_list, | |
313 const base::Closure& post_action) = 0; | |
314 private: | |
315 DISALLOW_COPY_AND_ASSIGN(EnrollmentDelegate); | |
316 }; | |
317 | |
318 // Contains data common to all network service types. | 300 // Contains data common to all network service types. |
319 class Network { | 301 class Network { |
320 public: | 302 public: |
321 virtual ~Network(); | 303 virtual ~Network(); |
322 | 304 |
323 // Test API for accessing setters in tests. | 305 // Test API for accessing setters in tests. |
324 class TestApi { | 306 class TestApi { |
325 public: | 307 public: |
326 explicit TestApi(Network* network) : network_(network) {} | 308 explicit TestApi(Network* network) : network_(network) {} |
327 void SetConnected() { | 309 void SetConnected() { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 static bool IsDisconnectedState(ConnectionState state) { | 411 static bool IsDisconnectedState(ConnectionState state) { |
430 return (state == STATE_UNKNOWN || | 412 return (state == STATE_UNKNOWN || |
431 state == STATE_IDLE || | 413 state == STATE_IDLE || |
432 state == STATE_DISCONNECT || | 414 state == STATE_DISCONNECT || |
433 state == STATE_FAILURE || | 415 state == STATE_FAILURE || |
434 state == STATE_ACTIVATION_FAILURE); | 416 state == STATE_ACTIVATION_FAILURE); |
435 } | 417 } |
436 | 418 |
437 // Adopts the given enrollment handler to handle any certificate enrollment | 419 // Adopts the given enrollment handler to handle any certificate enrollment |
438 // URIs encountered during network connection. | 420 // URIs encountered during network connection. |
439 void SetEnrollmentDelegate(EnrollmentDelegate* delegate) { | 421 void SetEnrollmentDelegate(EnrollmentDelegate* delegate); |
440 enrollment_delegate_.reset(delegate); | |
441 } | |
442 | 422 |
443 virtual bool UpdateStatus(const std::string& key, | 423 virtual bool UpdateStatus(const std::string& key, |
444 const base::Value& value, | 424 const base::Value& value, |
445 PropertyIndex* index); | 425 PropertyIndex* index); |
446 | 426 |
447 // Creates a Network object for the given type for testing. | 427 // Creates a Network object for the given type for testing. |
448 static Network* CreateForTesting(ConnectionType type); | 428 static Network* CreateForTesting(ConnectionType type); |
449 | 429 |
450 protected: | 430 protected: |
451 Network(const std::string& service_path, | 431 Network(const std::string& service_path, |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 NetworkLibrary::Shutdown(); | 1581 NetworkLibrary::Shutdown(); |
1602 } | 1582 } |
1603 | 1583 |
1604 private: | 1584 private: |
1605 DISALLOW_COPY_AND_ASSIGN(ScopedStubNetworkLibraryEnabler); | 1585 DISALLOW_COPY_AND_ASSIGN(ScopedStubNetworkLibraryEnabler); |
1606 }; | 1586 }; |
1607 | 1587 |
1608 } // namespace chromeos | 1588 } // namespace chromeos |
1609 | 1589 |
1610 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1590 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |