Skip to content

Store components data with unique folder #4443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ using brave_component_updater::BraveOnDemandUpdater;
namespace {

constexpr char kNTPSponsoredImagesDisplayName[] = "NTP sponsored images";
constexpr char kNTPSponsoredImagesBaseDirectory[] = "NTPSponsoredImages";
constexpr size_t kHashSize = 32;

class NTPSponsoredImagesComponentInstallerPolicy
Expand Down Expand Up @@ -54,6 +53,7 @@ class NTPSponsoredImagesComponentInstallerPolicy
std::vector<std::string> GetMimeTypes() const override;

private:
const std::string component_id_;
OnComponentReadyCallback ready_callback_;
uint8_t component_hash_[kHashSize];

Expand All @@ -63,7 +63,8 @@ class NTPSponsoredImagesComponentInstallerPolicy
NTPSponsoredImagesComponentInstallerPolicy::
NTPSponsoredImagesComponentInstallerPolicy(
const RegionalComponentData& data, OnComponentReadyCallback callback)
: ready_callback_(callback) {
: component_id_(data.component_id),
ready_callback_(callback) {
// Generate hash from public key.
std::string decoded_public_key;
base::Base64Decode(data.component_base64_public_key, &decoded_public_key);
Expand Down Expand Up @@ -107,7 +108,7 @@ bool NTPSponsoredImagesComponentInstallerPolicy::VerifyInstallation(

base::FilePath NTPSponsoredImagesComponentInstallerPolicy::
GetRelativeInstallDir() const {
return base::FilePath::FromUTF8Unsafe(kNTPSponsoredImagesBaseDirectory);
return base::FilePath::FromUTF8Unsafe(component_id_);
}

void NTPSponsoredImagesComponentInstallerPolicy::GetHash(
Expand Down