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