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

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

Issue 23532065: Add NetworkState::RequiresActivation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chromeos/network/network_connection_handler.h" 5 #include "chromeos/network/network_connection_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "chromeos/chromeos_switches.h" 10 #include "chromeos/chromeos_switches.h"
11 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "chromeos/dbus/shill_manager_client.h" 12 #include "chromeos/dbus/shill_manager_client.h"
13 #include "chromeos/dbus/shill_service_client.h" 13 #include "chromeos/dbus/shill_service_client.h"
14 #include "chromeos/network/client_cert_util.h" 14 #include "chromeos/network/client_cert_util.h"
15 #include "chromeos/network/network_activation_handler.h"
15 #include "chromeos/network/network_configuration_handler.h" 16 #include "chromeos/network/network_configuration_handler.h"
16 #include "chromeos/network/network_event_log.h" 17 #include "chromeos/network/network_event_log.h"
17 #include "chromeos/network/network_handler_callbacks.h" 18 #include "chromeos/network/network_handler_callbacks.h"
18 #include "chromeos/network/network_state.h" 19 #include "chromeos/network/network_state.h"
19 #include "chromeos/network/network_state_handler.h" 20 #include "chromeos/network/network_state_handler.h"
20 #include "chromeos/network/network_ui_data.h" 21 #include "chromeos/network/network_ui_data.h"
21 #include "chromeos/network/shill_property_util.h" 22 #include "chromeos/network/shill_property_util.h"
22 #include "dbus/object_path.h" 23 #include "dbus/object_path.h"
23 #include "net/cert/x509_certificate.h" 24 #include "net/cert/x509_certificate.h"
24 #include "third_party/cros_system_api/dbus/service_constants.h" 25 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 15 matching lines...) Expand all
40 } 41 }
41 42
42 bool IsAuthenticationError(const std::string& error) { 43 bool IsAuthenticationError(const std::string& error) {
43 return (error == flimflam::kErrorBadWEPKey || 44 return (error == flimflam::kErrorBadWEPKey ||
44 error == flimflam::kErrorPppAuthFailed || 45 error == flimflam::kErrorPppAuthFailed ||
45 error == shill::kErrorEapLocalTlsFailed || 46 error == shill::kErrorEapLocalTlsFailed ||
46 error == shill::kErrorEapRemoteTlsFailed || 47 error == shill::kErrorEapRemoteTlsFailed ||
47 error == shill::kErrorEapAuthenticationFailed); 48 error == shill::kErrorEapAuthenticationFailed);
48 } 49 }
49 50
50 bool NetworkRequiresActivation(const NetworkState* network) {
51 return (network->type() == flimflam::kTypeCellular &&
52 ((network->activation_state() != flimflam::kActivationStateActivated &&
53 network->activation_state() != flimflam::kActivationStateUnknown)));
54 }
55
56 bool VPNIsConfigured(const std::string& service_path, 51 bool VPNIsConfigured(const std::string& service_path,
57 const std::string& provider_type, 52 const std::string& provider_type,
58 const base::DictionaryValue& provider_properties) { 53 const base::DictionaryValue& provider_properties) {
59 if (provider_type == flimflam::kProviderOpenVpn) { 54 if (provider_type == flimflam::kProviderOpenVpn) {
60 std::string hostname; 55 std::string hostname;
61 provider_properties.GetStringWithoutPathExpansion( 56 provider_properties.GetStringWithoutPathExpansion(
62 flimflam::kHostProperty, &hostname); 57 flimflam::kHostProperty, &hostname);
63 if (hostname.empty()) { 58 if (hostname.empty()) {
64 NET_LOG_EVENT("OpenVPN: No hostname", service_path); 59 NET_LOG_EVENT("OpenVPN: No hostname", service_path);
65 return false; 60 return false;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (network) { 220 if (network) {
226 // For existing networks, perform some immediate consistency checks. 221 // For existing networks, perform some immediate consistency checks.
227 if (network->IsConnectedState()) { 222 if (network->IsConnectedState()) {
228 InvokeErrorCallback(service_path, error_callback, kErrorConnected); 223 InvokeErrorCallback(service_path, error_callback, kErrorConnected);
229 return; 224 return;
230 } 225 }
231 if (network->IsConnectingState()) { 226 if (network->IsConnectingState()) {
232 InvokeErrorCallback(service_path, error_callback, kErrorConnecting); 227 InvokeErrorCallback(service_path, error_callback, kErrorConnecting);
233 return; 228 return;
234 } 229 }
235 if (NetworkRequiresActivation(network)) { 230 if (NetworkActivationHandler::NetworkRequiresActivation(network)) {
236 InvokeErrorCallback(service_path, error_callback, 231 InvokeErrorCallback(service_path, error_callback,
237 kErrorActivationRequired); 232 kErrorActivationRequired);
238 return; 233 return;
239 } 234 }
240 235
241 if (check_error_state) { 236 if (check_error_state) {
242 const std::string& error = network->error(); 237 const std::string& error = network->error();
243 if (error == flimflam::kErrorBadPassphrase) { 238 if (error == flimflam::kErrorBadPassphrase) {
244 InvokeErrorCallback(service_path, error_callback, error); 239 InvokeErrorCallback(service_path, error_callback, error);
245 return; 240 return;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 645
651 void NetworkConnectionHandler::HandleShillDisconnectSuccess( 646 void NetworkConnectionHandler::HandleShillDisconnectSuccess(
652 const std::string& service_path, 647 const std::string& service_path,
653 const base::Closure& success_callback) { 648 const base::Closure& success_callback) {
654 NET_LOG_EVENT("Disconnect Request Sent", service_path); 649 NET_LOG_EVENT("Disconnect Request Sent", service_path);
655 if (!success_callback.is_null()) 650 if (!success_callback.is_null())
656 success_callback.Run(); 651 success_callback.Run();
657 } 652 }
658 653
659 } // namespace chromeos 654 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698