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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::StartsWithASCII(path, kHIDBatteryPathPrefix, false) &&
53 EndsWith(path, kHIDBatteryPathSuffix, false); 53 base::EndsWith(path, kHIDBatteryPathSuffix, false);
54 } 54 }
55 55
56 std::string ExtractBluetoothAddress(const std::string& path) { 56 std::string ExtractBluetoothAddress(const std::string& path) {
57 int header_size = strlen(kHIDBatteryPathPrefix); 57 int header_size = strlen(kHIDBatteryPathPrefix);
58 int end_size = strlen(kHIDBatteryPathSuffix); 58 int end_size = strlen(kHIDBatteryPathSuffix);
59 int key_len = path.size() - header_size - end_size; 59 int key_len = path.size() - header_size - end_size;
60 if (key_len <= 0) 60 if (key_len <= 0)
61 return std::string(); 61 return std::string();
62 std::string reverse_address = path.substr(header_size, key_len); 62 std::string reverse_address = path.substr(header_size, key_len);
63 base::StringToLowerASCII(&reverse_address); 63 base::StringToLowerASCII(&reverse_address);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { 227 void PeripheralBatteryObserver::CancelNotification(const std::string& address) {
228 // If last_used_profile_ is NULL then no notification has been posted yet. 228 // If last_used_profile_ is NULL then no notification has been posted yet.
229 if (notification_profile_) { 229 if (notification_profile_) {
230 g_browser_process->notification_ui_manager()->CancelById( 230 g_browser_process->notification_ui_manager()->CancelById(
231 address, NotificationUIManager::GetProfileID(notification_profile_)); 231 address, NotificationUIManager::GetProfileID(notification_profile_));
232 } 232 }
233 } 233 }
234 234
235 } // namespace chromeos 235 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698