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 UI_CHROMEOS_NETWORK_NETWORK_CONNECT_H | 5 #ifndef CHROMEOS_NETWORK_NETWORK_CONNECT_H_ |
6 #define UI_CHROMEOS_NETWORK_NETWORK_CONNECT_H | 6 #define CHROMEOS_NETWORK_NETWORK_CONNECT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "ui/chromeos/ui_chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class DictionaryValue; | 15 class DictionaryValue; |
16 } | 16 } |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
| 19 |
19 class NetworkTypePattern; | 20 class NetworkTypePattern; |
20 } | |
21 | 21 |
22 namespace ui { | 22 // NetworkConnect is a state machine designed to handle the complex UI flows |
23 | 23 // associated with connecting to a network (and related tasks). Any showing |
24 class UI_CHROMEOS_EXPORT NetworkConnect { | 24 // of UI is handled by the NetworkConnect::Delegate implementation. |
| 25 class CHROMEOS_EXPORT NetworkConnect { |
25 public: | 26 public: |
26 class Delegate { | 27 class CHROMEOS_EXPORT Delegate { |
27 public: | 28 public: |
28 // Shows UI to configure or activate the network specified by |network_id|, | 29 // Shows UI to configure or activate the network specified by |network_id|, |
29 // which may include showing Payment or Portal UI when appropriate. | 30 // which may include showing Payment or Portal UI when appropriate. |
30 virtual void ShowNetworkConfigure(const std::string& network_id) = 0; | 31 virtual void ShowNetworkConfigure(const std::string& network_id) = 0; |
31 | 32 |
32 // Shows the settings related to network. If |network_id| is not empty, | 33 // Shows the settings related to network. If |network_id| is not empty, |
33 // show the settings for that network. | 34 // show the settings for that network. |
34 virtual void ShowNetworkSettings(const std::string& network_id) = 0; | 35 virtual void ShowNetworkSettings(const std::string& network_id) = 0; |
35 | 36 |
36 // Shows UI to enroll the network specified by |network_id| if appropriate | 37 // Shows UI to enroll the network specified by |network_id| if appropriate |
37 // and returns true, otherwise returns false. | 38 // and returns true, otherwise returns false. |
38 virtual bool ShowEnrollNetwork(const std::string& network_id) = 0; | 39 virtual bool ShowEnrollNetwork(const std::string& network_id) = 0; |
39 | 40 |
40 // Shows UI to unlock a mobile sim. | 41 // Shows UI to unlock a mobile sim. |
41 virtual void ShowMobileSimDialog() = 0; | 42 virtual void ShowMobileSimDialog() = 0; |
42 | 43 |
43 // Shows UI to setup a mobile network. | 44 // Shows UI to setup a mobile network. |
44 virtual void ShowMobileSetupDialog(const std::string& network_id) = 0; | 45 virtual void ShowMobileSetupDialog(const std::string& network_id) = 0; |
45 | 46 |
| 47 // Shows an error notification. |error_name| is an error defined in |
| 48 // NetworkConnectionHandler. |network_id| may be empty. |
| 49 virtual void ShowNetworkConnectError(const std::string& error_name, |
| 50 const std::string& network_id) = 0; |
| 51 |
| 52 // Shows an error notification during mobile activation. |
| 53 virtual void ShowMobileActivationError(const std::string& network_id) = 0; |
| 54 |
46 protected: | 55 protected: |
47 virtual ~Delegate() {} | 56 virtual ~Delegate() {} |
48 }; | 57 }; |
49 | 58 |
50 // Creates the global NetworkConnect object. |delegate| is owned by the | 59 // Creates the global NetworkConnect object. |delegate| is owned by the |
51 // caller. | 60 // caller. |
52 static void Initialize(Delegate* delegate); | 61 static void Initialize(Delegate* delegate); |
53 | 62 |
54 // Destroys the global NetworkConnect object. | 63 // Destroys the global NetworkConnect object. |
55 static void Shutdown(); | 64 static void Shutdown(); |
56 | 65 |
57 // Returns the global NetworkConnect object if initialized or NULL. | 66 // Returns the global NetworkConnect object if initialized or NULL. |
58 static NetworkConnect* Get(); | 67 static NetworkConnect* Get(); |
59 | 68 |
60 static const char kErrorActivateFailed[]; | |
61 | |
62 virtual ~NetworkConnect(); | 69 virtual ~NetworkConnect(); |
63 | 70 |
64 // Requests a network connection and handles any errors and notifications. | 71 // Requests a network connection and handles any errors and notifications. |
65 virtual void ConnectToNetwork(const std::string& service_path) = 0; | 72 virtual void ConnectToNetwork(const std::string& service_path) = 0; |
66 | 73 |
67 // Maybe show the configuration UI after a connect failure based on the | 74 // Maybe show the configuration UI after a connect failure based on the |
68 // network state and error name. Returns true if the UI is shown. | 75 // network state and error name. Returns true if the UI is shown. |
69 virtual bool MaybeShowConfigureUI(const std::string& service_path, | 76 virtual bool MaybeShowConfigureUI(const std::string& service_path, |
70 const std::string& connect_error) = 0; | 77 const std::string& connect_error) = 0; |
71 | 78 |
(...skipping 23 matching lines...) Expand all Loading... |
95 // The profile used is determined by |shared|. | 102 // The profile used is determined by |shared|. |
96 virtual void CreateConfigurationAndConnect( | 103 virtual void CreateConfigurationAndConnect( |
97 base::DictionaryValue* shill_properties, | 104 base::DictionaryValue* shill_properties, |
98 bool shared) = 0; | 105 bool shared) = 0; |
99 | 106 |
100 // Requests a new network configuration to be created from a dictionary of | 107 // Requests a new network configuration to be created from a dictionary of |
101 // Shill properties. The profile used is determined by |shared|. | 108 // Shill properties. The profile used is determined by |shared|. |
102 virtual void CreateConfiguration(base::DictionaryValue* shill_properties, | 109 virtual void CreateConfiguration(base::DictionaryValue* shill_properties, |
103 bool shared) = 0; | 110 bool shared) = 0; |
104 | 111 |
105 // Returns the localized string for shill error string |error|. | |
106 virtual base::string16 GetShillErrorString( | |
107 const std::string& error, | |
108 const std::string& service_path) = 0; | |
109 | |
110 // Shows the settings for the network specified by |service_path|. If empty, | |
111 // or no matching network exists, shows the general internet settings page. | |
112 virtual void ShowNetworkSettingsForPath(const std::string& service_path) = 0; | |
113 | |
114 protected: | 112 protected: |
115 NetworkConnect(); | 113 NetworkConnect(); |
116 | 114 |
117 private: | 115 private: |
118 DISALLOW_COPY_AND_ASSIGN(NetworkConnect); | 116 DISALLOW_COPY_AND_ASSIGN(NetworkConnect); |
119 }; | 117 }; |
120 | 118 |
121 } // ui | 119 } // namespace chromeos |
122 | 120 |
123 #endif // UI_CHROMEOS_NETWORK_NETWORK_CONNECT_H | 121 #endif // CHROMEOS_NETWORK_NETWORK_CONNECT_H_ |
OLD | NEW |