OLD | NEW |
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 "ash/system/chromeos/network/network_connect.h" | 5 #include "ash/system/chromeos/network/network_connect.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/chromeos/network/network_state_notifier.h" | 8 #include "ash/system/chromeos/network/network_state_notifier.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ash/system/tray/system_tray_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 scoped_ptr<base::DictionaryValue> error_data) { | 66 scoped_ptr<base::DictionaryValue> error_data) { |
67 NET_LOG_ERROR("Connect Failed: " + error_name, service_path); | 67 NET_LOG_ERROR("Connect Failed: " + error_name, service_path); |
68 | 68 |
69 if (!ash::Shell::HasInstance()) | 69 if (!ash::Shell::HasInstance()) |
70 return; | 70 return; |
71 | 71 |
72 // If a new connect attempt canceled this connect, no need to notify the user. | 72 // If a new connect attempt canceled this connect, no need to notify the user. |
73 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled) | 73 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled) |
74 return; | 74 return; |
75 | 75 |
76 if (error_name == NetworkConnectionHandler::kErrorPassphraseRequired || | 76 if (error_name == flimflam::kErrorBadPassphrase || |
| 77 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || |
77 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || | 78 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || |
78 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { | 79 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { |
79 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( | 80 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( |
80 service_path); | 81 service_path); |
81 return; | 82 return; |
82 } | 83 } |
83 | 84 |
84 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { | 85 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { |
85 ash::Shell::GetInstance()->system_tray_delegate()->EnrollOrConfigureNetwork( | 86 ash::Shell::GetInstance()->system_tray_delegate()->EnrollOrConfigureNetwork( |
86 service_path, owning_window); | 87 service_path, owning_window); |
87 return; | 88 return; |
88 } | 89 } |
89 | 90 |
90 if (error_name == NetworkConnectionHandler::kErrorActivationRequired) { | 91 if (error_name == NetworkConnectionHandler::kErrorActivationRequired) { |
91 network_connect::ActivateCellular(service_path); | 92 network_connect::ActivateCellular(service_path); |
92 return; | 93 return; |
93 } | 94 } |
94 | 95 |
95 if (error_name == NetworkConnectionHandler::kErrorConnected || | 96 if (error_name == NetworkConnectionHandler::kErrorConnected || |
96 error_name == NetworkConnectionHandler::kErrorConnecting) { | 97 error_name == NetworkConnectionHandler::kErrorConnecting) { |
97 network_connect::ShowNetworkSettings(service_path); | 98 network_connect::ShowNetworkSettings(service_path); |
98 return; | 99 return; |
99 } | 100 } |
100 | 101 |
101 // ConnectFailed or unknown error; show a notification. | 102 // ConnectFailed or unknown error; show a notification. |
102 ShowErrorNotification(error_name, service_path); | 103 ShowErrorNotification(error_name, service_path); |
103 | 104 |
104 // Show a configure dialog for ConnectFailed errors. | 105 // Show a configure dialog for ConnectFailed errors. |
105 if (error_name != NetworkConnectionHandler::kErrorConnectFailed) | 106 if (error_name != flimflam::kErrorConnectFailed) |
106 return; | 107 return; |
107 | 108 |
108 // If Shill reports an InProgress error, don't try to configure the network. | 109 // If Shill reports an InProgress error, don't try to configure the network. |
109 std::string dbus_error_name; | 110 std::string dbus_error_name; |
110 error_data.get()->GetString( | 111 error_data.get()->GetString( |
111 chromeos::network_handler::kDbusErrorName, &dbus_error_name); | 112 chromeos::network_handler::kDbusErrorName, &dbus_error_name); |
112 if (dbus_error_name == kErrorInProgress) | 113 if (dbus_error_name == kErrorInProgress) |
113 return; | 114 return; |
114 | 115 |
115 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( | 116 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( |
(...skipping 22 matching lines...) Expand all Loading... |
138 network_connect::kNetworkConnectNotificationId, false /* not by user */); | 139 network_connect::kNetworkConnectNotificationId, false /* not by user */); |
139 | 140 |
140 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( | 141 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( |
141 service_path, | 142 service_path, |
142 base::Bind(&OnConnectSucceeded, service_path), | 143 base::Bind(&OnConnectSucceeded, service_path), |
143 base::Bind(&OnConnectFailed, service_path, owning_window), | 144 base::Bind(&OnConnectFailed, service_path, owning_window), |
144 check_error_state); | 145 check_error_state); |
145 } | 146 } |
146 | 147 |
147 void OnActivateFailed(const std::string& service_path, | 148 void OnActivateFailed(const std::string& service_path, |
148 const std::string& error_name, | 149 const std::string& error_name, |
149 scoped_ptr<base::DictionaryValue> error_data) { | 150 scoped_ptr<base::DictionaryValue> error_data) { |
150 NET_LOG_ERROR("Unable to activate network", service_path); | 151 NET_LOG_ERROR("Unable to activate network", service_path); |
151 ShowErrorNotification( | 152 ShowErrorNotification(network_connect::kErrorActivateFailed, service_path); |
152 NetworkConnectionHandler::kErrorActivateFailed, service_path); | |
153 } | 153 } |
154 | 154 |
155 void OnActivateSucceeded(const std::string& service_path) { | 155 void OnActivateSucceeded(const std::string& service_path) { |
156 NET_LOG_USER("Activation Succeeded", service_path); | 156 NET_LOG_USER("Activation Succeeded", service_path); |
157 } | 157 } |
158 | 158 |
159 void OnConfigureFailed(const std::string& error_name, | 159 void OnConfigureFailed(const std::string& error_name, |
160 scoped_ptr<base::DictionaryValue> error_data) { | 160 scoped_ptr<base::DictionaryValue> error_data) { |
161 NET_LOG_ERROR("Unable to configure network", ""); | 161 NET_LOG_ERROR("Unable to configure network", ""); |
162 ShowErrorNotification(NetworkConnectionHandler::kErrorConfigureFailed, ""); | 162 ShowErrorNotification(NetworkConnectionHandler::kErrorConfigureFailed, ""); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 } // namespace | 253 } // namespace |
254 | 254 |
255 namespace network_connect { | 255 namespace network_connect { |
256 | 256 |
257 const char kNetworkConnectNotificationId[] = | 257 const char kNetworkConnectNotificationId[] = |
258 "chrome://settings/internet/connect"; | 258 "chrome://settings/internet/connect"; |
259 const char kNetworkActivateNotificationId[] = | 259 const char kNetworkActivateNotificationId[] = |
260 "chrome://settings/internet/activate"; | 260 "chrome://settings/internet/activate"; |
261 | 261 |
| 262 const char kErrorActivateFailed[] = "activate-failed"; |
| 263 |
262 void ConnectToNetwork(const std::string& service_path, | 264 void ConnectToNetwork(const std::string& service_path, |
263 gfx::NativeWindow owning_window) { | 265 gfx::NativeWindow owning_window) { |
264 NET_LOG_USER("ConnectToNetwork", service_path); | 266 NET_LOG_USER("ConnectToNetwork", service_path); |
265 const NetworkState* network = | 267 const NetworkState* network = |
266 NetworkHandler::Get()->network_state_handler()-> | 268 NetworkHandler::Get()->network_state_handler()-> |
267 GetNetworkState(service_path); | 269 GetNetworkState(service_path); |
268 if (network && !network->error().empty()) { | 270 if (network && !network->error().empty()) { |
269 NET_LOG_USER("Configure: " + network->error(), service_path); | 271 NET_LOG_USER("Configure: " + network->error(), service_path); |
270 // If the network is in an error state, show the configuration UI directly | 272 // If the network is in an error state, show the configuration UI directly |
271 // to avoid a spurious notification. | 273 // to avoid a spurious notification. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 500 |
499 void ShowNetworkSettings(const std::string& service_path) { | 501 void ShowNetworkSettings(const std::string& service_path) { |
500 if (!ash::Shell::HasInstance()) | 502 if (!ash::Shell::HasInstance()) |
501 return; | 503 return; |
502 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings( | 504 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings( |
503 service_path); | 505 service_path); |
504 } | 506 } |
505 | 507 |
506 } // network_connect | 508 } // network_connect |
507 } // ash | 509 } // ash |
OLD | NEW |