#include "chrome/test/chromedriver/chrome/chrome_finder.h"
#include <stddef.h>
#include <string>
#include <vector>
#include "base/base_paths.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/test/chromedriver/constants/version.h"
#if BUILDFLAG(IS_WIN)
#include "base/base_paths_win.h"
#include "base/win/windows_version.h"
#endif
namespace {
#if BUILDFLAG(IS_WIN)
void GetApplicationDirs(std::vector<base::FilePath>* locations) {
std::vector<base::FilePath> installation_locations;
base::FilePath local_app_data, program_files, program_files_x86,
program_files_64_32;
if (base::PathService::Get(base::DIR_LOCAL_APP_DATA, &local_app_data))
installation_locations.push_back(local_app_data);
if (base::PathService::Get(base::DIR_PROGRAM_FILES, &program_files))
installation_locations.push_back(program_files);
if (base::PathService::Get(base::DIR_PROGRAM_FILESX86, &program_files_x86))
installation_locations.push_back(program_files_x86);
if (base::PathService::Get(base::DIR_PROGRAM_FILES6432, &program_files_64_32))
installation_locations.push_back(program_files_64_32);
for (size_t i = 0; i < installation_locations.size(); ++i) {
locations->push_back(
installation_locations[i].Append(L"Google\\Chrome\\Application"));
}
for (size_t i = 0; i < installation_locations.size(); ++i) {
locations->push_back(installation_locations[i].Append(
L"Google\\Chrome for Testing\\Application"));
}
for (size_t i = 0; i < installation_locations.size(); ++i) {
locations->push_back(
installation_locations[i].Append(L"Chromium\\Application"));
}
}
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
void GetApplicationDirs(std::vector<base::FilePath>* locations) { … }
#elif BUILDFLAG(IS_ANDROID)
void GetApplicationDirs(std::vector<base::FilePath>* locations) {
}
#endif
void GetPathsFromEnvironment(std::vector<base::FilePath>* paths) { … }
std::vector<base::FilePath> GetChromeProgramNames() { … }
std::vector<base::FilePath> GetHeadlessShellProgramNames() { … }
}
namespace internal {
bool FindExe(
const base::RepeatingCallback<bool(const base::FilePath&)>& exists_func,
const std::vector<base::FilePath>& rel_paths,
const std::vector<base::FilePath>& locations,
base::FilePath& out_path) { … }
}
#if BUILDFLAG(IS_MAC)
void GetApplicationDirs(std::vector<base::FilePath>* locations);
#endif
bool FindBrowser(const std::string& browser_name, base::FilePath& browser_exe) { … }
bool FindBrowser(
const std::string& browser_name,
const base::RepeatingCallback<bool(const base::FilePath&)>& exists_func,
base::FilePath& browser_exe) { … }