| 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 "ui/chromeos/network/network_state_notifier.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 did_show_out_of_credits_ = true; | 178 did_show_out_of_credits_ = true; |
| 179 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; | 179 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; |
| 180 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { | 180 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { |
| 181 out_of_credits_notify_time_ = base::Time::Now(); | 181 out_of_credits_notify_time_ = base::Time::Now(); |
| 182 base::string16 error_msg = l10n_util::GetStringFUTF16( | 182 base::string16 error_msg = l10n_util::GetStringFUTF16( |
| 183 IDS_NETWORK_OUT_OF_CREDITS_BODY, base::UTF8ToUTF16(cellular->name())); | 183 IDS_NETWORK_OUT_OF_CREDITS_BODY, base::UTF8ToUTF16(cellular->name())); |
| 184 ShowErrorNotification( | 184 ShowErrorNotification( |
| 185 kNetworkOutOfCreditsNotificationId, cellular->type(), | 185 kNetworkOutOfCreditsNotificationId, cellular->type(), |
| 186 l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE), error_msg, | 186 l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE), error_msg, |
| 187 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 187 base::Bind(&NetworkStateNotifier::ShowNetworkSettingsForPath, |
| 188 weak_ptr_factory_.GetWeakPtr(), cellular->path())); | 188 weak_ptr_factory_.GetWeakPtr(), cellular->path())); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 void NetworkStateNotifier::UpdateCellularActivating( | 192 void NetworkStateNotifier::UpdateCellularActivating( |
| 193 const NetworkState* cellular) { | 193 const NetworkState* cellular) { |
| 194 // Keep track of any activating cellular network. | 194 // Keep track of any activating cellular network. |
| 195 std::string activation_state = cellular->activation_state(); | 195 std::string activation_state = cellular->activation_state(); |
| 196 if (activation_state == shill::kActivationStateActivating) { | 196 if (activation_state == shill::kActivationStateActivating) { |
| 197 cellular_activating_.insert(cellular->path()); | 197 cellular_activating_.insert(cellular->path()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 211 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; | 211 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; |
| 212 const gfx::Image& icon = | 212 const gfx::Image& icon = |
| 213 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); | 213 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); |
| 214 message_center::MessageCenter::Get()->AddNotification( | 214 message_center::MessageCenter::Get()->AddNotification( |
| 215 message_center::Notification::CreateSystemNotification( | 215 message_center::Notification::CreateSystemNotification( |
| 216 kNetworkActivateNotificationId, | 216 kNetworkActivateNotificationId, |
| 217 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), | 217 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), |
| 218 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, | 218 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, |
| 219 base::UTF8ToUTF16((cellular->name()))), | 219 base::UTF8ToUTF16((cellular->name()))), |
| 220 icon, kNotifierNetwork, | 220 icon, kNotifierNetwork, |
| 221 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 221 base::Bind(&NetworkStateNotifier::ShowNetworkSettingsForPath, |
| 222 weak_ptr_factory_.GetWeakPtr(), cellular->path()))); | 222 weak_ptr_factory_.GetWeakPtr(), cellular->path()))); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void NetworkStateNotifier::ShowNetworkConnectError( | 225 void NetworkStateNotifier::ShowNetworkConnectError( |
| 226 const std::string& error_name, | 226 const std::string& error_name, |
| 227 const std::string& service_path) { | 227 const std::string& service_path) { |
| 228 if (service_path.empty()) { | 228 if (service_path.empty()) { |
| 229 base::DictionaryValue shill_properties; | 229 base::DictionaryValue shill_properties; |
| 230 ShowConnectErrorNotification(error_name, service_path, shill_properties); | 230 ShowConnectErrorNotification(error_name, service_path, shill_properties); |
| 231 return; | 231 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 251 } | 251 } |
| 252 message_center::MessageCenter::Get()->AddNotification( | 252 message_center::MessageCenter::Get()->AddNotification( |
| 253 message_center::Notification::CreateSystemNotification( | 253 message_center::Notification::CreateSystemNotification( |
| 254 kNetworkActivateNotificationId, | 254 kNetworkActivateNotificationId, |
| 255 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE), | 255 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE), |
| 256 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION, | 256 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION, |
| 257 base::UTF8ToUTF16(cellular->name())), | 257 base::UTF8ToUTF16(cellular->name())), |
| 258 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 258 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 259 IDR_AURA_UBER_TRAY_NETWORK_FAILED_CELLULAR), | 259 IDR_AURA_UBER_TRAY_NETWORK_FAILED_CELLULAR), |
| 260 kNotifierNetworkError, | 260 kNotifierNetworkError, |
| 261 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 261 base::Bind(&NetworkStateNotifier::ShowNetworkSettingsForPath, |
| 262 weak_ptr_factory_.GetWeakPtr(), service_path))); | 262 weak_ptr_factory_.GetWeakPtr(), service_path))); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void NetworkStateNotifier::RemoveConnectNotification() { | 265 void NetworkStateNotifier::RemoveConnectNotification() { |
| 266 message_center::MessageCenter* message_center = | 266 message_center::MessageCenter* message_center = |
| 267 message_center::MessageCenter::Get(); | 267 message_center::MessageCenter::Get(); |
| 268 if (message_center) { | 268 if (message_center) { |
| 269 message_center->RemoveNotification(kNetworkConnectNotificationId, | 269 message_center->RemoveNotification(kNetworkConnectNotificationId, |
| 270 false /* not by user */); | 270 false /* not by user */); |
| 271 } | 271 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 base::UTF8ToUTF16(network_name), error); | 364 base::UTF8ToUTF16(network_name), error); |
| 365 } | 365 } |
| 366 | 366 |
| 367 std::string network_type; | 367 std::string network_type; |
| 368 shill_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, | 368 shill_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, |
| 369 &network_type); | 369 &network_type); |
| 370 | 370 |
| 371 ShowErrorNotification( | 371 ShowErrorNotification( |
| 372 kNetworkConnectNotificationId, network_type, | 372 kNetworkConnectNotificationId, network_type, |
| 373 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg, | 373 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg, |
| 374 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, | 374 base::Bind(&NetworkStateNotifier::ShowNetworkSettingsForPath, |
| 375 weak_ptr_factory_.GetWeakPtr(), service_path)); | 375 weak_ptr_factory_.GetWeakPtr(), service_path)); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void NetworkStateNotifier::ShowNetworkSettings( | 378 void NetworkStateNotifier::ShowNetworkSettingsForPath( |
| 379 const std::string& service_path) { | 379 const std::string& service_path) { |
| 380 network_connect_->ShowNetworkSettings(service_path); | 380 network_connect_->ShowNetworkSettingsForPath(service_path); |
| 381 } | 381 } |
| 382 | 382 |
| 383 } // namespace ui | 383 } // namespace ui |
| OLD | NEW |