Both browsers present an API to initiate an extension/add-on install. You can actually use those to differentiate between browsers.
First, detection:
if(window.InstallTrigger) {
// This is Firefox
} else if(window.chrome && window.chrome.webstore) {
// This is Chrome
} else {
// Something else
}
Next, you want to trigger the installation. This probably requires a user gesture - so present a button/link for the user to click.
I'm not an expert on Firefox, but here's the relevant documentation. I don't know how that interacts with Gallery, if you have the add-on published there.
For Chrome, you need to link the Web Store item to the site in question to use inline install. Once that is done, you can follow the procedure from relevant documentation.
Consider that you also want to detect if the extension is already installed. To do that, you need to expose something visible to the page, or modify the page, from the extension.
Again, I'm not an expert on FF, but here's the canonical Chrome question.