Skip to content

Commit

Permalink
PartitionKey added to a few PolicyProvider overrides
Browse files Browse the repository at this point in the history
This argument is being passed along whenever possible, however for the
existing cases where the value was not provided, the default value in
the call is used.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/0733146d2f1fe11678a7dbf31ab1474370d42d3b

commit 0733146d2f1fe11678a7dbf31ab1474370d42d3b
Author: Jason Lin <lxj@google.com>
Date:   Mon Dec 4 23:56:39 2023 +0000

    Update content_settings::ProviderInterface to accept PartitionKey

    This only changes the signature of the methods. No actual logic is
    changed. We set a default value for the parameter for now to avoid
    having to update all the callers at once.

    For each of the provider, we either add a todo for implementing
    partitioning, or explain that it does not care about partitioning.

    Bug: b/307193732
  • Loading branch information
cdesouza-chromium committed Jan 4, 2024
1 parent b40d64f commit 24dc51c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ bool BravePrefProvider::SetWebsiteSetting(
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
base::Value&& in_value,
const ContentSettingConstraints& constraints) {
const ContentSettingConstraints& constraints,
const PartitionKey& partition_key) {
const auto cookie_is_found_in =
[&primary_pattern = std::as_const(primary_pattern),
&secondary_pattern = std::as_const(secondary_pattern),
Expand Down Expand Up @@ -569,7 +570,8 @@ bool BravePrefProvider::SetWebsiteSettingInternal(
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
base::Value&& in_value,
const ContentSettingConstraints& constraints) {
const ContentSettingConstraints& constraints,
const PartitionKey& partition_key) {
// PrefProvider ignores default settings so handle them here for shields
if (content_settings::IsShieldsContentSettingsType(content_type) &&
primary_pattern == ContentSettingsPattern::Wildcard() &&
Expand Down Expand Up @@ -611,18 +613,19 @@ bool BravePrefProvider::SetWebsiteSettingInternal(

return PrefProvider::SetWebsiteSetting(primary_pattern, secondary_pattern,
content_type, std::move(in_value),
constraints);
constraints, partition_key);
}

std::unique_ptr<RuleIterator> BravePrefProvider::GetRuleIterator(
ContentSettingsType content_type,
bool incognito) const NO_THREAD_SAFETY_ANALYSIS {
bool incognito,
const PartitionKey& partition_key) const NO_THREAD_SAFETY_ANALYSIS {
if (content_type == ContentSettingsType::COOKIES) {
const auto& rules = cookie_rules_.at(incognito);
return rules.GetRuleIterator(content_type);
}

return PrefProvider::GetRuleIterator(content_type, incognito);
return PrefProvider::GetRuleIterator(content_type, incognito, partition_key);
}

void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ class BravePrefProvider : public PrefProvider,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
base::Value&& value,
const ContentSettingConstraints& constraints) override;
const ContentSettingConstraints& constraints,
const PartitionKey& partition_key =
PartitionKey::WipGetDefault()) override;
std::unique_ptr<RuleIterator> GetRuleIterator(
ContentSettingsType content_type,
bool incognito) const override;
bool incognito,
const PartitionKey& partition_key =
PartitionKey::WipGetDefault()) const override;

// calls superclass directly
bool SetWebsiteSettingForTest(const ContentSettingsPattern& primary_pattern,
Expand Down Expand Up @@ -92,7 +96,8 @@ class BravePrefProvider : public PrefProvider,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
base::Value&& value,
const ContentSettingConstraints& constraints);
const ContentSettingConstraints& constraints,
const PartitionKey& partition_key = PartitionKey::WipGetDefault());

// content_settings::Observer overrides:
void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
Expand Down

0 comments on commit 24dc51c

Please sign in to comment.