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 ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H | 5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H |
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H | 6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class DictionaryValue; | 14 class DictionaryValue; |
15 } | 15 } |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 class NetworkTypePattern; | 18 class NetworkTypePattern; |
19 } | 19 } |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 namespace network_connect { | |
23 | 22 |
24 ASH_EXPORT extern const char kNetworkConnectNotificationId[]; | 23 class ASH_EXPORT NetworkConnect { |
25 ASH_EXPORT extern const char kNetworkActivateNotificationId[]; | 24 public: |
| 25 class Delegate { |
| 26 public: |
| 27 // Shows UI to configure or activate the network specified by |network_id|, |
| 28 // which may include showing Payment or Portal UI when appropriate. |
| 29 virtual void ShowNetworkConfigure(const std::string& network_id) = 0; |
26 | 30 |
27 ASH_EXPORT extern const char kErrorActivateFailed[]; | 31 // Shows the settings related to network. If |network_id| is not empty, |
| 32 // show the settings for that network. |
| 33 virtual void ShowNetworkSettings(const std::string& network_id) = 0; |
28 | 34 |
29 // Requests a network connection and handles any errors and notifications. | 35 // Shows UI to enroll the network specified by |network_id| if appropriate |
30 ASH_EXPORT void ConnectToNetwork(const std::string& service_path); | 36 // and returns true, otherwise returns false. |
| 37 virtual bool ShowEnrollNetwork(const std::string& network_id) = 0; |
31 | 38 |
32 // Enables or disables a network technology. If |technology| refers to cellular | 39 // Shows UI to unlock a mobile sim. |
33 // and the device cannot be enabled due to a SIM lock, this function will | 40 virtual void ShowMobileSimDialog() = 0; |
34 // launch the SIM unlock dialog. | |
35 ASH_EXPORT void SetTechnologyEnabled( | |
36 const chromeos::NetworkTypePattern& technology, | |
37 bool enabled_state); | |
38 | 41 |
39 // Requests network activation and handles any errors and notifications. | 42 // Shows UI to setup a mobile network. |
40 ASH_EXPORT void ActivateCellular(const std::string& service_path); | 43 virtual void ShowMobileSetupDialog(const std::string& service_path) = 0; |
41 | 44 |
42 // Determines whether or not a network requires a connection to activate or | 45 protected: |
43 // setup and either shows a notification or opens the mobile setup dialog. | 46 virtual ~Delegate() {} |
44 ASH_EXPORT void ShowMobileSetup(const std::string& service_path); | 47 }; |
45 | 48 |
46 // Configures a network with a dictionary of Shill properties, then sends a | 49 // Creates the global NetworkConnect object. |delegate| is owned by the |
47 // connect request. The profile is set according to 'shared' if allowed. | 50 // caller. |
48 ASH_EXPORT void ConfigureNetworkAndConnect( | 51 static void Initialize(Delegate* delegate); |
49 const std::string& service_path, | |
50 const base::DictionaryValue& properties, | |
51 bool shared); | |
52 | 52 |
53 // Requests a new network configuration to be created from a dictionary of | 53 // Destroys the global NetworkConnect object. |
54 // Shill properties and sends a connect request if the configuration succeeds. | 54 static void Shutdown(); |
55 // The profile used is determined by |shared|. | |
56 ASH_EXPORT void CreateConfigurationAndConnect(base::DictionaryValue* properties, | |
57 bool shared); | |
58 | 55 |
59 // Requests a new network configuration to be created from a dictionary of | 56 // Returns the global NetworkConnect object if initialized or NULL. |
60 // Shill properties. The profile used is determined by |shared|. | 57 static NetworkConnect* Get(); |
61 ASH_EXPORT void CreateConfiguration(base::DictionaryValue* properties, | |
62 bool shared); | |
63 | 58 |
64 // Returns the localized string for shill error string |error|. | 59 static const char kErrorActivateFailed[]; |
65 ASH_EXPORT base::string16 ErrorString(const std::string& error, | |
66 const std::string& service_path); | |
67 | 60 |
68 // Shows the settings for the network specified by |service_path|. If empty, | 61 virtual ~NetworkConnect(); |
69 // or no matching network exists, shows the general internet settings page. | |
70 ASH_EXPORT void ShowNetworkSettings(const std::string& service_path); | |
71 | 62 |
72 } // network_connect | 63 // Requests a network connection and handles any errors and notifications. |
| 64 virtual void ConnectToNetwork(const std::string& service_path) = 0; |
| 65 |
| 66 // Enables or disables a network technology. If |technology| refers to |
| 67 // cellular and the device cannot be enabled due to a SIM lock, this function |
| 68 // will launch the SIM unlock dialog. |
| 69 virtual void SetTechnologyEnabled( |
| 70 const chromeos::NetworkTypePattern& technology, |
| 71 bool enabled_state) = 0; |
| 72 |
| 73 // Requests network activation and handles any errors and notifications. |
| 74 virtual void ActivateCellular(const std::string& service_path) = 0; |
| 75 |
| 76 // Determines whether or not a network requires a connection to activate or |
| 77 // setup and either shows a notification or opens the mobile setup dialog. |
| 78 virtual void ShowMobileSetup(const std::string& service_path) = 0; |
| 79 |
| 80 // Configures a network with a dictionary of Shill properties, then sends a |
| 81 // connect request. The profile is set according to 'shared' if allowed. |
| 82 virtual void ConfigureNetworkAndConnect( |
| 83 const std::string& service_path, |
| 84 const base::DictionaryValue& properties, |
| 85 bool shared) = 0; |
| 86 |
| 87 // Requests a new network configuration to be created from a dictionary of |
| 88 // Shill properties and sends a connect request if the configuration succeeds. |
| 89 // The profile used is determined by |shared|. |
| 90 virtual void CreateConfigurationAndConnect(base::DictionaryValue* properties, |
| 91 bool shared) = 0; |
| 92 |
| 93 // Requests a new network configuration to be created from a dictionary of |
| 94 // Shill properties. The profile used is determined by |shared|. |
| 95 virtual void CreateConfiguration(base::DictionaryValue* properties, |
| 96 bool shared) = 0; |
| 97 |
| 98 // Returns the localized string for shill error string |error|. |
| 99 virtual base::string16 GetErrorString(const std::string& error, |
| 100 const std::string& service_path) = 0; |
| 101 |
| 102 // Shows the settings for the network specified by |service_path|. If empty, |
| 103 // or no matching network exists, shows the general internet settings page. |
| 104 virtual void ShowNetworkSettings(const std::string& service_path) = 0; |
| 105 |
| 106 protected: |
| 107 NetworkConnect(); |
| 108 |
| 109 private: |
| 110 DISALLOW_COPY_AND_ASSIGN(NetworkConnect); |
| 111 }; |
| 112 |
73 } // ash | 113 } // ash |
74 | 114 |
75 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H | 115 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H |
OLD | NEW |