chromium/chrome/common/chrome_paths.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/chrome_paths.h"

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/system/sys_info.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
#include "media/media_buildflags.h"
#include "ppapi/buildflags/buildflags.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/path_utils.h"
#include "base/base_paths_android.h"
// ui/base must only be used on Android. See BUILD.gn for dependency info.
#include "ui/base/ui_base_paths.h"  // nogncheck
#endif

#if BUILDFLAG(IS_MAC)
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#endif

#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_OPENBSD)
#include "components/policy/core/common/policy_paths.h"
#endif

#if BUILDFLAG(IS_WIN)
#include "base/win/registry.h"
#endif

#if BUILDFLAG(ENABLE_WIDEVINE)
#include "third_party/widevine/cdm/widevine_cdm_common.h"  // nogncheck
#endif

#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/crosapi/cpp/crosapi_constants.h"  // nogncheck
#include "chromeos/lacros/lacros_paths.h"
#include "chromeos/startup/startup.h"  // nogncheck
#endif

namespace {

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// The path to the external extension <id>.json files.
// /usr/share seems like a good choice, see: http://www.pathname.com/fhs/
const base::FilePath::CharType kFilepathSinglePrefExtensions[] =FILE_PATH_LITERAL("/usr/share/google-chrome/extensions");
#else
    FILE_PATH_LITERAL("/usr/share/chromium/extensions");
#endif  // BUILDFLAG(GOOGLE_CHROME_BRANDING)

#endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)

#if BUILDFLAG(ENABLE_WIDEVINE)
// The name of the hint file that tells the latest component updated Widevine
// CDM directory. This file name should not be changed as otherwise existing
// Widevine CDMs might not be loaded.
const base::FilePath::CharType kComponentUpdatedWidevineCdmHint[] =
    FILE_PATH_LITERAL("latest-component-updated-widevine-cdm");
#endif  // BUILDFLAG(ENABLE_WIDEVINE)

#if BUILDFLAG(IS_CHROMEOS_ASH)
const base::FilePath::CharType kChromeOSTPMFirmwareUpdateLocation[] =
    FILE_PATH_LITERAL("/run/tpm_firmware_update_location");
const base::FilePath::CharType kChromeOSTPMFirmwareUpdateSRKVulnerableROCA[] =
    FILE_PATH_LITERAL("/run/tpm_firmware_update_srk_vulnerable_roca");
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
const base::FilePath::CharType kChromeOSCryptohomeMountRoot[] =
    FILE_PATH_LITERAL("/home/user");
#else
const base::FilePath::CharType kFakeCryptohomeMountRootDirname[] =
    FILE_PATH_LITERAL(".home_user");
#endif  // BUILDFLAG(IS_CHROMEOS_DEVICE)

bool GetChromeOsCrdDataDirInternal(base::FilePath* result,
                                   bool* should_be_created) {
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
  *result = base::FilePath::FromASCII("/run/crd");
  // The directory is created by ChromeOS (since we do not have the permissions
  // to create anything in /run).
  *should_be_created = false;
  return true;
#else
  // On glinux-ChromeOS builds `/run/` doesn't exist, so we simply use the temp
  // directory.
  base::FilePath temp_directory;
  if (!base::PathService::Get(base::DIR_TEMP, &temp_directory)) {
    return false;
  }

  *result = temp_directory.Append(FILE_PATH_LITERAL("crd"));
  *should_be_created = true;
  return true;
#endif  // BUILDFLAG(IS_CHROMEOS_DEVICE)
}

#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

#if BUILDFLAG(IS_CHROMEOS_LACROS)
const base::FilePath::CharType kLacrosLogDirectory[] =
    FILE_PATH_LITERAL("/var/log/lacros");
#endif  // BUILDFLAG(IS_CHROMEOS_LACROS)

base::FilePath& GetInvalidSpecifiedUserDataDirInternal() {}

// Gets the path for internal plugins.
bool GetInternalPluginsDirectory(base::FilePath* result) {}

// Gets the path for bundled implementations of components. Note that these
// implementations should not be used if higher-versioned component-updated
// implementations are available in DIR_USER_DATA.
bool GetComponentDirectory(base::FilePath* result) {}

}  // namespace

namespace chrome {

bool PathProvider(int key, base::FilePath* result) {}

// This cannot be done as a static initializer sadly since Visual Studio will
// eliminate this object file if there is no direct entry point into it.
void RegisterPathProvider() {}

void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir) {}

const base::FilePath& GetInvalidSpecifiedUserDataDir() {}

}  // namespace chrome