Chromium Code Reviews| 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 "ui/chromeos/network/network_state_notifier.h" |
| 6 | 6 |
| 7 #include "ash/system/chromeos/network/network_connect.h" | |
| 8 #include "ash/system/system_notifier.h" | |
| 9 #include "base/bind.h" | 7 #include "base/bind.h" |
| 10 #include "base/location.h" | 8 #include "base/location.h" |
| 11 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chromeos/network/network_configuration_handler.h" | 12 #include "chromeos/network/network_configuration_handler.h" |
| 15 #include "chromeos/network/network_connection_handler.h" | 13 #include "chromeos/network/network_connection_handler.h" |
| 16 #include "chromeos/network/network_event_log.h" | 14 #include "chromeos/network/network_event_log.h" |
| 17 #include "chromeos/network/network_state.h" | 15 #include "chromeos/network/network_state.h" |
| 18 #include "chromeos/network/network_state_handler.h" | 16 #include "chromeos/network/network_state_handler.h" |
| 19 #include "chromeos/network/shill_property_util.h" | 17 #include "chromeos/network/shill_property_util.h" |
| 20 #include "grit/ash_resources.h" | |
| 21 #include "grit/ash_strings.h" | |
| 22 #include "grit/ui_chromeos_resources.h" | |
| 23 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/chromeos/network/network_connect.h" | |
| 22 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" | |
| 23 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" | |
| 26 #include "ui/message_center/message_center.h" | 24 #include "ui/message_center/message_center.h" |
| 27 #include "ui/message_center/notification.h" | 25 #include "ui/message_center/notification.h" |
| 28 | 26 |
| 29 using chromeos::NetworkConnectionHandler; | 27 using chromeos::NetworkConnectionHandler; |
| 30 using chromeos::NetworkHandler; | 28 using chromeos::NetworkHandler; |
| 31 using chromeos::NetworkState; | 29 using chromeos::NetworkState; |
| 32 using chromeos::NetworkStateHandler; | 30 using chromeos::NetworkStateHandler; |
| 33 using chromeos::NetworkTypePattern; | 31 using chromeos::NetworkTypePattern; |
| 34 | 32 |
| 35 namespace { | 33 namespace { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 48 if (error_name == NetworkConnectionHandler::kErrorNotFound) | 46 if (error_name == NetworkConnectionHandler::kErrorNotFound) |
| 49 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED); | 47 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED); |
| 50 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) { | 48 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) { |
| 51 return l10n_util::GetStringUTF16( | 49 return l10n_util::GetStringUTF16( |
| 52 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED); | 50 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED); |
| 53 } | 51 } |
| 54 if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) { | 52 if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) { |
| 55 return l10n_util::GetStringUTF16( | 53 return l10n_util::GetStringUTF16( |
| 56 IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED); | 54 IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED); |
| 57 } | 55 } |
| 58 if (error_name == ash::NetworkConnect::kErrorActivateFailed) { | 56 if (error_name == ui::NetworkConnect::kErrorActivateFailed) { |
| 59 return l10n_util::GetStringUTF16( | 57 return l10n_util::GetStringUTF16( |
| 60 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED); | 58 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED); |
| 61 } | 59 } |
| 62 return base::string16(); | 60 return base::string16(); |
| 63 } | 61 } |
| 64 | 62 |
| 65 void ShowErrorNotification(const std::string& notification_id, | 63 void ShowErrorNotification(const std::string& notification_id, |
| 66 const std::string& network_type, | 64 const std::string& network_type, |
| 67 const base::string16& title, | 65 const base::string16& title, |
| 68 const base::string16& message, | 66 const base::string16& message, |
| 69 const base::Closure& callback) { | 67 const base::Closure& callback) { |
| 70 int icon_id = (network_type == shill::kTypeCellular) | 68 int icon_id = (network_type == shill::kTypeCellular) |
| 71 ? IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED | 69 ? IDR_AURA_UBER_TRAY_NETWORK_FAILED_CELLULAR |
| 72 : IDR_AURA_UBER_TRAY_NETWORK_FAILED; | 70 : IDR_AURA_UBER_TRAY_NETWORK_FAILED; |
| 73 const gfx::Image& icon = | 71 const gfx::Image& icon = |
| 74 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); | 72 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); |
| 75 message_center::MessageCenter::Get()->AddNotification( | 73 message_center::MessageCenter::Get()->AddNotification( |
| 76 message_center::Notification::CreateSystemNotification( | 74 message_center::Notification::CreateSystemNotification( |
| 77 notification_id, title, message, icon, | 75 notification_id, title, message, icon, |
| 78 ash::system_notifier::kNotifierNetworkError, callback)); | 76 ui::NetworkStateNotifier::kNotifierNetworkError, callback)); |
| 79 } | 77 } |
| 80 | 78 |
| 81 } // namespace | 79 } // namespace |
| 82 | 80 |
| 83 namespace ash { | 81 namespace ui { |
| 82 | |
| 83 | |
|
tbarzic
2014/10/27 20:58:42
nuke one line
stevenjb
2014/10/29 20:44:55
Done.
| |
| 84 const char NetworkStateNotifier::kNotifierNetwork[] = "ui.chromeos.network"; | |
| 85 const char NetworkStateNotifier::kNotifierNetworkError[] = | |
| 86 "ui.chromeos.network.error"; | |
| 84 | 87 |
| 85 const char NetworkStateNotifier::kNetworkConnectNotificationId[] = | 88 const char NetworkStateNotifier::kNetworkConnectNotificationId[] = |
| 86 "chrome://settings/internet/connect"; | 89 "chrome://settings/internet/connect"; |
| 87 const char NetworkStateNotifier::kNetworkActivateNotificationId[] = | 90 const char NetworkStateNotifier::kNetworkActivateNotificationId[] = |
| 88 "chrome://settings/internet/activate"; | 91 "chrome://settings/internet/activate"; |
| 89 const char NetworkStateNotifier::kNetworkOutOfCreditsNotificationId[] = | 92 const char NetworkStateNotifier::kNetworkOutOfCreditsNotificationId[] = |
| 90 "chrome://settings/internet/out-of-credits"; | 93 "chrome://settings/internet/out-of-credits"; |
| 91 | 94 |
| 92 NetworkStateNotifier::NetworkStateNotifier(NetworkConnect* network_connect) | 95 NetworkStateNotifier::NetworkStateNotifier(NetworkConnect* network_connect) |
| 93 : network_connect_(network_connect), | 96 : network_connect_(network_connect), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 else | 193 else |
| 191 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; | 194 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; |
| 192 const gfx::Image& icon = | 195 const gfx::Image& icon = |
| 193 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); | 196 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); |
| 194 message_center::MessageCenter::Get()->AddNotification( | 197 message_center::MessageCenter::Get()->AddNotification( |
| 195 message_center::Notification::CreateSystemNotification( | 198 message_center::Notification::CreateSystemNotification( |
| 196 kNetworkActivateNotificationId, | 199 kNetworkActivateNotificationId, |
| 197 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), | 200 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), |
| 198 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, | 201 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, |
| 199 base::UTF8ToUTF16((cellular->name()))), | 202 base::UTF8ToUTF16((cellular->name()))), |
| 200 icon, system_notifier::kNotifierNetwork, | 203 icon, kNotifierNetwork, |
| 201 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 204 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, |
| 202 weak_ptr_factory_.GetWeakPtr(), cellular->path()))); | 205 weak_ptr_factory_.GetWeakPtr(), cellular->path()))); |
| 203 } | 206 } |
| 204 | 207 |
| 205 void NetworkStateNotifier::ShowNetworkConnectError( | 208 void NetworkStateNotifier::ShowNetworkConnectError( |
| 206 const std::string& error_name, | 209 const std::string& error_name, |
| 207 const std::string& service_path) { | 210 const std::string& service_path) { |
| 208 if (service_path.empty()) { | 211 if (service_path.empty()) { |
| 209 base::DictionaryValue shill_properties; | 212 base::DictionaryValue shill_properties; |
| 210 ShowConnectErrorNotification(error_name, service_path, shill_properties); | 213 ShowConnectErrorNotification(error_name, service_path, shill_properties); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 229 service_path); | 232 service_path); |
| 230 return; | 233 return; |
| 231 } | 234 } |
| 232 message_center::MessageCenter::Get()->AddNotification( | 235 message_center::MessageCenter::Get()->AddNotification( |
| 233 message_center::Notification::CreateSystemNotification( | 236 message_center::Notification::CreateSystemNotification( |
| 234 kNetworkActivateNotificationId, | 237 kNetworkActivateNotificationId, |
| 235 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE), | 238 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE), |
| 236 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION, | 239 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION, |
| 237 base::UTF8ToUTF16(cellular->name())), | 240 base::UTF8ToUTF16(cellular->name())), |
| 238 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 241 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 239 IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED), | 242 IDR_AURA_UBER_TRAY_NETWORK_FAILED_CELLULAR), |
| 240 ash::system_notifier::kNotifierNetworkError, | 243 kNotifierNetworkError, |
| 241 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 244 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, |
| 242 weak_ptr_factory_.GetWeakPtr(), service_path))); | 245 weak_ptr_factory_.GetWeakPtr(), service_path))); |
| 243 } | 246 } |
| 244 | 247 |
| 245 void NetworkStateNotifier::RemoveConnectNotification() { | 248 void NetworkStateNotifier::RemoveConnectNotification() { |
| 246 message_center::MessageCenter* message_center = | 249 message_center::MessageCenter* message_center = |
| 247 message_center::MessageCenter::Get(); | 250 message_center::MessageCenter::Get(); |
| 248 if (message_center) { | 251 if (message_center) { |
| 249 message_center->RemoveNotification(kNetworkConnectNotificationId, | 252 message_center->RemoveNotification(kNetworkConnectNotificationId, |
| 250 false /* not by user */); | 253 false /* not by user */); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg, | 356 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg, |
| 354 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 357 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, |
| 355 weak_ptr_factory_.GetWeakPtr(), service_path)); | 358 weak_ptr_factory_.GetWeakPtr(), service_path)); |
| 356 } | 359 } |
| 357 | 360 |
| 358 void NetworkStateNotifier::ShowNetworkSettings( | 361 void NetworkStateNotifier::ShowNetworkSettings( |
| 359 const std::string& service_path) { | 362 const std::string& service_path) { |
| 360 network_connect_->ShowNetworkSettings(service_path); | 363 network_connect_->ShowNetworkSettings(service_path); |
| 361 } | 364 } |
| 362 | 365 |
| 363 } // namespace ash | 366 } // namespace ui |
| OLD | NEW |