Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: chrome/browser/chromeos/power/peripheral_battery_observer.cc

Issue 1395093002: Fix system notifications incorrectly marked as type WEB_PAGE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timeout
Patch Set: Fix typo Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 22 matching lines...) Expand all
33 33
34 // When a peripheral device's battery level is <= kLowBatteryLevel, consider 34 // When a peripheral device's battery level is <= kLowBatteryLevel, consider
35 // it to be in low battery condition. 35 // it to be in low battery condition.
36 const int kLowBatteryLevel = 15; 36 const int kLowBatteryLevel = 15;
37 37
38 // Don't show 2 low battery notification within |kNotificationIntervalSec| 38 // Don't show 2 low battery notification within |kNotificationIntervalSec|
39 // seconds. 39 // seconds.
40 const int kNotificationIntervalSec = 60; 40 const int kNotificationIntervalSec = 60;
41 41
42 const char kNotificationOriginUrl[] = "chrome://peripheral-battery"; 42 const char kNotificationOriginUrl[] = "chrome://peripheral-battery";
43 const char kNotifierId[] = "power.peripheral-battery";
43 44
44 // HID Bluetooth device's battery sysfs entry path looks like 45 // HID Bluetooth device's battery sysfs entry path looks like
45 // "/sys/class/power_supply/hid-AA:BB:CC:DD:EE:FF-battery". 46 // "/sys/class/power_supply/hid-AA:BB:CC:DD:EE:FF-battery".
46 // Here the bluetooth address is showed in reverse order and its true 47 // Here the bluetooth address is showed in reverse order and its true
47 // address "FF:EE:DD:CC:BB:AA". 48 // address "FF:EE:DD:CC:BB:AA".
48 const char kHIDBatteryPathPrefix[] = "/sys/class/power_supply/hid-"; 49 const char kHIDBatteryPathPrefix[] = "/sys/class/power_supply/hid-";
49 const char kHIDBatteryPathSuffix[] = "-battery"; 50 const char kHIDBatteryPathSuffix[] = "-battery";
50 51
51 bool IsBluetoothHIDBattery(const std::string& path) { 52 bool IsBluetoothHIDBattery(const std::string& path) {
52 return base::StartsWith(path, kHIDBatteryPathPrefix, 53 return base::StartsWith(path, kHIDBatteryPathPrefix,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 g_browser_process->notification_ui_manager(); 206 g_browser_process->notification_ui_manager();
206 207
207 base::string16 string_text = l10n_util::GetStringFUTF16Int( 208 base::string16 string_text = l10n_util::GetStringFUTF16Int(
208 IDS_ASH_LOW_PERIPHERAL_BATTERY_NOTIFICATION_TEXT, 209 IDS_ASH_LOW_PERIPHERAL_BATTERY_NOTIFICATION_TEXT,
209 battery.level); 210 battery.level);
210 211
211 Notification notification( 212 Notification notification(
212 message_center::NOTIFICATION_TYPE_SIMPLE, base::UTF8ToUTF16(battery.name), 213 message_center::NOTIFICATION_TYPE_SIMPLE, base::UTF8ToUTF16(battery.name),
213 string_text, ui::ResourceBundle::GetSharedInstance().GetImageNamed( 214 string_text, ui::ResourceBundle::GetSharedInstance().GetImageNamed(
214 IDR_NOTIFICATION_PERIPHERAL_BATTERY_LOW), 215 IDR_NOTIFICATION_PERIPHERAL_BATTERY_LOW),
215 message_center::NotifierId(GURL(kNotificationOriginUrl)), 216 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
217 kNotifierId),
216 base::string16(), GURL(kNotificationOriginUrl), address, 218 base::string16(), GURL(kNotificationOriginUrl), address,
217 message_center::RichNotificationData(), 219 message_center::RichNotificationData(),
218 new PeripheralBatteryNotificationDelegate(address)); 220 new PeripheralBatteryNotificationDelegate(address));
219 221
220 notification.set_priority(message_center::SYSTEM_PRIORITY); 222 notification.set_priority(message_center::SYSTEM_PRIORITY);
221 223
222 notification_profile_ = ProfileManager::GetPrimaryUserProfile(); 224 notification_profile_ = ProfileManager::GetPrimaryUserProfile();
223 notification_manager->Add(notification, notification_profile_); 225 notification_manager->Add(notification, notification_profile_);
224 226
225 return true; 227 return true;
226 } 228 }
227 229
228 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { 230 void PeripheralBatteryObserver::CancelNotification(const std::string& address) {
229 // If last_used_profile_ is NULL then no notification has been posted yet. 231 // If last_used_profile_ is NULL then no notification has been posted yet.
230 if (notification_profile_) { 232 if (notification_profile_) {
231 g_browser_process->notification_ui_manager()->CancelById( 233 g_browser_process->notification_ui_manager()->CancelById(
232 address, NotificationUIManager::GetProfileID(notification_profile_)); 234 address, NotificationUIManager::GetProfileID(notification_profile_));
233 } 235 }
234 } 236 }
235 237
236 } // namespace chromeos 238 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents_service.cc ('k') | chrome/browser/local_discovery/privet_notifications.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698