Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: components/content_settings/core/browser/content_settings_utils.cc

Issue 1442083002: Stop inheriting push notification permissions from regular to incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Annotate bool parameters Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/content_settings/core/browser/content_settings_utils.cc
diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc
index b989875867893cfee66aa59e6d5033c6af88989d..dbd2823b69423de1f090c5abf50e42690a5ea06d 100644
--- a/components/content_settings/core/browser/content_settings_utils.cc
+++ b/components/content_settings/core/browser/content_settings_utils.cc
@@ -136,7 +136,7 @@ scoped_ptr<base::Value> ContentSettingToValue(ContentSetting setting) {
return make_scoped_ptr(new base::FundamentalValue(setting));
}
-base::Value* GetContentSettingValueAndPatterns(
+scoped_ptr<base::Value> GetContentSettingValueAndPatterns(
const ProviderInterface* provider,
const GURL& primary_url,
const GURL& secondary_url,
@@ -150,8 +150,9 @@ base::Value* GetContentSettingValueAndPatterns(
// |RuleIterator| gets out of scope before we get a rule iterator for the
// normal mode.
scoped_ptr<RuleIterator> incognito_rule_iterator(
- provider->GetRuleIterator(content_type, resource_identifier, true));
- base::Value* value = GetContentSettingValueAndPatterns(
+ provider->GetRuleIterator(content_type, resource_identifier,
+ true /* incognito */));
+ scoped_ptr<base::Value> value = GetContentSettingValueAndPatterns(
incognito_rule_iterator.get(), primary_url, secondary_url,
primary_pattern, secondary_pattern);
if (value)
@@ -159,13 +160,22 @@ base::Value* GetContentSettingValueAndPatterns(
}
// No settings from the incognito; use the normal mode.
scoped_ptr<RuleIterator> rule_iterator(
- provider->GetRuleIterator(content_type, resource_identifier, false));
- return GetContentSettingValueAndPatterns(
+ provider->GetRuleIterator(content_type, resource_identifier,
+ false /* incognito */));
+ scoped_ptr<base::Value> value = GetContentSettingValueAndPatterns(
rule_iterator.get(), primary_url, secondary_url,
primary_pattern, secondary_pattern);
+ if (value && include_incognito &&
+ ValueToContentSetting(value.get()) == CONTENT_SETTING_ALLOW) {
+ if (WebsiteSettingsRegistry::GetInstance()->Get(content_type)
+ ->incognito_behavior()
+ == WebsiteSettingsInfo::INHERIT_IN_INCOGNITO_EXCEPT_ALLOW)
+ value = ContentSettingToValue(CONTENT_SETTING_ASK);
+ }
+ return value;
}
-base::Value* GetContentSettingValueAndPatterns(
+scoped_ptr<base::Value> GetContentSettingValueAndPatterns(
RuleIterator* rule_iterator,
const GURL& primary_url,
const GURL& secondary_url,
@@ -179,10 +189,10 @@ base::Value* GetContentSettingValueAndPatterns(
*primary_pattern = rule.primary_pattern;
if (secondary_pattern)
*secondary_pattern = rule.secondary_pattern;
- return rule.value.get()->DeepCopy();
+ return make_scoped_ptr(rule.value.get()->DeepCopy());
}
}
- return NULL;
+ return scoped_ptr<base::Value>();
}
void GetRendererContentSettingRules(const HostContentSettingsMap* map,

Powered by Google App Engine
This is Rietveld 408576698