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

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

Issue 1279123004: Replace ToLower calls to the new format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 base::EndsWith(path, kHIDBatteryPathSuffix, 54 base::EndsWith(path, kHIDBatteryPathSuffix,
55 base::CompareCase::INSENSITIVE_ASCII); 55 base::CompareCase::INSENSITIVE_ASCII);
56 } 56 }
57 57
58 std::string ExtractBluetoothAddress(const std::string& path) { 58 std::string ExtractBluetoothAddress(const std::string& path) {
59 int header_size = strlen(kHIDBatteryPathPrefix); 59 int header_size = strlen(kHIDBatteryPathPrefix);
60 int end_size = strlen(kHIDBatteryPathSuffix); 60 int end_size = strlen(kHIDBatteryPathSuffix);
61 int key_len = path.size() - header_size - end_size; 61 int key_len = path.size() - header_size - end_size;
62 if (key_len <= 0) 62 if (key_len <= 0)
63 return std::string(); 63 return std::string();
64 std::string reverse_address = path.substr(header_size, key_len); 64 std::string reverse_address =
65 base::StringToLowerASCII(&reverse_address); 65 base::ToLowerASCII(path.substr(header_size, key_len));
66 std::vector<std::string> result = base::SplitString( 66 std::vector<std::string> result = base::SplitString(
67 reverse_address, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 67 reverse_address, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
68 std::reverse(result.begin(), result.end()); 68 std::reverse(result.begin(), result.end());
69 std::string address = base::JoinString(result, ":"); 69 std::string address = base::JoinString(result, ":");
70 return address; 70 return address;
71 } 71 }
72 72
73 class PeripheralBatteryNotificationDelegate : public NotificationDelegate { 73 class PeripheralBatteryNotificationDelegate : public NotificationDelegate {
74 public: 74 public:
75 explicit PeripheralBatteryNotificationDelegate(const std::string& id) 75 explicit PeripheralBatteryNotificationDelegate(const std::string& id)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 void PeripheralBatteryObserver::InitializeOnBluetoothReady( 175 void PeripheralBatteryObserver::InitializeOnBluetoothReady(
176 scoped_refptr<device::BluetoothAdapter> adapter) { 176 scoped_refptr<device::BluetoothAdapter> adapter) {
177 bluetooth_adapter_ = adapter; 177 bluetooth_adapter_ = adapter;
178 CHECK(bluetooth_adapter_.get()); 178 CHECK(bluetooth_adapter_.get());
179 bluetooth_adapter_->AddObserver(this); 179 bluetooth_adapter_->AddObserver(this);
180 } 180 }
181 181
182 void PeripheralBatteryObserver::RemoveBattery(const std::string& address) { 182 void PeripheralBatteryObserver::RemoveBattery(const std::string& address) {
183 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 183 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
184 std::string address_lowercase = address; 184 std::string address_lowercase = base::ToLowerASCII(address);
185 base::StringToLowerASCII(&address_lowercase);
186 std::map<std::string, BatteryInfo>::iterator it = 185 std::map<std::string, BatteryInfo>::iterator it =
187 batteries_.find(address_lowercase); 186 batteries_.find(address_lowercase);
188 if (it != batteries_.end()) { 187 if (it != batteries_.end()) {
189 batteries_.erase(it); 188 batteries_.erase(it);
190 CancelNotification(address_lowercase); 189 CancelNotification(address_lowercase);
191 } 190 }
192 } 191 }
193 192
194 bool PeripheralBatteryObserver::PostNotification(const std::string& address, 193 bool PeripheralBatteryObserver::PostNotification(const std::string& address,
195 const BatteryInfo& battery) { 194 const BatteryInfo& battery) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 227
229 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { 228 void PeripheralBatteryObserver::CancelNotification(const std::string& address) {
230 // 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.
231 if (notification_profile_) { 230 if (notification_profile_) {
232 g_browser_process->notification_ui_manager()->CancelById( 231 g_browser_process->notification_ui_manager()->CancelById(
233 address, NotificationUIManager::GetProfileID(notification_profile_)); 232 address, NotificationUIManager::GetProfileID(notification_profile_));
234 } 233 }
235 } 234 }
236 235
237 } // namespace chromeos 236 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698