How to change Search Engine from Add-On?

Our team is developing an add-on, which among other things, would add a search engine to user’s search engine list. We are using “chrome_settings_overrides” for this purpose and works well.
To my understanding, this way the engine would be set once and at install time of Add-On. We want to have a way to trigger the same from Add-On’s popup, not at install time, i.e. Change search engine when user explicitly clicks/adds/agrees from Add-On’s UI. Is this possible to do the change this way instead of one time during installation?

Can you use the method that a website would use:

window.external.AddSearchProvider(engineURL);

This page uses that function, if you need an example: https://www.userchrome.org/yahooxml.html