mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:52:44 +00:00 
			
		
		
		
	 7966fc4780
			
		
	
	
		7966fc4780
		
	
	
	
	
		
			
			The spec defines a Permissions Policy to control some browser behaviors on a per-origin basis. Management of these permissions live in their own spec: https://w3c.github.io/webappsec-permissions-policy/ This implements a somewhat ad-hoc Permissions Policy for autoplaying media elements. We will need to implement the entire policy spec for this to be more general.
		
			
				
	
	
		
			36 lines
		
	
	
	
		
			743 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
	
		
			743 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Forward.h>
 | |
| #include <AK/Variant.h>
 | |
| #include <AK/Vector.h>
 | |
| #include <LibWeb/Forward.h>
 | |
| #include <LibWeb/PermissionsPolicy/Decision.h>
 | |
| 
 | |
| namespace Web::PermissionsPolicy {
 | |
| 
 | |
| class AutoplayAllowlist {
 | |
| public:
 | |
|     static AutoplayAllowlist& the();
 | |
| 
 | |
|     Decision is_allowed_for_origin(DOM::Document const&, HTML::Origin const&) const;
 | |
| 
 | |
|     void enable_globally();
 | |
|     ErrorOr<void> enable_for_origins(ReadonlySpan<String>);
 | |
| 
 | |
| private:
 | |
|     AutoplayAllowlist();
 | |
|     ~AutoplayAllowlist();
 | |
| 
 | |
|     using Patterns = Vector<HTML::Origin>;
 | |
|     struct Global { };
 | |
| 
 | |
|     Optional<Variant<Patterns, Global>> m_allowlist;
 | |
| };
 | |
| 
 | |
| }
 |