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

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

Issue 1220963005: Update base::StartsWith calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const char kNotificationOriginUrl[] = "chrome://peripheral-battery"; 42 const char kNotificationOriginUrl[] = "chrome://peripheral-battery";
43 43
44 // HID Bluetooth device's battery sysfs entry path looks like 44 // HID Bluetooth device's battery sysfs entry path looks like
45 // "/sys/class/power_supply/hid-AA:BB:CC:DD:EE:FF-battery". 45 // "/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 46 // Here the bluetooth address is showed in reverse order and its true
47 // address "FF:EE:DD:CC:BB:AA". 47 // address "FF:EE:DD:CC:BB:AA".
48 const char kHIDBatteryPathPrefix[] = "/sys/class/power_supply/hid-"; 48 const char kHIDBatteryPathPrefix[] = "/sys/class/power_supply/hid-";
49 const char kHIDBatteryPathSuffix[] = "-battery"; 49 const char kHIDBatteryPathSuffix[] = "-battery";
50 50
51 bool IsBluetoothHIDBattery(const std::string& path) { 51 bool IsBluetoothHIDBattery(const std::string& path) {
52 return base::StartsWithASCII(path, kHIDBatteryPathPrefix, false) && 52 return base::StartsWith(path, kHIDBatteryPathPrefix,
53 base::EndsWith(path, kHIDBatteryPathSuffix, false); 53 base::CompareCase::INSENSITIVE_ASCII) &&
54 base::EndsWith(path, kHIDBatteryPathSuffix,
55 base::CompareCase::INSENSITIVE_ASCII);
54 } 56 }
55 57
56 std::string ExtractBluetoothAddress(const std::string& path) { 58 std::string ExtractBluetoothAddress(const std::string& path) {
57 int header_size = strlen(kHIDBatteryPathPrefix); 59 int header_size = strlen(kHIDBatteryPathPrefix);
58 int end_size = strlen(kHIDBatteryPathSuffix); 60 int end_size = strlen(kHIDBatteryPathSuffix);
59 int key_len = path.size() - header_size - end_size; 61 int key_len = path.size() - header_size - end_size;
60 if (key_len <= 0) 62 if (key_len <= 0)
61 return std::string(); 63 return std::string();
62 std::string reverse_address = path.substr(header_size, key_len); 64 std::string reverse_address = path.substr(header_size, key_len);
63 base::StringToLowerASCII(&reverse_address); 65 base::StringToLowerASCII(&reverse_address);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 228
227 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { 229 void PeripheralBatteryObserver::CancelNotification(const std::string& address) {
228 // If last_used_profile_ is NULL then no notification has been posted yet. 230 // If last_used_profile_ is NULL then no notification has been posted yet.
229 if (notification_profile_) { 231 if (notification_profile_) {
230 g_browser_process->notification_ui_manager()->CancelById( 232 g_browser_process->notification_ui_manager()->CancelById(
231 address, NotificationUIManager::GetProfileID(notification_profile_)); 233 address, NotificationUIManager::GetProfileID(notification_profile_));
232 } 234 }
233 } 235 }
234 236
235 } // namespace chromeos 237 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698