@@ -2310,5 +2310,58 @@ public void SetVibrancy(Vibrancy type)
23102310 ContractResolver = new CamelCasePropertyNamesContractResolver ( ) ,
23112311 NullValueHandling = NullValueHandling . Ignore
23122312 } ;
2313+
2314+ /// <summary>
2315+ /// Adds Chrome extension located at path, and returns extension's name.
2316+ /// The method will also not return if the extension's manifest is missing or incomplete.
2317+ /// Note: This API cannot be called before the ready event of the app module is emitted.
2318+ /// </summary>
2319+ /// <param name="path">Path to the Chrome extension</param>
2320+ /// <returns></returns>
2321+ public static Task < string > AddExtensionAsync ( string path )
2322+ {
2323+ var taskCompletionSource = new TaskCompletionSource < string > ( ) ;
2324+
2325+ BridgeConnector . Socket . On ( "browserWindow-addExtension-completed" , ( extensionname ) => {
2326+ BridgeConnector . Socket . Off ( "browserWindow-addExtension-completed" ) ;
2327+
2328+ taskCompletionSource . SetResult ( extensionname . ToString ( ) ) ;
2329+ } ) ;
2330+
2331+ BridgeConnector . Socket . Emit ( "browserWindowAddExtension" , path ) ;
2332+
2333+ return taskCompletionSource . Task ;
2334+ }
2335+
2336+ /// <summary>
2337+ /// Remove Chrome extension with the specified name.
2338+ /// Note: This API cannot be called before the ready event of the app module is emitted.
2339+ /// </summary>
2340+ /// <param name="name">Name of the Chrome extension to remove</param>
2341+ public static void RemoveExtension ( string name )
2342+ {
2343+ BridgeConnector . Socket . Emit ( "browserWindowRemoveExtension" , name ) ;
2344+ }
2345+
2346+ /// <summary>
2347+ /// The keys are the extension names and each value is an object containing name and version properties.
2348+ /// Note: This API cannot be called before the ready event of the app module is emitted.
2349+ /// </summary>
2350+ /// <returns></returns>
2351+ public static Task < ChromeExtensionInfo [ ] > GetExtensionsAsync ( )
2352+ {
2353+ var taskCompletionSource = new TaskCompletionSource < ChromeExtensionInfo [ ] > ( ) ;
2354+
2355+ BridgeConnector . Socket . On ( "browserWindow-getExtensions-completed" , ( extensionslist ) => {
2356+ BridgeConnector . Socket . Off ( "browserWindow-getExtensions-completed" ) ;
2357+ var chromeExtensionInfos = ( ( JArray ) extensionslist ) . ToObject < ChromeExtensionInfo [ ] > ( ) ;
2358+
2359+ taskCompletionSource . SetResult ( chromeExtensionInfos ) ;
2360+ } ) ;
2361+
2362+ BridgeConnector . Socket . Emit ( "browserWindowGetExtensions" ) ;
2363+
2364+ return taskCompletionSource . Task ;
2365+ }
23132366 }
23142367}
0 commit comments