Chromium Code Reviews| 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..38a9e72af540d8a3725bf144feeef7ab207a3a63 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,23 @@ 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 && |
|
msramek
2015/11/27 16:30:04
Please add a comment what is happening here (maybe
johnme
2015/11/30 14:56:58
Done (in header declaration of helper function).
|
| + 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); |
|
msramek
2015/11/27 16:30:04
As mentioned in HostContentSettingsMap, please DCH
johnme
2015/11/30 14:56:58
Done - HostContentSettingsMap::CoerceSettingInheri
|
| + } |
| + } |
| + return value; |
| } |
| -base::Value* GetContentSettingValueAndPatterns( |
| +scoped_ptr<base::Value> GetContentSettingValueAndPatterns( |
| RuleIterator* rule_iterator, |
| const GURL& primary_url, |
| const GURL& secondary_url, |
| @@ -179,10 +190,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, |