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 #include "ash/system/chromeos/network/network_state_notifier.h" | 5 #include "ash/system/chromeos/network/network_state_notifier.h" |
6 | 6 |
7 #include "ash/shell.h" | |
8 #include "ash/system/chromeos/network/network_connect.h" | 7 #include "ash/system/chromeos/network/network_connect.h" |
9 #include "ash/system/system_notifier.h" | 8 #include "ash/system/system_notifier.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chromeos/network/network_configuration_handler.h" | 14 #include "chromeos/network/network_configuration_handler.h" |
15 #include "chromeos/network/network_connection_handler.h" | 15 #include "chromeos/network/network_connection_handler.h" |
16 #include "chromeos/network/network_event_log.h" | 16 #include "chromeos/network/network_event_log.h" |
17 #include "chromeos/network/network_state.h" | 17 #include "chromeos/network/network_state.h" |
18 #include "chromeos/network/network_state_handler.h" | 18 #include "chromeos/network/network_state_handler.h" |
19 #include "chromeos/network/shill_property_util.h" | 19 #include "chromeos/network/shill_property_util.h" |
20 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
21 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
22 #include "grit/ui_chromeos_resources.h" | 22 #include "grit/ui_chromeos_resources.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/message_center/message_center.h" | 26 #include "ui/message_center/message_center.h" |
27 #include "ui/message_center/notification.h" | 27 #include "ui/message_center/notification.h" |
28 | 28 |
29 using chromeos::NetworkConnectionHandler; | 29 using chromeos::NetworkConnectionHandler; |
30 using chromeos::NetworkHandler; | 30 using chromeos::NetworkHandler; |
31 using chromeos::NetworkState; | 31 using chromeos::NetworkState; |
32 using chromeos::NetworkStateHandler; | 32 using chromeos::NetworkStateHandler; |
33 using chromeos::NetworkTypePattern; | 33 using chromeos::NetworkTypePattern; |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 const char kNetworkOutOfCreditsNotificationId[] = | |
38 "chrome://settings/internet/out-of-credits"; | |
39 | |
40 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60; | 37 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60; |
41 | 38 |
42 // Ignore in-progress error. | 39 // Ignore in-progress error. |
43 bool ShillErrorIsIgnored(const std::string& shill_error) { | 40 bool ShillErrorIsIgnored(const std::string& shill_error) { |
44 if (shill_error == shill::kErrorResultInProgress) | 41 if (shill_error == shill::kErrorResultInProgress) |
45 return true; | 42 return true; |
46 return false; | 43 return false; |
47 } | 44 } |
48 | 45 |
49 // Error messages based on |error_name|, not network_state->error(). | 46 // Error messages based on |error_name|, not network_state->error(). |
50 base::string16 GetConnectErrorString(const std::string& error_name) { | 47 base::string16 GetConnectErrorString(const std::string& error_name) { |
51 if (error_name == NetworkConnectionHandler::kErrorNotFound) | 48 if (error_name == NetworkConnectionHandler::kErrorNotFound) |
52 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED); | 49 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED); |
53 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) { | 50 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) { |
54 return l10n_util::GetStringUTF16( | 51 return l10n_util::GetStringUTF16( |
55 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED); | 52 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED); |
56 } | 53 } |
57 if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) { | 54 if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) { |
58 return l10n_util::GetStringUTF16( | 55 return l10n_util::GetStringUTF16( |
59 IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED); | 56 IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED); |
60 } | 57 } |
61 if (error_name == ash::network_connect::kErrorActivateFailed) { | 58 if (error_name == ash::NetworkConnect::kErrorActivateFailed) { |
62 return l10n_util::GetStringUTF16( | 59 return l10n_util::GetStringUTF16( |
63 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED); | 60 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED); |
64 } | 61 } |
65 return base::string16(); | 62 return base::string16(); |
66 } | 63 } |
67 | 64 |
68 void ShowErrorNotification(const std::string& notification_id, | 65 void ShowErrorNotification(const std::string& notification_id, |
69 const std::string& network_type, | 66 const std::string& network_type, |
70 const base::string16& title, | 67 const base::string16& title, |
71 const base::string16& message, | 68 const base::string16& message, |
72 const base::Closure& callback) { | 69 const base::Closure& callback) { |
73 int icon_id = (network_type == shill::kTypeCellular) ? | 70 int icon_id = (network_type == shill::kTypeCellular) |
74 IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED : | 71 ? IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED |
75 IDR_AURA_UBER_TRAY_NETWORK_FAILED; | 72 : IDR_AURA_UBER_TRAY_NETWORK_FAILED; |
76 const gfx::Image& icon = | 73 const gfx::Image& icon = |
77 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); | 74 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); |
78 message_center::MessageCenter::Get()->AddNotification( | 75 message_center::MessageCenter::Get()->AddNotification( |
79 message_center::Notification::CreateSystemNotification( | 76 message_center::Notification::CreateSystemNotification( |
80 notification_id, | 77 notification_id, title, message, icon, |
81 title, | 78 ash::system_notifier::kNotifierNetworkError, callback)); |
82 message, | |
83 icon, | |
84 ash::system_notifier::kNotifierNetworkError, | |
85 callback)); | |
86 } | 79 } |
87 | 80 |
88 } // namespace | 81 } // namespace |
89 | 82 |
90 namespace ash { | 83 namespace ash { |
91 | 84 |
92 NetworkStateNotifier::NetworkStateNotifier() | 85 const char NetworkStateNotifier::kNetworkConnectNotificationId[] = |
93 : did_show_out_of_credits_(false), | 86 "chrome://settings/internet/connect"; |
87 const char NetworkStateNotifier::kNetworkActivateNotificationId[] = | |
88 "chrome://settings/internet/activate"; | |
89 const char NetworkStateNotifier::kNetworkOutOfCreditsNotificationId[] = | |
90 "chrome://settings/internet/out-of-credits"; | |
91 | |
92 NetworkStateNotifier::NetworkStateNotifier(NetworkConnect* network_connect) | |
93 : network_connect_(network_connect), | |
94 did_show_out_of_credits_(false), | |
94 weak_ptr_factory_(this) { | 95 weak_ptr_factory_(this) { |
95 if (!NetworkHandler::IsInitialized()) | 96 if (!NetworkHandler::IsInitialized()) |
96 return; | 97 return; |
97 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 98 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
98 handler->AddObserver(this, FROM_HERE); | 99 handler->AddObserver(this, FROM_HERE); |
99 UpdateDefaultNetwork(handler->DefaultNetwork()); | 100 UpdateDefaultNetwork(handler->DefaultNetwork()); |
100 } | 101 } |
101 | 102 |
102 NetworkStateNotifier::~NetworkStateNotifier() { | 103 NetworkStateNotifier::~NetworkStateNotifier() { |
103 if (!NetworkHandler::IsInitialized()) | 104 if (!NetworkHandler::IsInitialized()) |
104 return; | 105 return; |
105 NetworkHandler::Get()->network_state_handler()->RemoveObserver( | 106 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, |
106 this, FROM_HERE); | 107 FROM_HERE); |
107 } | 108 } |
108 | 109 |
109 void NetworkStateNotifier::DefaultNetworkChanged(const NetworkState* network) { | 110 void NetworkStateNotifier::DefaultNetworkChanged(const NetworkState* network) { |
110 if (!UpdateDefaultNetwork(network)) | 111 if (!UpdateDefaultNetwork(network)) |
111 return; | 112 return; |
112 // If the default network changes to another network, allow the out of | 113 // If the default network changes to another network, allow the out of |
113 // credits notification to be shown again. A delay prevents the notification | 114 // credits notification to be shown again. A delay prevents the notification |
114 // from being shown too frequently (see below). | 115 // from being shown too frequently (see below). |
115 if (network) | 116 if (network) |
116 did_show_out_of_credits_ = false; | 117 did_show_out_of_credits_ = false; |
(...skipping 25 matching lines...) Expand all Loading... | |
142 if (!cellular->cellular_out_of_credits() || did_show_out_of_credits_) | 143 if (!cellular->cellular_out_of_credits() || did_show_out_of_credits_) |
143 return; | 144 return; |
144 | 145 |
145 // Only display a notification if not connected, connecting, or waiting to | 146 // Only display a notification if not connected, connecting, or waiting to |
146 // connect to another network. | 147 // connect to another network. |
147 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 148 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
148 const NetworkState* default_network = handler->DefaultNetwork(); | 149 const NetworkState* default_network = handler->DefaultNetwork(); |
149 if (default_network && default_network != cellular) | 150 if (default_network && default_network != cellular) |
150 return; | 151 return; |
151 if (handler->ConnectingNetworkByType(NetworkTypePattern::NonVirtual()) || | 152 if (handler->ConnectingNetworkByType(NetworkTypePattern::NonVirtual()) || |
152 NetworkHandler::Get()->network_connection_handler() | 153 NetworkHandler::Get() |
154 ->network_connection_handler() | |
153 ->HasPendingConnectRequest()) | 155 ->HasPendingConnectRequest()) |
154 return; | 156 return; |
155 | 157 |
156 did_show_out_of_credits_ = true; | 158 did_show_out_of_credits_ = true; |
157 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; | 159 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; |
158 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { | 160 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { |
159 out_of_credits_notify_time_ = base::Time::Now(); | 161 out_of_credits_notify_time_ = base::Time::Now(); |
160 base::string16 error_msg = l10n_util::GetStringFUTF16( | 162 base::string16 error_msg = l10n_util::GetStringFUTF16( |
161 IDS_NETWORK_OUT_OF_CREDITS_BODY, | 163 IDS_NETWORK_OUT_OF_CREDITS_BODY, base::UTF8ToUTF16(cellular->name())); |
162 base::UTF8ToUTF16(cellular->name())); | |
163 ShowErrorNotification( | 164 ShowErrorNotification( |
164 kNetworkOutOfCreditsNotificationId, | 165 kNetworkOutOfCreditsNotificationId, cellular->type(), |
165 cellular->type(), | 166 l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE), error_msg, |
166 l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE), | 167 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, |
167 error_msg, | 168 weak_ptr_factory_.GetWeakPtr(), cellular->path())); |
168 base::Bind(&network_connect::ShowNetworkSettings, cellular->path())); | |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 void NetworkStateNotifier::UpdateCellularActivating( | 172 void NetworkStateNotifier::UpdateCellularActivating( |
173 const NetworkState* cellular) { | 173 const NetworkState* cellular) { |
174 // Keep track of any activating cellular network. | 174 // Keep track of any activating cellular network. |
175 std::string activation_state = cellular->activation_state(); | 175 std::string activation_state = cellular->activation_state(); |
176 if (activation_state == shill::kActivationStateActivating) { | 176 if (activation_state == shill::kActivationStateActivating) { |
177 cellular_activating_.insert(cellular->path()); | 177 cellular_activating_.insert(cellular->path()); |
178 return; | 178 return; |
179 } | 179 } |
180 // Only display a notification if this network was activating and is now | 180 // Only display a notification if this network was activating and is now |
181 // activated. | 181 // activated. |
182 if (!cellular_activating_.count(cellular->path()) || | 182 if (!cellular_activating_.count(cellular->path()) || |
183 activation_state != shill::kActivationStateActivated) | 183 activation_state != shill::kActivationStateActivated) |
184 return; | 184 return; |
185 | 185 |
186 cellular_activating_.erase(cellular->path()); | 186 cellular_activating_.erase(cellular->path()); |
187 int icon_id; | 187 int icon_id; |
188 if (cellular->network_technology() == shill::kNetworkTechnologyLte) | 188 if (cellular->network_technology() == shill::kNetworkTechnologyLte) |
189 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; | 189 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; |
190 else | 190 else |
191 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; | 191 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; |
192 const gfx::Image& icon = | 192 const gfx::Image& icon = |
193 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); | 193 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); |
194 message_center::MessageCenter::Get()->AddNotification( | 194 message_center::MessageCenter::Get()->AddNotification( |
195 message_center::Notification::CreateSystemNotification( | 195 message_center::Notification::CreateSystemNotification( |
196 ash::network_connect::kNetworkActivateNotificationId, | 196 kNetworkActivateNotificationId, |
197 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), | 197 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), |
198 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, | 198 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, |
199 base::UTF8ToUTF16((cellular->name()))), | 199 base::UTF8ToUTF16((cellular->name()))), |
200 icon, | 200 icon, system_notifier::kNotifierNetwork, |
201 system_notifier::kNotifierNetwork, | 201 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, |
202 base::Bind(&ash::network_connect::ShowNetworkSettings, | 202 weak_ptr_factory_.GetWeakPtr(), cellular->path()))); |
203 cellular->path()))); | |
204 } | 203 } |
205 | 204 |
206 void NetworkStateNotifier::ShowNetworkConnectError( | 205 void NetworkStateNotifier::ShowNetworkConnectError( |
207 const std::string& error_name, | 206 const std::string& error_name, |
208 const std::string& service_path) { | 207 const std::string& service_path) { |
209 if (service_path.empty()) { | 208 if (service_path.empty()) { |
210 base::DictionaryValue shill_properties; | 209 base::DictionaryValue shill_properties; |
211 ShowConnectErrorNotification(error_name, service_path, shill_properties); | 210 ShowConnectErrorNotification(error_name, service_path, shill_properties); |
212 return; | 211 return; |
213 } | 212 } |
214 // Get the up-to-date properties for the network and display the error. | 213 // Get the up-to-date properties for the network and display the error. |
215 NetworkHandler::Get()->network_configuration_handler()->GetProperties( | 214 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
216 service_path, | 215 service_path, |
217 base::Bind(&NetworkStateNotifier::ConnectErrorPropertiesSucceeded, | 216 base::Bind(&NetworkStateNotifier::ConnectErrorPropertiesSucceeded, |
218 weak_ptr_factory_.GetWeakPtr(), error_name), | 217 weak_ptr_factory_.GetWeakPtr(), error_name), |
219 base::Bind(&NetworkStateNotifier::ConnectErrorPropertiesFailed, | 218 base::Bind(&NetworkStateNotifier::ConnectErrorPropertiesFailed, |
220 weak_ptr_factory_.GetWeakPtr(), error_name, service_path)); | 219 weak_ptr_factory_.GetWeakPtr(), error_name, service_path)); |
221 } | 220 } |
222 | 221 |
222 void NetworkStateNotifier::ShowMobileActivationkError( | |
armansito
2014/10/24 20:02:21
s/ShowMobileActivationkError/ShowMobileActivationE
stevenjb
2014/10/24 23:01:50
Oops, thanks! Done.
| |
223 const std::string& service_path) { | |
224 const NetworkState* cellular = | |
225 NetworkHandler::Get()->network_state_handler()->GetNetworkState( | |
226 service_path); | |
227 if (!cellular || cellular->type() != shill::kTypeCellular) { | |
228 NET_LOG_ERROR("ShowMobileActivationkError without Cellular network", | |
229 service_path); | |
230 return; | |
231 } | |
232 message_center::MessageCenter::Get()->AddNotification( | |
233 message_center::Notification::CreateSystemNotification( | |
234 kNetworkActivateNotificationId, | |
235 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE), | |
236 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION, | |
237 base::UTF8ToUTF16(cellular->name())), | |
238 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | |
239 IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED), | |
240 ash::system_notifier::kNotifierNetworkError, | |
241 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | |
242 weak_ptr_factory_.GetWeakPtr(), service_path))); | |
243 } | |
244 | |
245 void NetworkStateNotifier::RemoveConnectNotification() { | |
246 message_center::MessageCenter* message_center = | |
247 message_center::MessageCenter::Get(); | |
248 if (message_center) { | |
249 message_center->RemoveNotification(kNetworkConnectNotificationId, | |
250 false /* not by user */); | |
251 } | |
252 } | |
253 | |
223 void NetworkStateNotifier::ConnectErrorPropertiesSucceeded( | 254 void NetworkStateNotifier::ConnectErrorPropertiesSucceeded( |
224 const std::string& error_name, | 255 const std::string& error_name, |
225 const std::string& service_path, | 256 const std::string& service_path, |
226 const base::DictionaryValue& shill_properties) { | 257 const base::DictionaryValue& shill_properties) { |
227 std::string state; | 258 std::string state; |
228 shill_properties.GetStringWithoutPathExpansion(shill::kStateProperty, &state); | 259 shill_properties.GetStringWithoutPathExpansion(shill::kStateProperty, &state); |
229 if (chromeos::NetworkState::StateIsConnected(state) || | 260 if (chromeos::NetworkState::StateIsConnected(state) || |
230 chromeos::NetworkState::StateIsConnecting(state)) { | 261 chromeos::NetworkState::StateIsConnecting(state)) { |
231 // Network is no longer in an error state. This can happen if an unexpected | 262 // Network is no longer in an error state. This can happen if an |
232 // Idle state transition occurs, see crbug.com/333955. | 263 // unexpected idle state transition occurs, see crbug.com/333955. |
233 return; | 264 return; |
234 } | 265 } |
235 ShowConnectErrorNotification(error_name, service_path, shill_properties); | 266 ShowConnectErrorNotification(error_name, service_path, shill_properties); |
236 } | 267 } |
237 | 268 |
238 void NetworkStateNotifier::ConnectErrorPropertiesFailed( | 269 void NetworkStateNotifier::ConnectErrorPropertiesFailed( |
239 const std::string& error_name, | 270 const std::string& error_name, |
240 const std::string& service_path, | 271 const std::string& service_path, |
241 const std::string& shill_connect_error, | 272 const std::string& shill_connect_error, |
242 scoped_ptr<base::DictionaryValue> shill_error_data) { | 273 scoped_ptr<base::DictionaryValue> shill_error_data) { |
(...skipping 19 matching lines...) Expand all Loading... | |
262 shill_error.clear(); | 293 shill_error.clear(); |
263 } else { | 294 } else { |
264 NET_LOG_DEBUG("Notify Service.Error: " + shill_error, service_path); | 295 NET_LOG_DEBUG("Notify Service.Error: " + shill_error, service_path); |
265 } | 296 } |
266 | 297 |
267 const NetworkState* network = | 298 const NetworkState* network = |
268 NetworkHandler::Get()->network_state_handler()->GetNetworkState( | 299 NetworkHandler::Get()->network_state_handler()->GetNetworkState( |
269 service_path); | 300 service_path); |
270 if (network) { | 301 if (network) { |
271 // Always log last_error, but only use it if shill_error is empty. | 302 // Always log last_error, but only use it if shill_error is empty. |
272 // TODO(stevenjb): This shouldn't ever be necessary, but is kept here as a | 303 // TODO(stevenjb): This shouldn't ever be necessary, but is kept here as |
273 // failsafe since more information is better than less when debugging and | 304 // a failsafe since more information is better than less when debugging |
274 // we have encountered some strange edge cases before. | 305 // and we have encountered some strange edge cases before. |
275 NET_LOG_DEBUG("Notify Network.last_error: " + network->last_error(), | 306 NET_LOG_DEBUG("Notify Network.last_error: " + network->last_error(), |
276 service_path); | 307 service_path); |
277 if (shill_error.empty()) | 308 if (shill_error.empty()) |
278 shill_error = network->last_error(); | 309 shill_error = network->last_error(); |
279 } | 310 } |
280 | 311 |
281 if (ShillErrorIsIgnored(shill_error)) { | 312 if (ShillErrorIsIgnored(shill_error)) { |
282 NET_LOG_DEBUG("Notify Ignoring error: " + error_name, service_path); | 313 NET_LOG_DEBUG("Notify Ignoring error: " + error_name, service_path); |
283 return; | 314 return; |
284 } | 315 } |
285 | 316 |
286 error = network_connect::ErrorString(shill_error, service_path); | 317 error = network_connect_->GetErrorString(shill_error, service_path); |
287 if (error.empty()) | 318 if (error.empty()) |
288 error = l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); | 319 error = l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); |
289 } | 320 } |
290 NET_LOG_ERROR("Notify connect error: " + base::UTF16ToUTF8(error), | 321 NET_LOG_ERROR("Notify connect error: " + base::UTF16ToUTF8(error), |
291 service_path); | 322 service_path); |
292 | 323 |
293 std::string network_name = | 324 std::string network_name = |
294 chromeos::shill_property_util::GetNameFromProperties(service_path, | 325 chromeos::shill_property_util::GetNameFromProperties(service_path, |
295 shill_properties); | 326 shill_properties); |
296 std::string network_error_details; | 327 std::string network_error_details; |
297 shill_properties.GetStringWithoutPathExpansion(shill::kErrorDetailsProperty, | 328 shill_properties.GetStringWithoutPathExpansion(shill::kErrorDetailsProperty, |
298 &network_error_details); | 329 &network_error_details); |
299 | 330 |
300 base::string16 error_msg; | 331 base::string16 error_msg; |
301 if (!network_error_details.empty()) { | 332 if (!network_error_details.empty()) { |
302 // network_name should't be empty if network_error_details is set. | 333 // network_name should't be empty if network_error_details is set. |
303 error_msg = l10n_util::GetStringFUTF16( | 334 error_msg = l10n_util::GetStringFUTF16( |
304 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_SERVER_MESSAGE, | 335 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_SERVER_MESSAGE, |
305 base::UTF8ToUTF16(network_name), | 336 base::UTF8ToUTF16(network_name), error, |
306 error, | |
307 base::UTF8ToUTF16(network_error_details)); | 337 base::UTF8ToUTF16(network_error_details)); |
308 } else if (network_name.empty()) { | 338 } else if (network_name.empty()) { |
309 error_msg = l10n_util::GetStringFUTF16( | 339 error_msg = l10n_util::GetStringFUTF16( |
310 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_NO_NAME, error); | 340 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_NO_NAME, error); |
311 } else { | 341 } else { |
312 error_msg = l10n_util::GetStringFUTF16(IDS_NETWORK_CONNECTION_ERROR_MESSAGE, | 342 error_msg = |
313 base::UTF8ToUTF16(network_name), | 343 l10n_util::GetStringFUTF16(IDS_NETWORK_CONNECTION_ERROR_MESSAGE, |
314 error); | 344 base::UTF8ToUTF16(network_name), error); |
315 } | 345 } |
316 | 346 |
317 std::string network_type; | 347 std::string network_type; |
318 shill_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, | 348 shill_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, |
319 &network_type); | 349 &network_type); |
320 | 350 |
321 ShowErrorNotification( | 351 ShowErrorNotification( |
322 network_connect::kNetworkConnectNotificationId, | 352 kNetworkConnectNotificationId, network_type, |
323 network_type, | 353 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg, |
324 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), | 354 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, |
325 error_msg, | 355 weak_ptr_factory_.GetWeakPtr(), service_path)); |
326 base::Bind(&network_connect::ShowNetworkSettings, service_path)); | 356 } |
357 | |
358 void NetworkStateNotifier::ShowNetworkSettings( | |
359 const std::string& service_path) { | |
360 network_connect_->ShowNetworkSettings(service_path); | |
327 } | 361 } |
328 | 362 |
329 } // namespace ash | 363 } // namespace ash |
OLD | NEW |