OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/extensions/api/music_manager_private/device_id.h" | 5 #include "chrome/browser/extensions/api/music_manager_private/device_id.h" |
6 | 6 |
7 #include <sys/socket.h> // Must be included before ifaddrs.h. | 7 #include <sys/socket.h> // Must be included before ifaddrs.h. |
8 #include <ifaddrs.h> | 8 #include <ifaddrs.h> |
9 #include <net/if.h> | 9 #include <net/if.h> |
10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 const char* mac_address = | 117 const char* mac_address = |
118 static_cast<const char*>(ifinfo.ifr_hwaddr.sa_data); | 118 static_cast<const char*>(ifinfo.ifr_hwaddr.sa_data); |
119 if (!is_valid_mac_address_.Run(mac_address, MAC_LENGTH)) | 119 if (!is_valid_mac_address_.Run(mac_address, MAC_LENGTH)) |
120 return true; | 120 return true; |
121 | 121 |
122 if (!IsValidPrefix(ifinfo.ifr_name, prefixes, prefixes_count)) | 122 if (!IsValidPrefix(ifinfo.ifr_name, prefixes, prefixes_count)) |
123 return true; | 123 return true; |
124 | 124 |
125 // Got one! | 125 // Got one! |
126 found_mac_address_ = | 126 found_mac_address_ = |
127 base::StringToLowerASCII(base::HexEncode(mac_address, MAC_LENGTH)); | 127 base::ToLowerASCII(base::HexEncode(mac_address, MAC_LENGTH)); |
128 return false; | 128 return false; |
129 } | 129 } |
130 | 130 |
131 std::string mac_address() const { return found_mac_address_; } | 131 std::string mac_address() const { return found_mac_address_; } |
132 | 132 |
133 private: | 133 private: |
134 bool IsValidPrefix(const char* name, | 134 bool IsValidPrefix(const char* name, |
135 const char* const prefixes[], | 135 const char* const prefixes[], |
136 size_t prefixes_count) { | 136 size_t prefixes_count) { |
137 for (size_t i = 0; i < prefixes_count; i++) { | 137 for (size_t i = 0; i < prefixes_count; i++) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 content::BrowserThread::PostTask( | 197 content::BrowserThread::PostTask( |
198 content::BrowserThread::FILE, | 198 content::BrowserThread::FILE, |
199 FROM_HERE, | 199 FROM_HERE, |
200 base::Bind(GetRawDeviceIdImpl, | 200 base::Bind(GetRawDeviceIdImpl, |
201 base::Bind(DeviceId::IsValidMacAddress), | 201 base::Bind(DeviceId::IsValidMacAddress), |
202 callback)); | 202 callback)); |
203 } | 203 } |
204 | 204 |
205 } // namespace api | 205 } // namespace api |
206 } // namespace extensions | 206 } // namespace extensions |
OLD | NEW |