Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: chromeos/network/network_connection_handler.h

Issue 16512003: Configure networks requiring a certificate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update error strings Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ 5 #ifndef CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_
6 #define CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ 6 #define CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
16 #include "chromeos/dbus/dbus_method_call_status.h" 16 #include "chromeos/dbus/dbus_method_call_status.h"
17 #include "chromeos/login/login_state.h"
18 #include "chromeos/network/cert_loader.h"
17 #include "chromeos/network/network_handler.h" 19 #include "chromeos/network/network_handler.h"
18 #include "chromeos/network/network_handler_callbacks.h" 20 #include "chromeos/network/network_handler_callbacks.h"
19 #include "chromeos/network/network_state_handler_observer.h" 21 #include "chromeos/network/network_state_handler_observer.h"
20 22
21 namespace chromeos { 23 namespace chromeos {
22 24
23 class NetworkState; 25 class NetworkState;
26 class NetworkUIData;
24 27
25 // The NetworkConnectionHandler class is used to manage network connection 28 // The NetworkConnectionHandler class is used to manage network connection
26 // requests. This is the only class that should make Shill Connect calls. 29 // requests. This is the only class that should make Shill Connect calls.
27 // It handles the following steps: 30 // It handles the following steps:
28 // 1. Determine whether or not sufficient information (e.g. passphrase) is 31 // 1. Determine whether or not sufficient information (e.g. passphrase) is
29 // known to be available to connect to the network. 32 // known to be available to connect to the network.
30 // 2. Request additional information (e.g. user data which contains certificate 33 // 2. Request additional information (e.g. user data which contains certificate
31 // information) and determine whether sufficient information is available. 34 // information) and determine whether sufficient information is available.
32 // 3. Send the connect request. 35 // 3. Possibly configure the network certificate info (tpm slot and pkcs11 id).
33 // 4. Wait for the network state to change to a non connecting state. 36 // 4. Send the connect request.
34 // 5. Invoke the appropriate callback (always) on success or failure. 37 // 5. Wait for the network state to change to a non connecting state.
38 // 6. Invoke the appropriate callback (always) on success or failure.
35 // 39 //
36 // NetworkConnectionHandler depends on NetworkStateHandler for immediately 40 // NetworkConnectionHandler depends on NetworkStateHandler for immediately
37 // available State information, and NetworkConfigurationHandler for any 41 // available State information, and NetworkConfigurationHandler for any
38 // configuration calls. 42 // configuration calls.
39 43
40 class CHROMEOS_EXPORT NetworkConnectionHandler 44 class CHROMEOS_EXPORT NetworkConnectionHandler
41 : public NetworkStateHandlerObserver, 45 : public LoginState::Observer,
46 public CertLoader::Observer,
47 public NetworkStateHandlerObserver,
42 public base::SupportsWeakPtr<NetworkConnectionHandler> { 48 public base::SupportsWeakPtr<NetworkConnectionHandler> {
43 public: 49 public:
44 // Constants for |error_name| from |error_callback| for Connect. 50 // Constants for |error_name| from |error_callback| for Connect.
45 static const char kErrorNotFound[]; 51 static const char kErrorNotFound[];
46 static const char kErrorConnected[]; 52 static const char kErrorConnected[];
47 static const char kErrorConnecting[]; 53 static const char kErrorConnecting[];
48 static const char kErrorPassphraseRequired[]; 54 static const char kErrorPassphraseRequired[];
49 static const char kErrorActivationRequired[]; 55 static const char kErrorActivationRequired[];
50 static const char kErrorCertificateRequired[]; 56 static const char kErrorCertificateRequired[];
51 static const char kErrorConfigurationRequired[]; 57 static const char kErrorConfigurationRequired[];
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const network_handler::ErrorCallback& error_callback); 95 const network_handler::ErrorCallback& error_callback);
90 96
91 // Returns true if ConnectToNetwork has been called with |service_path| and 97 // Returns true if ConnectToNetwork has been called with |service_path| and
92 // has not completed (i.e. success or error callback has been called). 98 // has not completed (i.e. success or error callback has been called).
93 bool HasConnectingNetwork(const std::string& service_path); 99 bool HasConnectingNetwork(const std::string& service_path);
94 100
95 // NetworkStateHandlerObserver 101 // NetworkStateHandlerObserver
96 virtual void NetworkListChanged() OVERRIDE; 102 virtual void NetworkListChanged() OVERRIDE;
97 virtual void NetworkPropertiesUpdated(const NetworkState* network) OVERRIDE; 103 virtual void NetworkPropertiesUpdated(const NetworkState* network) OVERRIDE;
98 104
105 // LoginState::Observer
106 virtual void LoggedInStateChanged(LoginState::LoggedInState state) OVERRIDE;
107
108 // CertLoader::Observer
109 virtual void OnCertificatesLoaded(const net::CertificateList& cert_list,
110 bool initial_load) OVERRIDE;
111
99 private: 112 private:
100 friend class NetworkHandler; 113 friend class NetworkHandler;
101 friend class NetworkConnectionHandlerTest; 114 friend class NetworkConnectionHandlerTest;
102 115
103 struct ConnectRequest; 116 struct ConnectRequest;
104 117
105 NetworkConnectionHandler(); 118 NetworkConnectionHandler();
106 119
107 void Init(NetworkStateHandler* network_state_handler, 120 void Init(CertLoader* cert_loader,
121 NetworkStateHandler* network_state_handler,
108 NetworkConfigurationHandler* network_configuration_handler); 122 NetworkConfigurationHandler* network_configuration_handler);
109 123
110 ConnectRequest* pending_request(const std::string& service_path); 124 ConnectRequest* pending_request(const std::string& service_path);
111 125
112 // Callback from Shill.Service.GetProperties. Parses |properties| to verify 126 // Callback from Shill.Service.GetProperties. Parses |properties| to verify
113 // whether or not the network appears to be configured. If configured, 127 // whether or not the network appears to be configured. If configured,
114 // attempts a connection, otherwise invokes error_callback from 128 // attempts a connection, otherwise invokes error_callback from
115 // pending_requests_[service_path]. 129 // pending_requests_[service_path].
116 void VerifyConfiguredAndConnect(const std::string& service_path, 130 void VerifyConfiguredAndConnect(const std::string& service_path,
117 const base::DictionaryValue& properties); 131 const base::DictionaryValue& properties);
118 132
119 // Calls Shill.Manager.Connect asynchronously. 133 // Calls Shill.Manager.Connect asynchronously.
120 void CallShillConnect(const std::string& service_path); 134 void CallShillConnect(const std::string& service_path);
121 135
122 // Handle failure from ConfigurationHandler calls. 136 // Handle failure from ConfigurationHandler calls.
123 void HandleConfigurationFailure( 137 void HandleConfigurationFailure(
124 const std::string& service_path, 138 const std::string& service_path,
125 const std::string& error_name, 139 const std::string& error_name,
126 scoped_ptr<base::DictionaryValue> error_data); 140 scoped_ptr<base::DictionaryValue> error_data);
127 141
128 // Handle success or failure from Shill.Service.Connect. 142 // Handle success or failure from Shill.Service.Connect.
129 void HandleShillConnectSuccess(const std::string& service_path); 143 void HandleShillConnectSuccess(const std::string& service_path);
130 void HandleShillConnectFailure(const std::string& service_path, 144 void HandleShillConnectFailure(const std::string& service_path,
131 const std::string& error_name, 145 const std::string& error_name,
132 const std::string& error_message); 146 const std::string& error_message);
133 147
134 void CheckPendingRequest(const std::string service_path); 148 void CheckPendingRequest(const std::string service_path);
135 void CheckAllPendingRequests(); 149 void CheckAllPendingRequests();
150 bool CertificateIsConfigured(NetworkUIData* ui_data, std::string* pkcs11_id);
151 void ErrorCallbackForPendingRequest(const std::string& service_path,
152 const std::string& error_name);
136 153
137 // Calls Shill.Manager.Disconnect asynchronously. 154 // Calls Shill.Manager.Disconnect asynchronously.
138 void CallShillDisconnect( 155 void CallShillDisconnect(
139 const std::string& service_path, 156 const std::string& service_path,
140 const base::Closure& success_callback, 157 const base::Closure& success_callback,
141 const network_handler::ErrorCallback& error_callback); 158 const network_handler::ErrorCallback& error_callback);
142 159
143 // Handle success or failure from Shill.Service.Disconnect. 160 // Handle success or failure from Shill.Service.Disconnect.
144 void HandleShillDisconnectSuccess(const std::string& service_path, 161 void HandleShillDisconnectSuccess(const std::string& service_path,
145 const base::Closure& success_callback); 162 const base::Closure& success_callback);
146 void HandleShillDisconnectFailure( 163 void HandleShillDisconnectFailure(
147 const std::string& service_path, 164 const std::string& service_path,
148 const network_handler::ErrorCallback& error_callback, 165 const network_handler::ErrorCallback& error_callback,
149 const std::string& error_name, 166 const std::string& error_name,
150 const std::string& error_message); 167 const std::string& error_message);
151 168
152 // Local references to the associated handler instances. 169 // Local references to the associated handler instances.
170 CertLoader* cert_loader_;
153 NetworkStateHandler* network_state_handler_; 171 NetworkStateHandler* network_state_handler_;
154 NetworkProfileHandler* network_profile_handler_; 172 NetworkProfileHandler* network_profile_handler_;
155 NetworkConfigurationHandler* network_configuration_handler_; 173 NetworkConfigurationHandler* network_configuration_handler_;
156 174
157 // Map of pending connect requests, used to prevent repeat attempts while 175 // Map of pending connect requests, used to prevent repeated attempts while
158 // waiting for Shill and to trigger callbacks on eventual success or failure. 176 // waiting for Shill and to trigger callbacks on eventual success or failure.
159 std::map<std::string, ConnectRequest> pending_requests_; 177 std::map<std::string, ConnectRequest> pending_requests_;
178 scoped_ptr<ConnectRequest> queued_connect_;
179
180 // Track certificate loading state.
181 bool logged_in_;
182 bool certificates_loaded_;
160 183
161 DISALLOW_COPY_AND_ASSIGN(NetworkConnectionHandler); 184 DISALLOW_COPY_AND_ASSIGN(NetworkConnectionHandler);
162 }; 185 };
163 186
164 } // namespace chromeos 187 } // namespace chromeos
165 188
166 #endif // CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_ 189 #endif // CHROMEOS_NETWORK_NETWORK_CONNECTION_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/ash_system_tray_delegate.cc ('k') | chromeos/network/network_connection_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698