| 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 // Note: The order of header includes is important, as we want both pre-Vista | 7 // Note: The order of header includes is important, as we want both pre-Vista |
| 8 // and post-Vista data structures to be defined, specifically | 8 // and post-Vista data structures to be defined, specifically |
| 9 // PIP_ADAPTER_ADDRESSES and PMIB_IF_ROW2. | 9 // PIP_ADAPTER_ADDRESSES and PMIB_IF_ROW2. |
| 10 | 10 |
| 11 #include <limits.h> | 11 #include <limits.h> |
| 12 #include <stddef.h> | 12 #include <stddef.h> |
| 13 #include <winsock2.h> | 13 #include <winsock2.h> |
| 14 #include <ws2def.h> | 14 #include <ws2def.h> |
| 15 #include <ws2ipdef.h> | 15 #include <ws2ipdef.h> |
| 16 #include <iphlpapi.h> | 16 #include <iphlpapi.h> |
| 17 | 17 |
| 18 #include <string> | 18 #include <string> |
| 19 | 19 |
| 20 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/scoped_native_library.h" | 22 #include "base/scoped_native_library.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
| 26 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "rlz/features/features.h" |
| 28 | 29 |
| 29 #if defined(ENABLE_RLZ) | 30 #if BUILDFLAG(ENABLE_RLZ) |
| 30 #include "rlz/lib/machine_id.h" | 31 #include "rlz/lib/machine_id.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 using extensions::api::DeviceId; | 36 using extensions::api::DeviceId; |
| 36 | 37 |
| 37 typedef base::Callback<bool(const void* bytes, size_t size)> | 38 typedef base::Callback<bool(const void* bytes, size_t size)> |
| 38 IsValidMacAddressCallback; | 39 IsValidMacAddressCallback; |
| 39 | 40 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 LOG(ERROR) << "Could not find appropriate MAC address."; | 177 LOG(ERROR) << "Could not find appropriate MAC address."; |
| 177 } | 178 } |
| 178 | 179 |
| 179 content::BrowserThread::PostTask( | 180 content::BrowserThread::PostTask( |
| 180 content::BrowserThread::UI, | 181 content::BrowserThread::UI, |
| 181 FROM_HERE, | 182 FROM_HERE, |
| 182 base::Bind(callback, mac_address)); | 183 base::Bind(callback, mac_address)); |
| 183 } | 184 } |
| 184 | 185 |
| 185 std::string GetRlzMachineId() { | 186 std::string GetRlzMachineId() { |
| 186 #if defined(ENABLE_RLZ) | 187 #if BUILDFLAG(ENABLE_RLZ) |
| 187 std::string machine_id; | 188 std::string machine_id; |
| 188 if (!rlz_lib::GetMachineId(&machine_id)) | 189 if (!rlz_lib::GetMachineId(&machine_id)) |
| 189 return ""; | 190 return std::string(); |
| 190 return machine_id; | 191 return machine_id; |
| 191 #else | 192 #else |
| 192 return ""; | 193 return std::string(); |
| 193 #endif | 194 #endif |
| 194 } | 195 } |
| 195 | 196 |
| 196 void GetMacAddressCallback(const DeviceId::IdCallback& callback, | 197 void GetMacAddressCallback(const DeviceId::IdCallback& callback, |
| 197 const std::string& mac_address) { | 198 const std::string& mac_address) { |
| 198 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 199 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 199 | 200 |
| 200 std::string machine_id = GetRlzMachineId(); | 201 std::string machine_id = GetRlzMachineId(); |
| 201 if (mac_address.empty() || machine_id.empty()) { | 202 if (mac_address.empty() || machine_id.empty()) { |
| 202 callback.Run(""); | 203 callback.Run(""); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 217 content::BrowserThread::PostTask( | 218 content::BrowserThread::PostTask( |
| 218 content::BrowserThread::FILE, | 219 content::BrowserThread::FILE, |
| 219 FROM_HERE, | 220 FROM_HERE, |
| 220 base::Bind(GetMacAddress, | 221 base::Bind(GetMacAddress, |
| 221 base::Bind(DeviceId::IsValidMacAddress), | 222 base::Bind(DeviceId::IsValidMacAddress), |
| 222 base::Bind(GetMacAddressCallback, callback))); | 223 base::Bind(GetMacAddressCallback, callback))); |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace api | 226 } // namespace api |
| 226 } // namespace extensions | 227 } // namespace extensions |
| OLD | NEW |