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

Unified Diff: chrome/browser/content_settings/content_settings_utils.cc

Issue 8334020: Check for default content setting pattern when requiring user authorization for plug-ins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 2 months 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: chrome/browser/content_settings/content_settings_utils.cc
diff --git a/chrome/browser/content_settings/content_settings_utils.cc b/chrome/browser/content_settings/content_settings_utils.cc
index 5abebd2960c5a433fee502108ff0d308a66f68e1..cdc8537c9d75e9caf81b23547e042429baa015ce 100644
--- a/chrome/browser/content_settings/content_settings_utils.cc
+++ b/chrome/browser/content_settings/content_settings_utils.cc
@@ -120,77 +120,77 @@ bool ParseContentSettingValue(const base::Value* value,
return *setting != CONTENT_SETTING_DEFAULT;
}
-base::Value* GetContentSettingValue(const ProviderInterface* provider,
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- const std::string& resource_identifier,
- bool include_incognito) {
+base::Value* GetContentSettingValueAndPatterns(
+ const ProviderInterface* provider,
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier,
+ bool include_incognito,
+ ContentSettingsPattern* primary_pattern,
+ ContentSettingsPattern* secondary_pattern) {
if (include_incognito) {
// Check incognito-only specific settings. It's essential that the
// |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 = GetContentSettingValue(
- incognito_rule_iterator.get(), primary_url, secondary_url);
+ base::Value* value = GetContentSettingValueAndPatterns(
+ incognito_rule_iterator.get(), primary_url, secondary_url,
+ primary_pattern, secondary_pattern);
if (value)
return value;
}
// No settings from the incognito; use the normal mode.
scoped_ptr<RuleIterator> rule_iterator(
provider->GetRuleIterator(content_type, resource_identifier, false));
- return GetContentSettingValue(
- rule_iterator.get(), primary_url, secondary_url);
-}
-
-ContentSetting GetContentSetting(const ProviderInterface* provider,
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- const std::string& resource_identifier,
- bool include_incognito) {
- if (include_incognito) {
- // Check incognito-only specific settings. It's essential that the
- // |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));
- ContentSetting setting = GetContentSetting(
- incognito_rule_iterator.get(), primary_url, secondary_url);
- if (setting != CONTENT_SETTING_DEFAULT)
- return setting;
- }
- // No settings from the incognito; use the normal mode.
- scoped_ptr<RuleIterator> rule_iterator(
- provider->GetRuleIterator(content_type, resource_identifier, false));
- return GetContentSetting(rule_iterator.get(), primary_url, secondary_url);
+ return GetContentSettingValueAndPatterns(
+ rule_iterator.get(), primary_url, secondary_url,
+ primary_pattern, secondary_pattern);
}
-base::Value* GetContentSettingValue(RuleIterator* rule_iterator,
- const GURL& primary_url,
- const GURL& secondary_url) {
+base::Value* GetContentSettingValueAndPatterns(
+ RuleIterator* rule_iterator,
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsPattern* primary_pattern,
+ ContentSettingsPattern* secondary_pattern) {
while (rule_iterator->HasNext()) {
const Rule& rule = rule_iterator->Next();
if (rule.primary_pattern.Matches(primary_url) &&
rule.secondary_pattern.Matches(secondary_url)) {
+ if (primary_pattern)
+ *primary_pattern = rule.primary_pattern;
+ if (secondary_pattern)
+ *secondary_pattern = rule.secondary_pattern;
return rule.value.get()->DeepCopy();
}
}
return NULL;
}
-ContentSetting GetContentSetting(RuleIterator* rule_iterator,
+base::Value* GetContentSettingValue(const ProviderInterface* provider,
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier,
+ bool include_incognito) {
+ return GetContentSettingValueAndPatterns(provider, primary_url, secondary_url,
+ content_type, resource_identifier,
+ include_incognito, NULL, NULL);
+}
+
+ContentSetting GetContentSetting(const ProviderInterface* provider,
const GURL& primary_url,
- const GURL& secondary_url) {
- while (rule_iterator->HasNext()) {
- const Rule& rule = rule_iterator->Next();
- if (rule.primary_pattern.Matches(primary_url) &&
- rule.secondary_pattern.Matches(secondary_url)) {
- return ValueToContentSetting(rule.value.get());
- }
- }
- return CONTENT_SETTING_DEFAULT;
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier,
+ bool include_incognito) {
+ scoped_ptr<base::Value> value(
+ GetContentSettingValue(provider, primary_url, secondary_url,
+ content_type, resource_identifier,
+ include_incognito));
+ return ValueToContentSetting(value.get());
}
} // namespace content_settings
« no previous file with comments | « chrome/browser/content_settings/content_settings_utils.h ('k') | chrome/browser/content_settings/host_content_settings_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698