chromium/chrome/updater/installer.h

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

#ifndef CHROME_UPDATER_INSTALLER_H_
#define CHROME_UPDATER_INSTALLER_H_

#include <memory>
#include <optional>
#include <string>

#include "base/files/file_path.h"
#include "base/functional/callback_forward.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/version.h"
#include "build/build_config.h"
#include "chrome/updater/persisted_data.h"
#include "chrome/updater/update_service.h"
#include "chrome/updater/updater_scope.h"
#include "components/crx_file/crx_verifier.h"
#include "components/update_client/update_client.h"

namespace base {
class TimeDelta;
}

namespace updater {

struct AppInfo {};

InstallProgressCallback;

InstallerResult;

// Runs an app installer.
//   The file `server_install_data` contains additional application-specific
// install configuration parameters extracted either from the update response or
// the app manifest.
InstallerResult RunApplicationInstaller(
    const AppInfo& app_info,
    const base::FilePath& installer_path,
    const std::string& install_args,
    const std::optional<base::FilePath>& server_install_data,
    bool usage_stats_enabled,
    const base::TimeDelta& timeout,
    InstallProgressCallback progress_callback);

// Retrieves the value of `keyname` from `path` (a plist, on macOS). If the
// file does not exist, or the key does not exist, or the key or path are
// empty, or the platform does not support this functionality (Windows, Linux),
// `default_value` is returned.
std::string LookupString(const base::FilePath& path,
                         const std::string& keyname,
                         const std::string& default_value);
base::Version LookupVersion(const base::FilePath& path,
                            const std::string& keyname,
                            const base::Version& default_value);

// Manages the install of one application. Some of the functions of this
// class are blocking and can't be invoked on the main sequence.
//
// If the application installer completes with success, then the following
// post conditions are true: |update_client| updates persisted data in prefs,
// the CRX is installed in a versioned directory in apps/app_id/version,
// the application is considered to be registered for updates, and the
// application installed version matches the version recorded in prefs.
//
// If installing the CRX fails, or the installer fails, then prefs is not
// going to be updated. There will be some files left on the file system, which
// are going to be cleaned up next time the installer runs.
//
// Install directories not matching the |pv| version are lazy-deleted.
class Installer final : public update_client::CrxInstaller {};

}  // namespace updater

#endif  // CHROME_UPDATER_INSTALLER_H_