| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = path.substr(header_size, key_len); |
| 65 base::StringToLowerASCII(&reverse_address); | 65 base::StringToLowerASCII(&reverse_address); |
| 66 std::vector<std::string> result; | 66 std::vector<std::string> result; |
| 67 base::SplitString(reverse_address, ':', &result); | 67 base::SplitString(reverse_address, ':', &result); |
| 68 std::reverse(result.begin(), result.end()); | 68 std::reverse(result.begin(), result.end()); |
| 69 std::string address = 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) |
| 76 : id_(id) {} | 76 : id_(id) {} |
| 77 | 77 |
| 78 // Overridden from NotificationDelegate: | 78 // Overridden from NotificationDelegate: |
| 79 std::string id() const override { return id_; } | 79 std::string id() const override { return id_; } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { | 229 void PeripheralBatteryObserver::CancelNotification(const std::string& address) { |
| 230 // 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. |
| 231 if (notification_profile_) { | 231 if (notification_profile_) { |
| 232 g_browser_process->notification_ui_manager()->CancelById( | 232 g_browser_process->notification_ui_manager()->CancelById( |
| 233 address, NotificationUIManager::GetProfileID(notification_profile_)); | 233 address, NotificationUIManager::GetProfileID(notification_profile_)); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace chromeos | 237 } // namespace chromeos |
| OLD | NEW |