blob: a9d6461335f2d9cfbd112213d01c35e717502c95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_MUSIC_MANAGER_PRIVATE_DEVICE_ID_H_
#define CHROME_BROWSER_EXTENSIONS_API_MUSIC_MANAGER_PRIVATE_DEVICE_ID_H_
#include <string>
#include "base/bind.h"
namespace extensions {
namespace api {
class DeviceId {
public:
typedef base::Callback<void(const std::string&)> IdCallback;
// Calls |callback| with a unique device identifier as argument. The device
// identifier has the following characteristics:
// 1. It is shared across users of a device.
// 2. It is resilient to device reboots.
// 3. It can be reset in *some* way by the user. In Particular, it can *not*
// be based only on a MAC address of a physical device.
// The specific implementation varies across platforms, some of them requiring
// a round trip to the IO or FILE thread. "callback" will always be called on
// the UI thread though (sometimes directly if the implementation allows
// running on the UI thread).
// The returned value is HMAC_SHA256(|raw_device_id|, |extension_id|), so that
// the actual device identifier value is not exposed directly to the caller.
static void GetDeviceId(const std::string& extension_id,
const IdCallback& callback);
private:
// Platform specific implementation of "raw" machine ID retrieval.
static void GetRawDeviceId(const IdCallback& callback);
// On some platforms, part of the machine ID is the MAC address. This function
// is shared across platforms to filter out MAC addresses that have been
// identified as invalid, i.e. not unique. For example, some VM hosts assign a
// new MAC addresses at each reboot.
static bool IsValidMacAddress(const void* bytes, size_t size);
};
} // namespace api
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_MUSIC_MANAGER_PRIVATE_DEVICE_ID_H_
|