public static String locateChrome(){
  String os=Platform.getOS();
  List<File> locationsToCheck=new ArrayList<File>();
  if (Platform.OS_WIN32.equals(os)) {
    String[] envVariables=new String[]{"home","userprofile","home","userprofile","ProgramFiles(X86)","ProgramFiles"};
    String[] appendedPaths=new String[]{"\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe","\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe","\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe","\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe","\\Google\\Chrome\\Application\\chrome.exe","\\Google\\Chrome\\Application\\chrome.exe"};
    assert envVariables.length == appendedPaths.length;
    for (int i=0; i < envVariables.length; i++) {
      String envValue=System.getenv(envVariables[i]);
      if (envValue != null) {
        locationsToCheck.add(new File(envValue + appendedPaths[i]));
      }
    }
  }
 else   if (Platform.OS_MACOSX.equals(os)) {
    locationsToCheck.add(new File("/Applications/ChromeWithSpeedTracer.app"));
    String homeDir=System.getenv("HOME");
    if (homeDir != null) {
      locationsToCheck.add(new File(homeDir + "/Applications/ChromeWithSpeedTracer.app"));
    }
  }
 else {
    locationsToCheck.add(new File("/usr/bin/chrome"));
    locationsToCheck.add(new File("/usr/local/bin/chrome"));
    locationsToCheck.add(new File("/usr/bin/google-chrome"));
    locationsToCheck.add(new File("/usr/local/bin/google-chrome"));
    locationsToCheck.add(new File("/usr/bin/chromium"));
    locationsToCheck.add(new File("/usr/local/bin/chromium"));
    locationsToCheck.add(new File("/usr/bin/chromium-browser"));
    locationsToCheck.add(new File("/usr/local/bin/chromium-browser"));
  }
  for (  File location : locationsToCheck) {
    if (location.exists() && (Platform.OS_MACOSX.equals(os) || location.isFile())) {
      return location.getAbsolutePath();
    }
  }
  return null;
}

public static String locateChrome ( ) { String os = Platform . getOS ( ) ; List < File > locationsToCheck = new ArrayList < File > ( ) ; if ( Platform . OS_WIN32 . equals ( os ) ) { String [ ] envVariables = new String [ ] { "home" , "userprofile" , "home" , "userprofile" , "ProgramFiles(X86)" , "ProgramFiles" } ; String [ ] appendedPaths = new String [ ] { "\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe" , "\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe" , "\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe" , "\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe" , "\\Google\\Chrome\\Application\\chrome.exe" , "\\Google\\Chrome\\Application\\chrome.exe" } ; assert envVariables . length == appendedPaths . length ; for ( int i = 0 ; i < envVariables . length ; i ++ ) { String envValue = System . getenv ( envVariables [ i ] ) ; if ( envValue != null ) { locationsToCheck . add ( new File ( envValue + appendedPaths [ i ] ) ) ; } } } else if ( Platform . OS_MACOSX . equals ( os ) ) { locationsToCheck . add ( new File ( "/Applications/ChromeWithSpeedTracer.app" ) ) ; String homeDir = System . getenv ( "HOME" ) ; if ( homeDir != null ) { locationsToCheck . add ( new File ( homeDir + "/Applications/ChromeWithSpeedTracer.app" ) ) ; } } else { locationsToCheck . add ( new File ( "/usr/bin/chrome" ) ) ; locationsToCheck . add ( new File ( "/usr/local/bin/chrome" ) ) ; locationsToCheck . add ( new File ( "/usr/bin/google-chrome" ) ) ; locationsToCheck . add ( new File ( "/usr/local/bin/google-chrome" ) ) ; locationsToCheck . add ( new File ( "/usr/bin/chromium" ) ) ; locationsToCheck . add ( new File ( "/usr/local/bin/chromium" ) ) ; locationsToCheck . add ( new File ( "/usr/bin/chromium-browser" ) ) ; locationsToCheck . add ( new File ( "/usr/local/bin/chromium-browser" ) ) ; } for ( File location : locationsToCheck ) { if ( location . exists ( ) && ( Platform . OS_MACOSX . equals ( os ) || location . isFile ( ) ) ) { return location . getAbsolutePath ( ) ; } } return null ; }
locates a chrome installation in one of the default installation directories .
