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

Side by Side Diff: ash/system/chromeos/network/network_connect.cc

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

Powered by Google App Engine
This is Rietveld 408576698