import { isPresent } from 'polar-shared/src/Preconditions' ; import { Analytics } from "../../../web/js/analytics/Analytics" ; import { AppRuntime } from "polar-shared/src/util/AppRuntime" ; const EXTENSION_URL = "https://chrome.google.com/webstore/detail/jkfdkjomocoaljglgddnmhcbolldcafd" ; Deprecated export class ChromeExtensionInstallation { public static isChromeOrChromium ( ) { return navigator . userAgent . includes ( "Chrome" ) || navigator . userAgent . includes ( "Chromium" ) ; } public static isSupported ( ) { return AppRuntime . isBrowser ( ) && this . isChromeOrChromium ( ) ; } public static requiresInstall ( ) { return this . isSupported ( ) && ! localStorage . getItem ( "skip-extension" ) ; } public static isInstalled ( ) { const anyChrome = chrome ; if ( ! anyChrome ) { return false ; } const app = anyChrome . app ; if ( ! app ) { return false ; } return isPresent ( app . isInstalled ) && app . isInstalled ; } /**
     *
     * Trigger the online installation of the extension.
     */ public static doInstall ( successCallback , failureCallback ) { Analytics . event ( { category : 'chrome-extension' , action : 'inline-installation-triggered' } ) ; const handleSuccess = ( ) => { Analytics . event ( { category : 'chrome-extension-install-result' , action : 'install-successful' } ) ; successCallback ( ) ; } ; const handleFailure = ( error , errorCode ? ) => { Analytics . event ( { category : 'chrome-extension-install-result' , action : 'install-failed' } ) ; if ( errorCode ) { Analytics . event ( { category : 'chrome-extension-failures' , action : errorCode } ) ; } failureCallback ( error , errorCode ) ; } ; chrome . webstore . install ( EXTENSION_URL , handleSuccess , handleFailure ) ; } }