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