chromium/chrome/browser/extensions/external_provider_impl.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/browser/extensions/external_provider_impl.h"

#include <stddef.h>

#include <memory>
#include <set>
#include <string_view>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
#include "base/trace_event/trace_event.h"
#include "base/values.h"
#include "base/version.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_migrator.h"
#include "chrome/browser/extensions/external_component_loader.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/extensions/external_pref_loader.h"
#include "chrome/browser/extensions/forced_extensions/install_stage_tracker.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/web_applications/preinstalled_app_install_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "components/crx_file/id_util.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/external_install_info.h"
#include "extensions/browser/external_provider_interface.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "ui/base/l10n/l10n_util.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/chromeos/app_mode/kiosk_app_external_loader.h"
#include "chromeos/components/kiosk/kiosk_utils.h"
#include "chromeos/components/mgs/managed_guest_session_utils.h"
#endif  // BUIDLFLAG(IS_CHROMEOS)

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/arc_util.h"
#include "ash/constants/ash_paths.h"
#include "base/path_service.h"
#include "chrome/browser/ash/customization/customization_document.h"
#include "chrome/browser/ash/extensions/signin_screen_extensions_external_loader.h"
#include "chrome/browser/ash/login/demo_mode/demo_extensions_external_loader.h"
#include "chrome/browser/ash/login/demo_mode/demo_session.h"
#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
#include "chrome/browser/ash/policy/core/device_local_account_policy_service.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h"
#else
#include "chrome/browser/extensions/preinstalled_apps.h"
#include "components/policy/core/common/device_local_account_type.h"
#endif

#if BUILDFLAG(IS_WIN)
#include "chrome/browser/extensions/external_registry_loader_win.h"
#endif

#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/check_is_test.h"
#include "chrome/browser/lacros/app_mode/device_local_account_extension_installer_lacros.h"
#endif

BrowserThread;
ManifestLocation;

namespace extensions {

namespace {

#if BUILDFLAG(IS_CHROMEOS_ASH)

const char kCameraAppId[] = "hfhhnacclhffhdffklopdkcgdhifgngh";

// Certain pre-installed extensions are no longer needed on ARC devices as they
// were replaced by their ARC counterparts.
bool ShouldUninstallExtensionReplacedByArcApp(const std::string& extension_id) {
  if (!arc::IsArcAvailable())
    return false;

  if (extension_id == extension_misc::kGooglePlayBooksAppId ||
      extension_id == extension_misc::kGooglePlayMoviesAppId ||
      extension_id == extension_misc::kGooglePlayMusicAppId) {
    return true;
  }

  return false;
}

#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

}  // namespace

// Constants for keeping track of extension preferences in a dictionary.
const char ExternalProviderImpl::kInstallParam[] =;
const char ExternalProviderImpl::kExternalCrx[] =;
const char ExternalProviderImpl::kExternalVersion[] =;
const char ExternalProviderImpl::kExternalUpdateUrl[] =;
const char ExternalProviderImpl::kIsBookmarkApp[] =;
const char ExternalProviderImpl::kIsFromWebstore[] =;
const char ExternalProviderImpl::kKeepIfPresent[] =;
const char ExternalProviderImpl::kWasInstalledByOem[] =;
const char ExternalProviderImpl::kWebAppMigrationFlag[] =;
const char ExternalProviderImpl::kSupportedLocales[] =;
const char ExternalProviderImpl::kMayBeUntrusted[] =;
const char ExternalProviderImpl::kMinProfileCreatedByVersion[] =;
const char ExternalProviderImpl::kDoNotInstallForEnterprise[] =;

ExternalProviderImpl::ExternalProviderImpl(
    VisitorInterface* service,
    const scoped_refptr<ExternalLoader>& loader,
    Profile* profile,
    ManifestLocation crx_location,
    ManifestLocation download_location,
    int creation_flags)
    :{}

ExternalProviderImpl::~ExternalProviderImpl() {}

void ExternalProviderImpl::VisitRegisteredExtension() {}

void ExternalProviderImpl::SetPrefs(base::Value::Dict prefs) {}

void ExternalProviderImpl::TriggerOnExternalExtensionFound() {}

void ExternalProviderImpl::NotifyServiceOnExternalExtensionsFound() {}

void ExternalProviderImpl::UpdatePrefs(base::Value::Dict prefs) {}

void ExternalProviderImpl::RetrieveExtensionsFromPrefs(
    std::vector<ExternalInstallInfoUpdateUrl>* external_update_url_extensions,
    std::vector<ExternalInstallInfoFile>* external_file_extensions) {}

void ExternalProviderImpl::ServiceShutdown() {}

bool ExternalProviderImpl::IsReady() const {}

bool ExternalProviderImpl::HasExtension(
    const std::string& id) const {}

bool ExternalProviderImpl::GetExtensionDetails(
    const std::string& id,
    ManifestLocation* location,
    std::unique_ptr<base::Version>* version) const {}

bool ExternalProviderImpl::HandleMinProfileVersion(
    const base::Value::Dict& extension,
    const std::string& extension_id,
    std::set<std::string>* unsupported_extensions) {}

bool ExternalProviderImpl::HandleDoNotInstallForEnterprise(
    const base::Value::Dict& extension,
    const std::string& extension_id,
    std::set<std::string>* unsupported_extensions) {}

// static
void ExternalProviderImpl::CreateExternalProviders(
    VisitorInterface* service,
    Profile* profile,
    ProviderCollection* provider_list) {}

}  // namespace extensions