chromium/chrome/browser/web_applications/preinstalled_web_app_config_utils.cc

// Copyright 2022 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/browser/web_applications/preinstalled_web_app_config_utils.h"

#include "base/command_line.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_switches.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/common/chrome_paths_lacros.h"
#endif  // BUILDFLAG(IS_CHROMEOS_LACROS)

namespace web_app {

namespace {

const base::FilePath* g_config_dir_for_testing =;

#if BUILDFLAG(IS_CHROMEOS_ASH)
// The sub-directory of the extensions directory in which to scan for external
// web apps (as opposed to external extensions or external ARC apps).
const base::FilePath::CharType kWebAppsSubDirectory[] =
    FILE_PATH_LITERAL("web_apps");
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

#if BUILDFLAG(IS_CHROMEOS_LACROS)
base::FilePath GetPreinstalledWebAppConfigDirFromDefaultPaths(
    Profile* profile) {
  if (g_config_dir_for_testing) {
    return *g_config_dir_for_testing;
  }

  base::FilePath web_apps_dir;
  if (chrome::GetPreinstalledWebAppConfigPath(&web_apps_dir))
    return web_apps_dir;
  return base::FilePath();
}

base::FilePath GetPreinstalledWebAppExtraConfigDirFromDefaultPaths(
    Profile* profile) {
  base::FilePath extra_web_apps_dir;
  if (chrome::GetPreinstalledWebAppExtraConfigPath(&extra_web_apps_dir))
    return extra_web_apps_dir;
  return base::FilePath();
}
#endif  // BUILDFLAG(IS_CHROMEOS_LACROS)

}  // namespace

const base::FilePath* GetPreinstalledWebAppConfigDirForTesting() {}

void SetPreinstalledWebAppConfigDirForTesting(
    const base::FilePath* config_dir) {}

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
base::FilePath GetPreinstalledWebAppConfigDirFromCommandLine(Profile* profile) {}

base::FilePath GetPreinstalledWebAppExtraConfigDirFromCommandLine(
    Profile* profile) {}
#endif  // !BUILDFLAG(IS_CHROMEOS_LACROS)

base::FilePath GetPreinstalledWebAppConfigDir(Profile* profile) {}

base::FilePath GetPreinstalledWebAppExtraConfigDir(Profile* profile) {}

}  // namespace web_app