2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2023 ,  Luke  Wilde  < lukew @ serenityos . org > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/Bindings/Intrinsics.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-27 12:09:58 +12:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibWeb/Bindings/PluginPrototype.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/Plugin.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/Scripting/Environments.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/HTML/Window.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibWeb/Page/Page.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace  Web : : HTML  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC_DEFINE_ALLOCATOR ( Plugin ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-19 19:47:52 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 13:14:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Plugin : : Plugin ( JS : : Realm &  realm ,  String  name ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-09 16:05:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    :  Bindings : : PlatformObject ( realm ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 13:14:51 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    ,  m_name ( move ( name ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-09 16:05:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    m_legacy_platform_object_flags  =  LegacyPlatformObjectFlags  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        . supports_indexed_properties  =  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        . supports_named_properties  =  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        . has_legacy_unenumerable_named_properties_interface_extended_attribute  =  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Plugin : : ~ Plugin ( )  =  default ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 08:41:28 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								void  Plugin : : initialize ( JS : : Realm &  realm ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 13:13:08 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    WEB_SET_PROTOTYPE_FOR_INTERFACE ( Plugin ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 16:22:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Base : : initialize ( realm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/system-state.html#dom-plugin-name
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								String  const &  Plugin : : name ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The Plugin interface's name getter steps are to return this's name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  m_name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/system-state.html#dom-plugin-description
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 11:12:38 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								String  Plugin : : description ( )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The Plugin interface's description getter steps are to return "Portable Document Format".
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 11:12:38 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    static  String  description_string  =  " Portable Document Format " _string ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    return  description_string ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/system-state.html#dom-plugin-filename
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 11:12:38 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								String  Plugin : : filename ( )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The Plugin interface's filename getter steps are to return "internal-pdf-viewer".
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 11:12:38 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    static  String  filename_string  =  " internal-pdf-viewer " _string ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    return  filename_string ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewing-support:support-named-properties-3
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-24 20:59:00 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Vector < FlyString >  Plugin : : supported_property_names ( )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The Plugin interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer mime types. Otherwise, they are the empty list.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 09:12:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  const &  window  =  as < HTML : : Window > ( HTML : : relevant_global_object ( * this ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-15 20:33:16 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! window . page ( ) . pdf_viewer_supported ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-mime-types
 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-24 20:59:00 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    static  Vector < FlyString >  const  mime_types  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        " application/pdf " _fly_string , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        " text/pdf " _fly_string , 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  mime_types ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/system-state.html#dom-plugin-length
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								size_t  Plugin : : length ( )  const 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The Plugin interface's length getter steps are to return this's relevant global object's PDF viewer mime type objects's size.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 09:12:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto &  window  =  as < HTML : : Window > ( HTML : : relevant_global_object ( * this ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    return  window . pdf_viewer_mime_type_objects ( ) . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// https://html.spec.whatwg.org/multipage/system-state.html#dom-plugin-item
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ptr < MimeType >  Plugin : : item ( u32  index )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let mimeTypes be this's relevant global object's PDF viewer mime type objects.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 09:12:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto &  window  =  as < HTML : : Window > ( HTML : : relevant_global_object ( * this ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    auto  mime_types  =  window . pdf_viewer_mime_type_objects ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 17:15:00 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 2. If index < mimeTypes's size, then return mimeTypes[index].
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if  ( index  <  mime_types . size ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  mime_types [ index ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. Return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ptr < MimeType >  Plugin : : named_item ( FlyString  const &  name )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. For each MimeType mimeType of this's relevant global object's PDF viewer mime type objects: if mimeType's type is name, then return mimeType.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 09:12:05 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto &  window  =  as < HTML : : Window > ( HTML : : relevant_global_object ( * this ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    auto  mime_types  =  window . pdf_viewer_mime_type_objects ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( auto &  mime_type  :  mime_types )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( mime_type - > type ( )  = =  name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  mime_type ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Return null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 18:15:51 +12:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Optional < JS : : Value >  Plugin : : item_value ( size_t  index )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  return_value  =  item ( index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! return_value ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 18:15:51 +12:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    return  return_value . ptr ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 17:36:10 +12:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								JS : : Value  Plugin : : named_item_value ( FlyString  const &  name )  const 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-08 13:16:50 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  return_value  =  named_item ( name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 00:23:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! return_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  JS : : js_null ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  return_value . ptr ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}