Skip to content

Instantly share code, notes, and snippets.

@t4kemyh4nd
Created October 15, 2023 05:49
Show Gist options
  • Save t4kemyh4nd/34daed00c7437c63b5ae5029691e6f0c to your computer and use it in GitHub Desktop.
Save t4kemyh4nd/34daed00c7437c63b5ae5029691e6f0c to your computer and use it in GitHub Desktop.
void AddToHomescreenInstaller::Install(
content::WebContents* web_contents,
const AddToHomescreenParams& params,
const base::RepeatingCallback<void(Event, const AddToHomescreenParams&)>&
event_callback) {
if (!web_contents) {
event_callback.Run(Event::INSTALL_FAILED, params);
return;
}
event_callback.Run(Event::INSTALL_STARTED, params);
switch (params.app_type) {
case AddToHomescreenParams::AppType::NATIVE:
InstallOrOpenNativeApp(web_contents, params, event_callback);
break;
case AddToHomescreenParams::AppType::WEBAPK:
WebappsClient::Get()->InstallWebApk(web_contents, params);
break;
case AddToHomescreenParams::AppType::SHORTCUT:
WebappsClient::Get()->InstallShortcut(web_contents, params);
break;
}
event_callback.Run(Event::INSTALL_REQUEST_FINISHED, params);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment