11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file.
41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)//
51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Media device IDs come in two flavors: The machine-wide unique ID of
61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// the device, which is what we use on the browser side, and one-way
71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// hashes over the unique ID and a security origin, which we provide
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// to code on the renderer side as per-security-origin IDs.
91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_MEDIA_DEVICE_ID_H_
111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_MEDIA_DEVICE_ID_H_
121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include <string>
141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/common/content_export.h"
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/public/browser/resource_context.h"
175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "content/public/common/media_stream_request.h"
181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "url/gurl.h"
191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace content {
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Generates a one-way hash of a device's unique ID usable by one
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// particular security origin.
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)CONTENT_EXPORT std::string GetHMACForMediaDeviceID(
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const ResourceContext::SaltCallback& sc,
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    const GURL& security_origin,
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    const std::string& raw_unique_id);
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Convenience method to check if |device_guid| is an HMAC of
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// |raw_device_id| for |security_origin|.
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)CONTENT_EXPORT bool DoesMediaDeviceIDMatchHMAC(
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const ResourceContext::SaltCallback& sc,
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    const GURL& security_origin,
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    const std::string& device_guid,
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    const std::string& raw_unique_id);
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuCONTENT_EXPORT bool GetMediaDeviceIDForHMAC(
385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    MediaStreamType stream_type,
395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    const ResourceContext::SaltCallback& rc,
405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    const GURL& security_origin,
415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    const std::string& source_id,
425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    std::string* device_id);
435c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}  // namespace content
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif  // CONTENT_PUBLIC_BROWSER_MEDIA_DEVICE_ID_H_
47