Commit af2bd3c7 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Add the base for the intervention policy database component installer.

This doesn't do anything yet (this component isn't yet published by
Omaha anyway), it's just all the boilerplate required to setup the
component installer, this will then be connected to c/b/rc and the
server side work will be done later (once the Chrome part is done).

Bug: 773383
Change-Id: I19802d63934b72ce812abe9d89d30d6f80a52258
Reviewed-on: https://chromium-review.googlesource.com/1100342Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568030}
parent 30326986
......@@ -288,6 +288,8 @@ jumbo_split_static_library("browser") {
"component_updater/crl_set_component_installer.h",
"component_updater/file_type_policies_component_installer.cc",
"component_updater/file_type_policies_component_installer.h",
"component_updater/intervention_policy_database_component_installer.cc",
"component_updater/intervention_policy_database_component_installer.h",
"component_updater/mei_preload_component_installer.cc",
"component_updater/mei_preload_component_installer.h",
"component_updater/optimization_hints_component_installer.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/component_updater/intervention_policy_database_component_installer.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "components/component_updater/component_updater_paths.h"
#include "components/component_updater/component_updater_service.h"
#include "components/crx_file/id_util.h"
using component_updater::ComponentUpdateService;
namespace {
// The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: copjbmjbojbakpaedmpkhmiplmmehfck
const uint8_t kInterventionPolicyDatabasePublicKeySHA256[32] = {
0x2e, 0xf9, 0x1c, 0x91, 0xe9, 0x10, 0xaf, 0x04, 0x3c, 0xfa, 0x7c,
0x8f, 0xbc, 0xc4, 0x75, 0x2a, 0x48, 0x9a, 0x64, 0x74, 0xc6, 0xda,
0xb7, 0xb9, 0xdf, 0x5f, 0x51, 0x3e, 0x50, 0x39, 0x04, 0xab};
// The name of the component, used in the chrome://components page.
const char kInterventionPolicyDatabaseComponentName[] =
"Intervention Policy Database";
// The name of the database file inside of an installation of this component.
const base::FilePath::CharType kInterventionPolicyDatabaseBinaryPbFileName[] =
FILE_PATH_LITERAL("intervention_policy_database.pb");
} // namespace
namespace component_updater {
bool InterventionPolicyDatabaseComponentInstallerPolicy::
SupportsGroupPolicyEnabledComponentUpdates() const {
return false;
}
bool InterventionPolicyDatabaseComponentInstallerPolicy::
RequiresNetworkEncryption() const {
// Public data is delivered via this component, no need for encryption.
return false;
}
update_client::CrxInstaller::Result
InterventionPolicyDatabaseComponentInstallerPolicy::OnCustomInstall(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) {
return update_client::CrxInstaller::Result(0);
}
void InterventionPolicyDatabaseComponentInstallerPolicy::OnCustomUninstall() {}
// Called during startup and installation before ComponentReady().
bool InterventionPolicyDatabaseComponentInstallerPolicy::VerifyInstallation(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const {
return base::PathExists(
install_dir.Append(kInterventionPolicyDatabaseBinaryPbFileName));
}
// NOTE: This is always called on the main UI thread. It is called once every
// startup to notify of an already installed component, and may be called
// repeatedly after that every time a new component is ready.
void InterventionPolicyDatabaseComponentInstallerPolicy::ComponentReady(
const base::Version& version,
const base::FilePath& install_dir,
std::unique_ptr<base::DictionaryValue> manifest) {
// TODO(sebmarchand): Implement this.
}
base::FilePath
InterventionPolicyDatabaseComponentInstallerPolicy::GetRelativeInstallDir()
const {
return base::FilePath(FILE_PATH_LITERAL("InterventionPolicyDatabase"));
}
void InterventionPolicyDatabaseComponentInstallerPolicy::GetHash(
std::vector<uint8_t>* hash) const {
hash->assign(kInterventionPolicyDatabasePublicKeySHA256,
kInterventionPolicyDatabasePublicKeySHA256 +
base::size(kInterventionPolicyDatabasePublicKeySHA256));
}
std::string InterventionPolicyDatabaseComponentInstallerPolicy::GetName()
const {
return kInterventionPolicyDatabaseComponentName;
}
update_client::InstallerAttributes
InterventionPolicyDatabaseComponentInstallerPolicy::GetInstallerAttributes()
const {
return update_client::InstallerAttributes();
}
std::vector<std::string>
InterventionPolicyDatabaseComponentInstallerPolicy::GetMimeTypes() const {
return std::vector<std::string>();
}
void RegisterInterventionPolicyDatabaseComponent(ComponentUpdateService* cus) {
std::unique_ptr<ComponentInstallerPolicy> policy(
new InterventionPolicyDatabaseComponentInstallerPolicy());
auto installer = base::MakeRefCounted<ComponentInstaller>(std::move(policy));
installer->Register(cus, base::OnceClosure());
}
} // namespace component_updater
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_COMPONENT_UPDATER_INTERVENTION_POLICY_DATABASE_COMPONENT_INSTALLER_H_
#define CHROME_BROWSER_COMPONENT_UPDATER_INTERVENTION_POLICY_DATABASE_COMPONENT_INSTALLER_H_
#include "components/component_updater/component_installer.h"
namespace component_updater {
class ComponentUpdateService;
// Component for receiving the intervention policy database. The database
// consists in a proto, defined in
// chrome/browser/resource_coordinator/intervention_policy_database.proto.
class InterventionPolicyDatabaseComponentInstallerPolicy
: public ComponentInstallerPolicy {
public:
InterventionPolicyDatabaseComponentInstallerPolicy() = default;
~InterventionPolicyDatabaseComponentInstallerPolicy() override = default;
private:
// ComponentInstallerPolicy:
bool SupportsGroupPolicyEnabledComponentUpdates() const override;
bool RequiresNetworkEncryption() const override;
update_client::CrxInstaller::Result OnCustomInstall(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) override;
void OnCustomUninstall() override;
bool VerifyInstallation(const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const override;
void ComponentReady(const base::Version& version,
const base::FilePath& install_dir,
std::unique_ptr<base::DictionaryValue> manifest) override;
base::FilePath GetRelativeInstallDir() const override;
void GetHash(std::vector<uint8_t>* hash) const override;
std::string GetName() const override;
update_client::InstallerAttributes GetInstallerAttributes() const override;
std::vector<std::string> GetMimeTypes() const override;
DISALLOW_COPY_AND_ASSIGN(InterventionPolicyDatabaseComponentInstallerPolicy);
};
// Call once to make the component update service aware of the Intervention
// Policy Database component.
void RegisterInterventionPolicyDatabaseComponent(ComponentUpdateService* cus);
} // namespace component_updater
#endif // CHROME_BROWSER_COMPONENT_UPDATER_INTERVENTION_POLICY_DATABASE_COMPONENT_INSTALLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment