Commit a9e46b29 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[vr] Add VR assets component installer

Bug: 706150
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I3d4fd8eed952d0a22667d39de4e3186e0cb4db27
Reviewed-on: https://chromium-review.googlesource.com/782407Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518798}
parent 90115b4c
......@@ -3985,6 +3985,10 @@ split_static_library("browser") {
configs += [ "//third_party/gvr-android-sdk:libgvr_config" ]
}
sources += [
"component_updater/vr_assets_component_installer.cc",
"component_updater/vr_assets_component_installer.h",
]
deps += [ "//chrome/browser/vr:vr_common" ]
}
......
// Copyright 2017 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/vr_assets_component_installer.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/task_scheduler/post_task.h"
#include "base/version.h"
#include "chrome/browser/vr/assets.h"
#include "chrome/common/safe_browsing/file_type_policies.h"
#include "components/component_updater/component_updater_paths.h"
using component_updater::ComponentUpdateService;
namespace {
// The SHA256 of the SubjectPublicKeyInfo used to sign the extension.
// The extension id is: cjfkbpdpjpdldhclahpfgnlhpodlpnba
const uint8_t kPublicKeySHA256[32] = {
0x29, 0x5a, 0x1f, 0x3f, 0x9f, 0x3b, 0x37, 0x2b, 0x07, 0xf5, 0x6d,
0xb7, 0xfe, 0x3b, 0xfd, 0x10, 0xb6, 0x80, 0xf3, 0x66, 0x0d, 0xc3,
0xe2, 0x07, 0x25, 0x8d, 0x37, 0x85, 0x39, 0x51, 0x58, 0xcf};
const char kVrAssetsComponentName[] = "VR Assets";
const base::FilePath::CharType kRelativeInstallDir[] =
FILE_PATH_LITERAL("VrAssets");
} // namespace
namespace component_updater {
bool VrAssetsComponentInstallerTraits::
SupportsGroupPolicyEnabledComponentUpdates() const {
return false;
}
bool VrAssetsComponentInstallerTraits::RequiresNetworkEncryption() const {
return false;
}
update_client::CrxInstaller::Result
VrAssetsComponentInstallerTraits::OnCustomInstall(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) {
return update_client::CrxInstaller::Result(0);
}
void VrAssetsComponentInstallerTraits::OnCustomUninstall() {}
// Called during startup and installation before ComponentReady().
bool VrAssetsComponentInstallerTraits::VerifyInstallation(
const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const {
auto* version_value = manifest.FindKey("version");
if (!version_value || !version_value->is_string()) {
return false;
}
auto version_string = version_value->GetString();
base::Version version(version_string);
if (!version.IsValid() || version.components().size() != 2 ||
version.components()[0] != vr::kCompatibleMajorVrAssetsComponentVersion ||
!base::PathExists(install_dir)) {
return false;
}
return true;
}
void VrAssetsComponentInstallerTraits::ComponentReady(
const base::Version& version,
const base::FilePath& install_dir,
std::unique_ptr<base::DictionaryValue> manifest) {
vr::Assets::GetInstance()->OnComponentReady(version, install_dir,
std::move(manifest));
}
base::FilePath VrAssetsComponentInstallerTraits::GetRelativeInstallDir() const {
return base::FilePath(kRelativeInstallDir);
}
void VrAssetsComponentInstallerTraits::GetHash(
std::vector<uint8_t>* hash) const {
hash->assign(kPublicKeySHA256,
kPublicKeySHA256 + arraysize(kPublicKeySHA256));
}
std::string VrAssetsComponentInstallerTraits::GetName() const {
return kVrAssetsComponentName;
}
update_client::InstallerAttributes
VrAssetsComponentInstallerTraits::GetInstallerAttributes() const {
return update_client::InstallerAttributes();
}
std::vector<std::string> VrAssetsComponentInstallerTraits::GetMimeTypes()
const {
return std::vector<std::string>();
}
void RegisterVrAssetsComponent(ComponentUpdateService* cus) {
std::unique_ptr<ComponentInstallerPolicy> policy(
new VrAssetsComponentInstallerTraits());
auto installer = base::MakeRefCounted<ComponentInstaller>(std::move(policy));
installer->Register(cus, base::Closure());
}
} // namespace component_updater
// Copyright 2017 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_VR_ASSETS_COMPONENT_INSTALLER_H_
#define CHROME_BROWSER_COMPONENT_UPDATER_VR_ASSETS_COMPONENT_INSTALLER_H_
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/values.h"
#include "components/component_updater/component_installer.h"
namespace base {
class FilePath;
} // namespace base
namespace component_updater {
class ComponentUpdateService;
class VrAssetsComponentInstallerTraits : public ComponentInstallerPolicy {
public:
VrAssetsComponentInstallerTraits() {}
~VrAssetsComponentInstallerTraits() override {}
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(VrAssetsComponentInstallerTraits);
};
// Call once during to make the component update service aware of
// the VR Assets component.
void RegisterVrAssetsComponent(ComponentUpdateService* cus);
} // namespace component_updater
#endif // CHROME_BROWSER_COMPONENT_UPDATER_VR_ASSETS_COMPONENT_INSTALLER_H_
......@@ -17,6 +17,8 @@ static_library("vr_common") {
sources = [
"animation_player.cc",
"animation_player.h",
"assets.cc",
"assets.h",
"browser_ui_interface.h",
"content_input_delegate.cc",
"content_input_delegate.h",
......
// Copyright 2017 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/vr/assets.h"
#include "base/memory/singleton.h"
#include "base/values.h"
namespace vr {
struct AssetsSingletonTrait : public base::DefaultSingletonTraits<Assets> {
static Assets* New() { return new Assets(); }
static void Delete(Assets* assets) { delete assets; }
};
// static
Assets* Assets::GetInstance() {
return base::Singleton<Assets, AssetsSingletonTrait>::get();
}
void Assets::OnComponentReady(const base::Version& version,
const base::FilePath& install_dir,
std::unique_ptr<base::DictionaryValue> manifest) {
// TODO(706150): Make assets available to VR.
}
Assets::Assets() = default;
Assets::~Assets() = default;
} // namespace vr
// Copyright 2017 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_VR_ASSETS_H_
#define CHROME_BROWSER_VR_ASSETS_H_
#include <stdint.h>
#include <memory>
namespace base {
class DictionaryValue;
class FilePath;
class Version;
} // namespace base
namespace vr {
constexpr uint32_t kCompatibleMajorVrAssetsComponentVersion = 0;
struct AssetsSingletonTrait;
// Manages VR assets such as the environment. Gets updated by the VR assets
// component.
class Assets {
public:
// Returns the single assets instance and creates it on first call. This
// function is thread-safe.
static Assets* GetInstance();
void OnComponentReady(const base::Version& version,
const base::FilePath& install_dir,
std::unique_ptr<base::DictionaryValue> manifest);
private:
Assets();
~Assets();
friend struct AssetsSingletonTrait;
};
} // namespace vr
#endif // CHROME_BROWSER_VR_ASSETS_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