Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/media/media_stream_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1963 const url::Origin& security_origin, | 1963 const url::Origin& security_origin, |
| 1964 const std::string& device_guid, | 1964 const std::string& device_guid, |
| 1965 const std::string& raw_unique_id) { | 1965 const std::string& raw_unique_id) { |
| 1966 DCHECK(!raw_unique_id.empty()); | 1966 DCHECK(!raw_unique_id.empty()); |
| 1967 std::string guid_from_raw_device_id = | 1967 std::string guid_from_raw_device_id = |
| 1968 GetHMACForMediaDeviceID(salt, security_origin, raw_unique_id); | 1968 GetHMACForMediaDeviceID(salt, security_origin, raw_unique_id); |
| 1969 return guid_from_raw_device_id == device_guid; | 1969 return guid_from_raw_device_id == device_guid; |
| 1970 } | 1970 } |
| 1971 | 1971 |
| 1972 // static | 1972 // static |
| 1973 bool MediaStreamManager::IsValidDeviceId(const std::string& device_id) { | |
|
o1ka
2016/11/03 10:07:22
What is the reason for MediaStreaMgr to expose it?
Max Morin
2016/11/10 14:59:52
I figured I'd put it with the rest of the hashing-
| |
| 1974 constexpr int hash_size = 64; // 32 bytes * 2 char/byte hex encoding | |
| 1975 if (media::AudioDeviceDescription::IsDefaultDevice(device_id) || | |
| 1976 device_id == media::AudioDeviceDescription::kCommunicationsDeviceId) | |
| 1977 return true; | |
| 1978 | |
| 1979 if (device_id.length() != hash_size) | |
| 1980 return false; | |
| 1981 | |
| 1982 return std::all_of(device_id.cbegin(), device_id.cend(), [](const char& c) { | |
| 1983 return base::IsAsciiLower(c) || base::IsAsciiDigit(c); | |
| 1984 }); | |
| 1985 } | |
| 1986 | |
| 1987 // static | |
| 1973 bool MediaStreamManager::IsOriginAllowed(int render_process_id, | 1988 bool MediaStreamManager::IsOriginAllowed(int render_process_id, |
| 1974 const url::Origin& origin) { | 1989 const url::Origin& origin) { |
| 1975 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( | 1990 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( |
| 1976 render_process_id, origin.GetURL())) { | 1991 render_process_id, origin.GetURL())) { |
| 1977 LOG(ERROR) << "MSM: Renderer requested a URL it's not allowed to use."; | 1992 LOG(ERROR) << "MSM: Renderer requested a URL it's not allowed to use."; |
| 1978 return false; | 1993 return false; |
| 1979 } | 1994 } |
| 1980 | 1995 |
| 1981 return true; | 1996 return true; |
| 1982 } | 1997 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2043 } | 2058 } |
| 2044 } | 2059 } |
| 2045 } | 2060 } |
| 2046 | 2061 |
| 2047 void MediaStreamManager::SetGenerateStreamCallbackForTesting( | 2062 void MediaStreamManager::SetGenerateStreamCallbackForTesting( |
| 2048 GenerateStreamTestCallback test_callback) { | 2063 GenerateStreamTestCallback test_callback) { |
| 2049 generate_stream_test_callback_ = test_callback; | 2064 generate_stream_test_callback_ = test_callback; |
| 2050 } | 2065 } |
| 2051 | 2066 |
| 2052 } // namespace content | 2067 } // namespace content |
| OLD | NEW |