| OLD | NEW |
| 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 "chrome/browser/chromeos/power/peripheral_battery_observer.h" | 5 #include "chrome/browser/chromeos/power/peripheral_battery_observer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/strings/grit/ash_strings.h" | 10 #include "ash/strings/grit/ash_strings.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return false; | 202 return false; |
| 203 | 203 |
| 204 NotificationUIManager* notification_manager = | 204 NotificationUIManager* notification_manager = |
| 205 g_browser_process->notification_ui_manager(); | 205 g_browser_process->notification_ui_manager(); |
| 206 | 206 |
| 207 base::string16 string_text = l10n_util::GetStringFUTF16Int( | 207 base::string16 string_text = l10n_util::GetStringFUTF16Int( |
| 208 IDS_ASH_LOW_PERIPHERAL_BATTERY_NOTIFICATION_TEXT, | 208 IDS_ASH_LOW_PERIPHERAL_BATTERY_NOTIFICATION_TEXT, |
| 209 battery.level); | 209 battery.level); |
| 210 | 210 |
| 211 Notification notification( | 211 Notification notification( |
| 212 message_center::NOTIFICATION_TYPE_SIMPLE, GURL(kNotificationOriginUrl), | 212 message_center::NOTIFICATION_TYPE_SIMPLE, base::UTF8ToUTF16(battery.name), |
| 213 base::UTF8ToUTF16(battery.name), string_text, | 213 string_text, ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 214 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 214 IDR_NOTIFICATION_PERIPHERAL_BATTERY_LOW), |
| 215 IDR_NOTIFICATION_PERIPHERAL_BATTERY_LOW), | |
| 216 message_center::NotifierId(GURL(kNotificationOriginUrl)), | 215 message_center::NotifierId(GURL(kNotificationOriginUrl)), |
| 217 base::string16(), address, message_center::RichNotificationData(), | 216 base::string16(), GURL(kNotificationOriginUrl), address, |
| 217 message_center::RichNotificationData(), |
| 218 new PeripheralBatteryNotificationDelegate(address)); | 218 new PeripheralBatteryNotificationDelegate(address)); |
| 219 | 219 |
| 220 notification.set_priority(message_center::SYSTEM_PRIORITY); | 220 notification.set_priority(message_center::SYSTEM_PRIORITY); |
| 221 | 221 |
| 222 notification_profile_ = ProfileManager::GetPrimaryUserProfile(); | 222 notification_profile_ = ProfileManager::GetPrimaryUserProfile(); |
| 223 notification_manager->Add(notification, notification_profile_); | 223 notification_manager->Add(notification, notification_profile_); |
| 224 | 224 |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| 227 | 227 |
| 228 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { | 228 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { |
| 229 // If last_used_profile_ is NULL then no notification has been posted yet. | 229 // If last_used_profile_ is NULL then no notification has been posted yet. |
| 230 if (notification_profile_) { | 230 if (notification_profile_) { |
| 231 g_browser_process->notification_ui_manager()->CancelById( | 231 g_browser_process->notification_ui_manager()->CancelById( |
| 232 address, NotificationUIManager::GetProfileID(notification_profile_)); | 232 address, NotificationUIManager::GetProfileID(notification_profile_)); |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace chromeos | 236 } // namespace chromeos |
| OLD | NEW |