summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc7
-rw-r--r--chrome/browser/content_settings/content_settings_details.cc7
-rw-r--r--chrome/browser/content_settings/content_settings_details.h24
-rw-r--r--chrome/browser/content_settings/content_settings_extension_provider.cc6
-rw-r--r--chrome/browser/content_settings/content_settings_origin_identifier_value_map.cc50
-rw-r--r--chrome/browser/content_settings/content_settings_origin_identifier_value_map.h38
-rw-r--r--chrome/browser/content_settings/content_settings_pattern_unittest.cc5
-rw-r--r--chrome/browser/content_settings/content_settings_policy_provider.cc14
-rw-r--r--chrome/browser/content_settings/content_settings_policy_provider.h8
-rw-r--r--chrome/browser/content_settings/content_settings_policy_provider_unittest.cc4
-rw-r--r--chrome/browser/content_settings/content_settings_pref_provider.cc189
-rw-r--r--chrome/browser/content_settings/content_settings_pref_provider.h9
-rw-r--r--chrome/browser/content_settings/content_settings_pref_provider_unittest.cc58
-rw-r--r--chrome/browser/content_settings/content_settings_provider.cc8
-rw-r--r--chrome/browser/content_settings/content_settings_provider.h24
-rw-r--r--chrome/browser/content_settings/host_content_settings_map.cc111
-rw-r--r--chrome/browser/content_settings/host_content_settings_map.h37
-rw-r--r--chrome/browser/content_settings/host_content_settings_map_unittest.cc462
-rw-r--r--chrome/browser/content_settings/mock_settings_observer.cc6
-rw-r--r--chrome/browser/content_settings/mock_settings_observer.h3
-rw-r--r--chrome/browser/content_settings/tab_specific_content_settings.cc8
-rw-r--r--chrome/browser/cookies_tree_model.cc1
-rw-r--r--chrome/browser/cookies_tree_model_unittest.cc19
-rw-r--r--chrome/browser/extensions/extension_content_settings_api.cc2
-rw-r--r--chrome/browser/extensions/extension_content_settings_apitest.cc38
-rw-r--r--chrome/browser/geolocation/geolocation_content_settings_map.cc1
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc6
-rw-r--r--chrome/browser/plugin_exceptions_table_model.cc1
-rw-r--r--chrome/browser/plugin_exceptions_table_model_unittest.cc4
-rw-r--r--chrome/browser/plugin_observer.cc5
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.cc5
-rw-r--r--chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc5
-rw-r--r--chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm4
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model.cc8
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc6
-rw-r--r--chrome/browser/ui/webui/options/content_settings_handler.cc7
-rw-r--r--chrome/test/functional/cookies.py6
-rw-r--r--chrome/test/functional/plugins.py4
-rw-r--r--chrome/test/functional/popups.py2
39 files changed, 830 insertions, 372 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 8ccd0d9..b1288c8 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -5830,8 +5830,11 @@ void TestingAutomationProvider::SetContentSetting(
if (host.empty()) {
map->SetDefaultContentSetting(content_type, setting);
} else {
- map->SetContentSetting(ContentSettingsPattern::LegacyFromString(host),
- content_type, "", setting);
+ map->SetContentSetting(ContentSettingsPattern::FromString(host),
+ ContentSettingsPattern::Wildcard(),
+ content_type,
+ std::string(),
+ setting);
}
*success = true;
}
diff --git a/chrome/browser/content_settings/content_settings_details.cc b/chrome/browser/content_settings/content_settings_details.cc
index 20a5ff3..b6410e2 100644
--- a/chrome/browser/content_settings/content_settings_details.cc
+++ b/chrome/browser/content_settings/content_settings_details.cc
@@ -5,11 +5,12 @@
#include "chrome/browser/content_settings/content_settings_details.h"
ContentSettingsDetails::ContentSettingsDetails(
- const ContentSettingsPattern& pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType type,
const std::string& resource_identifier)
- : pattern_(pattern),
+ : primary_pattern_(primary_pattern),
+ secondary_pattern_(secondary_pattern),
type_(type),
resource_identifier_(resource_identifier) {
}
-
diff --git a/chrome/browser/content_settings/content_settings_details.h b/chrome/browser/content_settings/content_settings_details.h
index a277eff..53b0b50 100644
--- a/chrome/browser/content_settings/content_settings_details.h
+++ b/chrome/browser/content_settings/content_settings_details.h
@@ -6,6 +6,8 @@
#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_
#pragma once
+#include <string>
+
#include "base/basictypes.h"
#include "chrome/browser/content_settings/content_settings_pattern.h"
#include "chrome/common/content_settings.h"
@@ -18,15 +20,26 @@
class ContentSettingsDetails {
public:
// Update the setting that matches this pattern/content type/resource.
- ContentSettingsDetails(const ContentSettingsPattern& pattern,
+ ContentSettingsDetails(const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType type,
const std::string& resource_identifier);
- // The pattern whose settings have changed.
- const ContentSettingsPattern& pattern() const { return pattern_; }
+ // The item pattern whose settings have changed.
+ const ContentSettingsPattern& primary_pattern() const {
+ return primary_pattern_;
+ }
+
+ // The top level frame pattern whose settings have changed.
+ const ContentSettingsPattern& secondary_pattern() const {
+ return secondary_pattern_;
+ }
// True if all settings should be updated for the given type.
- bool update_all() const { return !pattern_.IsValid(); }
+ bool update_all() const {
+ return primary_pattern_.ToString().empty() &&
+ secondary_pattern_.ToString().empty();
+ }
// The type of the pattern whose settings have changed.
ContentSettingsType type() const { return type_; }
@@ -43,7 +56,8 @@ class ContentSettingsDetails {
}
private:
- ContentSettingsPattern pattern_;
+ ContentSettingsPattern primary_pattern_;
+ ContentSettingsPattern secondary_pattern_;
ContentSettingsType type_;
std::string resource_identifier_;
diff --git a/chrome/browser/content_settings/content_settings_extension_provider.cc b/chrome/browser/content_settings/content_settings_extension_provider.cc
index f95823a..640d454 100644
--- a/chrome/browser/content_settings/content_settings_extension_provider.cc
+++ b/chrome/browser/content_settings/content_settings_extension_provider.cc
@@ -70,8 +70,10 @@ void ExtensionProvider::OnContentSettingChanged(
if (incognito_ != incognito)
return;
// TODO(markusheintz): Be more concise.
- ContentSettingsDetails details(
- ContentSettingsPattern(), CONTENT_SETTINGS_TYPE_DEFAULT, std::string());
+ ContentSettingsDetails details(ContentSettingsPattern(),
+ ContentSettingsPattern(),
+ CONTENT_SETTINGS_TYPE_DEFAULT,
+ std::string());
NotifyObservers(details);
}
diff --git a/chrome/browser/content_settings/content_settings_origin_identifier_value_map.cc b/chrome/browser/content_settings/content_settings_origin_identifier_value_map.cc
index 330ee49..a6fb3d0 100644
--- a/chrome/browser/content_settings/content_settings_origin_identifier_value_map.cc
+++ b/chrome/browser/content_settings/content_settings_origin_identifier_value_map.cc
@@ -11,13 +11,13 @@
namespace content_settings {
OriginIdentifierValueMap::Entry::Entry(
- ContentSettingsPattern item_pattern,
- ContentSettingsPattern top_level_frame_pattern,
+ ContentSettingsPattern primary_pattern,
+ ContentSettingsPattern secondary_pattern,
ContentSettingsType content_type,
OriginIdentifierValueMap::ResourceIdentifier identifier,
Value* value)
- : item_pattern(item_pattern),
- top_level_frame_pattern(top_level_frame_pattern),
+ : primary_pattern(primary_pattern),
+ secondary_pattern(secondary_pattern),
content_type(content_type),
identifier(identifier),
value(value) {
@@ -32,20 +32,20 @@ OriginIdentifierValueMap::~OriginIdentifierValueMap() {}
bool operator>(const OriginIdentifierValueMap::Entry& first,
const OriginIdentifierValueMap::Entry& second) {
// Compare item patterns.
- if (first.item_pattern > second.item_pattern)
+ if (first.primary_pattern > second.primary_pattern)
return true;
- if (first.item_pattern < second.item_pattern)
+ if (first.primary_pattern < second.primary_pattern)
return false;
// Compare top_level_frame patterns.
- if (first.top_level_frame_pattern > second.top_level_frame_pattern)
+ if (first.secondary_pattern > second.secondary_pattern)
return true;
return false;
}
Value* OriginIdentifierValueMap::GetValue(
- const GURL& item_url,
- const GURL& top_level_frame_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const {
// Find best matching list entry.
@@ -53,8 +53,8 @@ Value* OriginIdentifierValueMap::GetValue(
for (OriginIdentifierValueMap::const_iterator entry = entries_.begin();
entry != entries_.end();
++entry) {
- if (entry->item_pattern.Matches(item_url) &&
- entry->top_level_frame_pattern.Matches(top_level_frame_url) &&
+ if (entry->primary_pattern.Matches(primary_url) &&
+ entry->secondary_pattern.Matches(secondary_url) &&
entry->content_type == content_type &&
entry->identifier == resource_identifier) {
if (best_match == entries_.end() || *entry > *best_match) {
@@ -68,20 +68,20 @@ Value* OriginIdentifierValueMap::GetValue(
}
void OriginIdentifierValueMap::SetValue(
- const ContentSettingsPattern& item_pattern,
- const ContentSettingsPattern& top_level_frame_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
Value* value) {
OriginIdentifierValueMap::iterator list_entry =
- FindEntry(item_pattern,
- top_level_frame_pattern,
+ FindEntry(primary_pattern,
+ secondary_pattern,
content_type,
resource_identifier);
if (list_entry == entries_.end()) {
// No matching list entry found. Add a new entry to the list.
- entries_.insert(list_entry, Entry(item_pattern,
- top_level_frame_pattern,
+ entries_.insert(list_entry, Entry(primary_pattern,
+ secondary_pattern,
content_type,
resource_identifier,
value));
@@ -92,13 +92,13 @@ void OriginIdentifierValueMap::SetValue(
}
void OriginIdentifierValueMap::DeleteValue(
- const ContentSettingsPattern& item_pattern,
- const ContentSettingsPattern& top_level_frame_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) {
OriginIdentifierValueMap::iterator entry_to_delete =
- FindEntry(item_pattern,
- top_level_frame_pattern,
+ FindEntry(primary_pattern,
+ secondary_pattern,
content_type,
resource_identifier);
if (entry_to_delete != entries_.end()) {
@@ -117,15 +117,15 @@ OriginIdentifierValueMap::iterator OriginIdentifierValueMap::erase(
}
OriginIdentifierValueMap::iterator OriginIdentifierValueMap::FindEntry(
- const ContentSettingsPattern& item_pattern,
- const ContentSettingsPattern& top_level_frame_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) {
for (OriginIdentifierValueMap::iterator entry = entries_.begin();
entry != entries_.end();
++entry) {
- if (item_pattern == entry->item_pattern &&
- top_level_frame_pattern == entry->top_level_frame_pattern &&
+ if (primary_pattern == entry->primary_pattern &&
+ secondary_pattern == entry->secondary_pattern &&
content_type == entry->content_type &&
resource_identifier == entry->identifier) {
return entry;
diff --git a/chrome/browser/content_settings/content_settings_origin_identifier_value_map.h b/chrome/browser/content_settings/content_settings_origin_identifier_value_map.h
index 713f7bf..37263bb 100644
--- a/chrome/browser/content_settings/content_settings_origin_identifier_value_map.h
+++ b/chrome/browser/content_settings/content_settings_origin_identifier_value_map.h
@@ -24,15 +24,15 @@ class OriginIdentifierValueMap {
typedef std::string ResourceIdentifier;
struct Entry {
- Entry(ContentSettingsPattern item_pattern,
- ContentSettingsPattern top_level_frame_pattern,
+ Entry(ContentSettingsPattern primary_pattern,
+ ContentSettingsPattern secondary_pattern,
ContentSettingsType content_type,
ResourceIdentifier identifier,
Value* value);
~Entry();
- ContentSettingsPattern item_pattern;
- ContentSettingsPattern top_level_frame_pattern;
+ ContentSettingsPattern primary_pattern;
+ ContentSettingsPattern secondary_pattern;
ContentSettingsType content_type;
ResourceIdentifier identifier;
linked_ptr<Value> value;
@@ -67,30 +67,30 @@ class OriginIdentifierValueMap {
OriginIdentifierValueMap();
~OriginIdentifierValueMap();
- // Returns a weak pointer to the value for the given |item_pattern|,
- // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple. If
+ // Returns a weak pointer to the value for the given |primary_pattern|,
+ // |secondary_pattern|, |content_type|, |resource_identifier| tuple. If
// no value is stored for the passed parameter |NULL| is returned.
Value* GetValue(
- const GURL& item_url,
- const GURL& top_level_frame_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const;
- // Sets the |value| for the given |item_pattern|, |top_level_frame_pattern|,
+ // Sets the |value| for the given |primary_pattern|, |secondary_pattern|,
// |content_type|, |resource_identifier| tuple. The method takes the ownership
// of the passed |value|.
void SetValue(
- const ContentSettingsPattern& item_pattern,
- const ContentSettingsPattern& top_level_frame_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
Value* value);
- // Deletes the map entry for the given |item_pattern|,
- // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple.
+ // Deletes the map entry for the given |primary_pattern|,
+ // |secondary_pattern|, |content_type|, |resource_identifier| tuple.
void DeleteValue(
- const ContentSettingsPattern& item_pattern,
- const ContentSettingsPattern& top_level_frame_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier);
@@ -102,13 +102,13 @@ class OriginIdentifierValueMap {
void clear();
private:
- // Finds the list entry for the given |item_pattern|,
- // |top_level_frame_pattern|, |content_type|, |resource_identifier| tuple and
+ // Finds the list entry for the given |primary_pattern|,
+ // |secondary_pattern|, |content_type|, |resource_identifier| tuple and
// returns the iterator of the list entry. If no entry is found for the passed
// parameters then the end of list iterator is returned.
EntryList::iterator FindEntry(
- const ContentSettingsPattern& item_pattern,
- const ContentSettingsPattern& top_level_frame_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier);
diff --git a/chrome/browser/content_settings/content_settings_pattern_unittest.cc b/chrome/browser/content_settings/content_settings_pattern_unittest.cc
index a985697..0ec8e0c 100644
--- a/chrome/browser/content_settings/content_settings_pattern_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_pattern_unittest.cc
@@ -373,8 +373,9 @@ TEST(ContentSettingsPatternTest, Compare) {
Pattern("*://[*.]google.com:*").Compare(
Pattern("*://[*.]google.com:*")));
- ContentSettingsPattern invalid_pattern1 = ContentSettingsPattern();
- ContentSettingsPattern invalid_pattern2 = Pattern("www.google.com*");
+ ContentSettingsPattern invalid_pattern1;
+ ContentSettingsPattern invalid_pattern2 =
+ ContentSettingsPattern::FromString("google.com*");
// Compare invalid patterns.
EXPECT_TRUE(!invalid_pattern1.IsValid());
diff --git a/chrome/browser/content_settings/content_settings_policy_provider.cc b/chrome/browser/content_settings/content_settings_policy_provider.cc
index ec3d97e..3b3deec 100644
--- a/chrome/browser/content_settings/content_settings_policy_provider.cc
+++ b/chrome/browser/content_settings/content_settings_policy_provider.cc
@@ -179,6 +179,7 @@ void PolicyDefaultProvider::Observe(NotificationType type,
if (!is_off_the_record_) {
ContentSettingsDetails details(ContentSettingsPattern(),
+ ContentSettingsPattern(),
CONTENT_SETTINGS_TYPE_DEFAULT,
std::string());
NotifyObservers(details);
@@ -380,21 +381,21 @@ void PolicyProvider::ReadManagedContentSettings(bool overwrite) {
// Since the PolicyProvider is a read only content settings provider, all
// methodes of the ProviderInterface that set or delete any settings do nothing.
void PolicyProvider::SetContentSetting(
- const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
ContentSetting content_setting) {
}
ContentSetting PolicyProvider::GetContentSetting(
- const GURL& requesting_url,
- const GURL& embedding_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const {
ContentSetting setting = BaseProvider::GetContentSetting(
- requesting_url,
- embedding_url,
+ primary_url,
+ secondary_url,
content_type,
NO_RESOURCE_IDENTIFIER);
if (setting == CONTENT_SETTING_DEFAULT && default_provider_)
@@ -451,6 +452,7 @@ void PolicyProvider::Observe(NotificationType type,
*name == prefs::kManagedPopupsBlockedForUrls) {
ReadManagedContentSettings(true);
ContentSettingsDetails details(ContentSettingsPattern(),
+ ContentSettingsPattern(),
CONTENT_SETTINGS_TYPE_DEFAULT,
std::string());
NotifyObservers(details);
diff --git a/chrome/browser/content_settings/content_settings_policy_provider.h b/chrome/browser/content_settings/content_settings_policy_provider.h
index a2efaaa..f6860bf 100644
--- a/chrome/browser/content_settings/content_settings_policy_provider.h
+++ b/chrome/browser/content_settings/content_settings_policy_provider.h
@@ -93,15 +93,15 @@ class PolicyProvider : public BaseProvider,
virtual void Init();
virtual void SetContentSetting(
- const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
ContentSetting content_setting);
virtual ContentSetting GetContentSetting(
- const GURL& requesting_url,
- const GURL& embedding_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const;
diff --git a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
index 5d24503..0dfa19b 100644
--- a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
@@ -70,7 +70,7 @@ TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) {
EXPECT_CALL(observer,
OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
CONTENT_SETTINGS_TYPE_DEFAULT, true,
- _, true));
+ _, _, true));
prefs->SetManagedPref(prefs::kManagedDefaultImagesSetting,
Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
::testing::Mock::VerifyAndClearExpectations(&observer);
@@ -78,7 +78,7 @@ TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) {
EXPECT_CALL(observer,
OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
CONTENT_SETTINGS_TYPE_DEFAULT, true,
- _, true));
+ _, _, true));
// Remove the managed default-content-setting.
prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting);
}
diff --git a/chrome/browser/content_settings/content_settings_pref_provider.cc b/chrome/browser/content_settings/content_settings_pref_provider.cc
index 40007a6..8f438ad 100644
--- a/chrome/browser/content_settings/content_settings_pref_provider.cc
+++ b/chrome/browser/content_settings/content_settings_pref_provider.cc
@@ -82,11 +82,35 @@ void SetDefaultContentSettings(DictionaryValue* default_settings) {
}
}
+const char* kPatternSeparator = ",";
+
std::string CreatePatternString(
- const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern) {
- DCHECK(requesting_pattern == embedding_pattern);
- return requesting_pattern.ToString();
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern) {
+ return primary_pattern.ToString() +
+ std::string(kPatternSeparator) +
+ secondary_pattern.ToString();
+}
+
+std::pair<ContentSettingsPattern, ContentSettingsPattern>
+ ParsePatternString(const std::string& pattern_str) {
+ DCHECK(!pattern_str.empty());
+ size_t pos = pattern_str.find(kPatternSeparator);
+
+ std::pair<ContentSettingsPattern, ContentSettingsPattern> pattern_pair;
+ if (pos == std::string::npos) {
+ pattern_pair.first = ContentSettingsPattern::FromString(pattern_str);
+ DCHECK(pattern_pair.first.IsValid());
+ pattern_pair.second = ContentSettingsPattern();
+ } else {
+ pattern_pair.first = ContentSettingsPattern::FromString(
+ pattern_str.substr(0, pos));
+ DCHECK(pattern_pair.first.IsValid());
+ pattern_pair.second = ContentSettingsPattern::FromString(
+ pattern_str.substr(pos+1, pattern_str.size() - pos - 1));
+ DCHECK(pattern_pair.second.IsValid());
+ }
+ return pattern_pair;
}
ContentSetting ValueToContentSetting(Value* value) {
@@ -196,7 +220,10 @@ void PrefDefaultProvider::UpdateDefaultSetting(
updating_preferences_ = false;
ContentSettingsDetails details(
- ContentSettingsPattern(), content_type, std::string());
+ ContentSettingsPattern(),
+ ContentSettingsPattern(),
+ content_type,
+ std::string());
NotifyObservers(details);
}
@@ -239,6 +266,7 @@ void PrefDefaultProvider::Observe(NotificationType type,
if (!is_incognito_) {
ContentSettingsDetails details(ContentSettingsPattern(),
+ ContentSettingsPattern(),
CONTENT_SETTINGS_TYPE_DEFAULT,
std::string());
NotifyObservers(details);
@@ -391,6 +419,7 @@ void PrefProvider::Init() {
// Migrate obsolete preferences.
MigrateObsoletePerhostPref(prefs);
MigrateObsoletePopupsPref(prefs);
+ MigrateSinglePatternSettings(prefs);
// Verify preferences version.
if (!prefs->HasPrefPath(prefs::kContentSettingsVersion)) {
@@ -420,29 +449,26 @@ void PrefProvider::Init() {
}
ContentSetting PrefProvider::GetContentSetting(
- const GURL& requesting_url,
- const GURL& embedding_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const {
- // Support for item, top-level-frame URLs are not enabled yet.
- DCHECK(requesting_url == embedding_url);
-
// For a |PrefProvider| used in a |HostContentSettingsMap| of a non incognito
// profile, this will always return NULL.
// TODO(markusheintz): I don't like this. I'd like to have an
// IncognitoProviderWrapper that wrapps the pref provider for a host content
// settings map of an incognito profile.
Value* incognito_value = incognito_value_map_.GetValue(
- requesting_url,
- embedding_url,
+ primary_url,
+ secondary_url,
content_type,
resource_identifier);
if (incognito_value)
return ValueToContentSetting(incognito_value);
Value* value = value_map_.GetValue(
- requesting_url,
- embedding_url,
+ primary_url,
+ secondary_url,
content_type,
resource_identifier);
if (value)
@@ -469,8 +495,8 @@ void PrefProvider::GetAllContentSettingsRules(
entry->identifier == resource_identifier) {
ContentSetting setting = ValueToContentSetting(entry->value.get());
DCHECK(setting != CONTENT_SETTING_DEFAULT);
- Rule new_rule(entry->item_pattern,
- entry->top_level_frame_pattern,
+ Rule new_rule(entry->primary_pattern,
+ entry->secondary_pattern,
setting);
content_setting_rules->push_back(new_rule);
}
@@ -478,14 +504,11 @@ void PrefProvider::GetAllContentSettingsRules(
}
void PrefProvider::SetContentSetting(
- const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
ContentSetting setting) {
- // Support for embedding_patterns is not implemented yet.
- DCHECK(requesting_pattern == embedding_pattern);
-
DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -506,14 +529,14 @@ void PrefProvider::SetContentSetting(
base::AutoLock auto_lock(lock_);
if (setting == CONTENT_SETTING_DEFAULT) {
map_to_modify->DeleteValue(
- requesting_pattern,
- embedding_pattern,
+ primary_pattern,
+ secondary_pattern,
content_type,
resource_identifier);
} else {
map_to_modify->SetValue(
- requesting_pattern,
- embedding_pattern,
+ primary_pattern,
+ secondary_pattern,
content_type,
resource_identifier,
Value::CreateIntegerValue(setting));
@@ -521,8 +544,8 @@ void PrefProvider::SetContentSetting(
}
// Update the content settings preference.
- std::string pattern_str(CreatePatternString(requesting_pattern,
- embedding_pattern));
+ std::string pattern_str(CreatePatternString(primary_pattern,
+ secondary_pattern));
if (all_settings_dictionary) {
// Get settings dictionary for the pattern string (key).
DictionaryValue* settings_dictionary = NULL;
@@ -582,7 +605,7 @@ void PrefProvider::SetContentSetting(
updating_preferences_ = false;
ContentSettingsDetails details(
- requesting_pattern, content_type, std::string());
+ primary_pattern, secondary_pattern, content_type, std::string());
NotifyObservers(details);
}
@@ -626,7 +649,7 @@ void PrefProvider::ClearAllContentSettingsRules(
while (entry != map_to_modify->end()) {
if (entry->content_type == content_type) {
std::string pattern_str = CreatePatternString(
- entry->item_pattern, entry->top_level_frame_pattern);
+ entry->primary_pattern, entry->secondary_pattern);
// Delete current |entry| and set |entry| to the next value map entry.
entry = map_to_modify->erase(entry);
@@ -655,7 +678,10 @@ void PrefProvider::ClearAllContentSettingsRules(
updating_preferences_ = false;
ContentSettingsDetails details(
- ContentSettingsPattern(), content_type, std::string());
+ ContentSettingsPattern(),
+ ContentSettingsPattern(),
+ content_type,
+ std::string());
NotifyObservers(details);
}
@@ -680,6 +706,7 @@ void PrefProvider::Observe(
if (!is_incognito_) {
ContentSettingsDetails details(ContentSettingsPattern(),
+ ContentSettingsPattern(),
CONTENT_SETTINGS_TYPE_DEFAULT,
std::string());
NotifyObservers(details);
@@ -729,10 +756,13 @@ void PrefProvider::ReadExceptions(bool overwrite) {
for (DictionaryValue::key_iterator i(mutable_settings->begin_keys());
i != mutable_settings->end_keys(); ++i) {
const std::string& pattern_str(*i);
- ContentSettingsPattern pattern =
- ContentSettingsPattern::FromString(pattern_str);
- if (!pattern.IsValid())
- LOG(WARNING) << "Invalid pattern stored in content settings";
+ std::pair<ContentSettingsPattern, ContentSettingsPattern> pattern_pair =
+ ParsePatternString(pattern_str);
+ if (!pattern_pair.first.IsValid() ||
+ !pattern_pair.second.IsValid()) {
+ LOG(DFATAL) << "Invalid pattern strings: " << pattern_str;
+ continue;
+ }
// Get settings dictionary for the current pattern string, and read
// settings from the dictionary.
@@ -760,8 +790,8 @@ void PrefProvider::ReadExceptions(bool overwrite) {
DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
setting = ClickToPlayFixup(content_type,
ContentSetting(setting));
- value_map_.SetValue(pattern,
- pattern,
+ value_map_.SetValue(pattern_pair.first,
+ pattern_pair.second,
content_type,
resource_identifier,
Value::CreateIntegerValue(setting));
@@ -777,8 +807,8 @@ void PrefProvider::ReadExceptions(bool overwrite) {
ContentSetting(setting));
setting = ClickToPlayFixup(content_type,
ContentSetting(setting));
- value_map_.SetValue(pattern,
- pattern,
+ value_map_.SetValue(pattern_pair.first,
+ pattern_pair.second,
content_type,
ResourceIdentifier(""),
Value::CreateIntegerValue(setting));
@@ -798,26 +828,31 @@ void PrefProvider::CanonicalizeContentSettingsExceptions(
std::vector<std::pair<std::string, std::string> > move_items;
for (DictionaryValue::key_iterator i(all_settings_dictionary->begin_keys());
i != all_settings_dictionary->end_keys(); ++i) {
- const std::string& pattern(*i);
- const std::string canonicalized_pattern =
- ContentSettingsPattern::FromString(pattern).ToString();
+ const std::string& pattern_str(*i);
+ std::pair<ContentSettingsPattern, ContentSettingsPattern> pattern_pair =
+ ParsePatternString(pattern_str);
+
+ const std::string canonicalized_pattern_str = CreatePatternString(
+ pattern_pair.first, pattern_pair.second);
- if (canonicalized_pattern.empty() || canonicalized_pattern == pattern)
+ if (canonicalized_pattern_str.empty() ||
+ canonicalized_pattern_str == pattern_str)
continue;
// Clear old pattern if prefs already have canonicalized pattern.
DictionaryValue* new_pattern_settings_dictionary = NULL;
if (all_settings_dictionary->GetDictionaryWithoutPathExpansion(
- canonicalized_pattern, &new_pattern_settings_dictionary)) {
- remove_items.push_back(pattern);
+ canonicalized_pattern_str, &new_pattern_settings_dictionary)) {
+ remove_items.push_back(pattern_str);
continue;
}
// Move old pattern to canonicalized pattern.
DictionaryValue* old_pattern_settings_dictionary = NULL;
if (all_settings_dictionary->GetDictionaryWithoutPathExpansion(
- pattern, &old_pattern_settings_dictionary)) {
- move_items.push_back(std::make_pair(pattern, canonicalized_pattern));
+ pattern_str, &old_pattern_settings_dictionary)) {
+ move_items.push_back(
+ std::make_pair(pattern_str, canonicalized_pattern_str));
}
}
@@ -933,4 +968,66 @@ void PrefProvider::MigrateObsoletePopupsPref(PrefService* prefs) {
}
}
+void PrefProvider::MigrateSinglePatternSettings(PrefService* prefs) {
+ const DictionaryValue* all_settings_dictionary =
+ prefs->GetDictionary(prefs::kContentSettingsPatterns);
+ // The all_settings_dictionary can be |NULL| if the preferences hasn't been
+ // set yet. In incognito mode we must not write to preferences.
+ if (all_settings_dictionary && !is_incognito_) {
+ DictionaryPrefUpdate update(prefs, prefs::kContentSettingsPatterns);
+ DictionaryValue* mutable_settings;
+ mutable_settings = update.Get();
+
+ // Create a list of items to migrate.
+ std::list<std::string> move_items;
+ for (DictionaryValue::key_iterator i(mutable_settings->begin_keys());
+ i != mutable_settings->end_keys();
+ ++i) {
+ const std::string& pattern_str(*i);
+ std::pair<ContentSettingsPattern, ContentSettingsPattern> pattern_pair =
+ ParsePatternString(pattern_str);
+
+ // If the pattern_str contains two valid patterns it must not be migrated,
+ // so we skip it.
+ if (pattern_pair.first.IsValid() &&
+ pattern_pair.second.IsValid()) {
+ continue;
+ }
+ if (!pattern_pair.first.IsValid()) {
+ // Skip over corrupted and malformed patterns.
+ LOG(DFATAL) << "Invalid pattern string: " << pattern_str;
+ continue;
+ }
+
+ move_items.push_back(pattern_str);
+ }
+
+ // Migrate the items.
+ for (std::list<std::string>::iterator i = move_items.begin();
+ i != move_items.end();
+ ++i) {
+ const std::string& pattern_str(*i);
+ Value* value;
+ bool found = mutable_settings->RemoveWithoutPathExpansion(*i, &value);
+ DCHECK(found);
+
+ // Migrate the content settings types that used to be applied based on the
+ // top level frame URL only.
+ std::string new_pattern_str = CreatePatternString(
+ ContentSettingsPattern::FromString(pattern_str),
+ ContentSettingsPattern::Wildcard());
+ // Check if there is already a entry for the new pattern string.
+ DictionaryValue* dictionary = NULL;
+ found = mutable_settings->GetDictionaryWithoutPathExpansion(
+ new_pattern_str, &dictionary);
+ if (!found) {
+ mutable_settings->SetWithoutPathExpansion(
+ new_pattern_str, value);
+ } else {
+ NOTREACHED();
+ }
+ }
+ }
+}
+
} // namespace content_settings
diff --git a/chrome/browser/content_settings/content_settings_pref_provider.h b/chrome/browser/content_settings/content_settings_pref_provider.h
index 4e00ae5..266cc06 100644
--- a/chrome/browser/content_settings/content_settings_pref_provider.h
+++ b/chrome/browser/content_settings/content_settings_pref_provider.h
@@ -110,15 +110,15 @@ class PrefProvider : public ProviderInterface,
// ProviderInterface implementations.
virtual void SetContentSetting(
- const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
ContentSetting content_setting);
virtual ContentSetting GetContentSetting(
- const GURL& requesting_url,
- const GURL& embedding_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const;
@@ -146,6 +146,7 @@ class PrefProvider : public ProviderInterface,
// migrated to the new format).
void MigrateObsoletePerhostPref(PrefService* prefs);
void MigrateObsoletePopupsPref(PrefService* prefs);
+ void MigrateSinglePatternSettings(PrefService* prefs);
void CanonicalizeContentSettingsExceptions(
DictionaryValue* all_settings_dictionary);
diff --git a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
index a73ec01..d398002 100644
--- a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
+++ b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
@@ -65,13 +65,13 @@ TEST_F(PrefDefaultProviderTest, Observer) {
EXPECT_CALL(observer,
OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
CONTENT_SETTINGS_TYPE_IMAGES, false,
- _, true));
+ _, _, true));
// Expect a second call because the PrefDefaultProvider in the TestingProfile
// also observes the default content settings preference.
EXPECT_CALL(observer,
OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
CONTENT_SETTINGS_TYPE_DEFAULT, true,
- _, true));
+ _, _, true));
provider.UpdateDefaultSetting(
CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
}
@@ -173,15 +173,18 @@ TEST_F(PrefProviderTest, Observer) {
// Expect 2 calls: One from the update and one from canonicalization.
EXPECT_CALL(observer,
OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
- CONTENT_SETTINGS_TYPE_IMAGES, false,
- pattern, false));
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ false,
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ false));
EXPECT_CALL(observer,
OnContentSettingsChanged(profile.GetHostContentSettingsMap(),
CONTENT_SETTINGS_TYPE_DEFAULT, true,
- _, true));
+ _, _, true));
pref_content_settings_provider.SetContentSetting(
pattern,
- pattern,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_IMAGES,
"",
CONTENT_SETTING_ALLOW);
@@ -331,4 +334,47 @@ TEST_F(PrefProviderTest, ResourceIdentifier) {
host, host, CONTENT_SETTINGS_TYPE_PLUGINS, resource2));
}
+TEST_F(PrefProviderTest, MigrateSinglePatternSettings) {
+ // Setup single pattern settings.
+ TestingProfile profile;
+ PrefService* prefs = profile.GetPrefs();
+
+ DictionaryValue* settings_dictionary = new DictionaryValue();
+ settings_dictionary->SetInteger("cookies", 2);
+ settings_dictionary->SetInteger("images", 2);
+ settings_dictionary->SetInteger("popups", 2);
+
+ ContentSettingsPattern pattern =
+ ContentSettingsPattern::FromString("http://www.example.com");
+ DictionaryValue* all_settings_dictionary = new DictionaryValue();
+ all_settings_dictionary->SetWithoutPathExpansion(
+ pattern.ToString(), settings_dictionary);
+
+ prefs->Set(prefs::kContentSettingsPatterns, *all_settings_dictionary);
+
+ // Test if single pattern settings are properly migrated.
+ content_settings::PrefProvider provider(profile.GetOriginalProfile());
+
+ const DictionaryValue* const_all_settings_dictionary =
+ prefs->GetDictionary(prefs::kContentSettingsPatterns);
+ EXPECT_EQ(1U, const_all_settings_dictionary->size());
+ EXPECT_FALSE(const_all_settings_dictionary->HasKey(pattern.ToString()));
+ EXPECT_TRUE(const_all_settings_dictionary->HasKey(
+ pattern.ToString() + "," +
+ ContentSettingsPattern::Wildcard().ToString()));
+
+ // TODO test provider
+ EXPECT_EQ(CONTENT_SETTING_BLOCK, provider.GetContentSetting(
+ GURL("http://www.example.com"),
+ GURL("http://www.example.com"),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ ""));
+
+ EXPECT_EQ(CONTENT_SETTING_BLOCK, provider.GetContentSetting(
+ GURL("http://www.example.com"),
+ GURL("http://www.example.com"),
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ ""));
+}
+
} // namespace content_settings
diff --git a/chrome/browser/content_settings/content_settings_provider.cc b/chrome/browser/content_settings/content_settings_provider.cc
index 3920700..282c7988 100644
--- a/chrome/browser/content_settings/content_settings_provider.cc
+++ b/chrome/browser/content_settings/content_settings_provider.cc
@@ -10,11 +10,11 @@ ProviderInterface::Rule::Rule()
: content_setting(CONTENT_SETTING_DEFAULT) {
}
-ProviderInterface::Rule::Rule(const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern,
+ProviderInterface::Rule::Rule(const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSetting setting)
- : requesting_url_pattern(requesting_pattern),
- embedding_url_pattern(embedding_pattern),
+ : primary_pattern(primary_pattern),
+ secondary_pattern(secondary_pattern),
content_setting(setting) {
}
diff --git a/chrome/browser/content_settings/content_settings_provider.h b/chrome/browser/content_settings/content_settings_provider.h
index 19a7191..1056ea2 100644
--- a/chrome/browser/content_settings/content_settings_provider.h
+++ b/chrome/browser/content_settings/content_settings_provider.h
@@ -51,12 +51,12 @@ class ProviderInterface {
public:
struct Rule {
Rule();
- Rule(const ContentSettingsPattern& requesting_pattern,
- const ContentSettingsPattern& embedding_pattern,
+ Rule(const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSetting setting);
- ContentSettingsPattern requesting_url_pattern;
- ContentSettingsPattern embedding_url_pattern;
+ ContentSettingsPattern primary_pattern;
+ ContentSettingsPattern secondary_pattern;
ContentSetting content_setting;
};
@@ -64,27 +64,27 @@ class ProviderInterface {
virtual ~ProviderInterface() {}
- // Returns a single ContentSetting which applies to a given |requesting_url|,
- // |embedding_url| pair or CONTENT_SETTING_DEFAULT, if no rule applies. For
+ // Returns a single ContentSetting which applies to a given |primary_url|,
+ // |secondary_url| pair or CONTENT_SETTING_DEFAULT, if no rule applies. For
// ContentSettingsTypes that require a resource identifier to be specified,
// the |resource_identifier| must be non-empty.
//
// This may be called on any thread.
virtual ContentSetting GetContentSetting(
- const GURL& requesting_url,
- const GURL& embedding_url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier) const = 0;
- // Sets the content setting for a particular |requesting_pattern|,
- // |embedding_pattern|, |content_type| tuple. For ContentSettingsTypes that
+ // Sets the content setting for a particular |primary_pattern|,
+ // |secondary_pattern|, |content_type| tuple. For ContentSettingsTypes that
// require a resource identifier to be specified, the |resource_identifier|
// must be non-empty.
//
// This should only be called on the UI thread.
virtual void SetContentSetting(
- const ContentSettingsPattern& requesting_url_pattern,
- const ContentSettingsPattern& embedding_url_pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
ContentSetting content_setting) = 0;
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index f7380bf..66853dd 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -158,28 +158,6 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSetting(
return setting;
}
-ContentSetting HostContentSettingsMap::GetContentSetting(
- const GURL& url,
- ContentSettingsType content_type,
- const std::string& resource_identifier) const {
- DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type);
- DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type),
- resource_identifier.empty());
- return GetContentSettingInternal(url, content_type, resource_identifier);
-}
-
-ContentSetting HostContentSettingsMap::GetContentSettingInternal(
- const GURL& url,
- ContentSettingsType content_type,
- const std::string& resource_identifier) const {
- ContentSetting setting = GetNonDefaultContentSetting(url,
- content_type,
- resource_identifier);
- if (setting == CONTENT_SETTING_DEFAULT)
- return GetDefaultContentSetting(content_type);
- return setting;
-}
-
ContentSetting HostContentSettingsMap::GetCookieContentSetting(
const GURL& url,
const GURL& first_party_url,
@@ -204,16 +182,42 @@ ContentSetting HostContentSettingsMap::GetCookieContentSetting(
}
if (setting == CONTENT_SETTING_ALLOW)
- setting = GetContentSettingInternal(url, CONTENT_SETTINGS_TYPE_COOKIES, "");
+ setting = GetContentSettingInternal(
+ url, url, CONTENT_SETTINGS_TYPE_COOKIES, "");
return setting;
}
-ContentSetting HostContentSettingsMap::GetNonDefaultContentSetting(
- const GURL& url,
+ContentSetting HostContentSettingsMap::GetContentSetting(
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier) const {
- if (ShouldAllowAllContent(url))
+ DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type);
+ DCHECK_NE(content_settings::RequiresResourceIdentifier(content_type),
+ resource_identifier.empty());
+ return GetContentSettingInternal(
+ primary_url, secondary_url, content_type, resource_identifier);
+}
+
+ContentSetting HostContentSettingsMap::GetContentSettingInternal(
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier) const {
+ ContentSetting setting = GetNonDefaultContentSetting(
+ primary_url, secondary_url, content_type, resource_identifier);
+ if (setting == CONTENT_SETTING_DEFAULT)
+ return GetDefaultContentSetting(content_type);
+ return setting;
+}
+
+ContentSetting HostContentSettingsMap::GetNonDefaultContentSetting(
+ const GURL& primary_url,
+ const GURL& secondary_url,
+ ContentSettingsType content_type,
+ const std::string& resource_identifier) const {
+ if (ShouldAllowAllContent(secondary_url))
return CONTENT_SETTING_ALLOW;
// Iterate through the list of providers and break when the first non default
@@ -223,7 +227,7 @@ ContentSetting HostContentSettingsMap::GetNonDefaultContentSetting(
provider != content_settings_providers_.end();
++provider) {
provided_setting = (*provider)->GetContentSetting(
- url, url, content_type, resource_identifier);
+ primary_url, secondary_url, content_type, resource_identifier);
if (provided_setting != CONTENT_SETTING_DEFAULT)
return provided_setting;
}
@@ -231,8 +235,10 @@ ContentSetting HostContentSettingsMap::GetNonDefaultContentSetting(
}
ContentSettings HostContentSettingsMap::GetContentSettings(
- const GURL& url) const {
- ContentSettings output = GetNonDefaultContentSettings(url);
+ const GURL& primary_url,
+ const GURL& secondary_url) const {
+ ContentSettings output = GetNonDefaultContentSettings(
+ primary_url, secondary_url);
// If we require a resource identifier, set the content settings to default,
// otherwise make the defaults explicit.
@@ -248,14 +254,18 @@ ContentSettings HostContentSettingsMap::GetContentSettings(
}
ContentSettings HostContentSettingsMap::GetNonDefaultContentSettings(
- const GURL& url) const {
- if (ShouldAllowAllContent(url))
+ const GURL& primary_url,
+ const GURL& secondary_url) const {
+ if (ShouldAllowAllContent(secondary_url))
return ContentSettings(CONTENT_SETTING_ALLOW);
ContentSettings output(CONTENT_SETTING_DEFAULT);
for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) {
output.settings[j] = GetNonDefaultContentSetting(
- url, ContentSettingsType(j) , "");
+ primary_url,
+ secondary_url,
+ ContentSettingsType(j),
+ "");
}
return output;
}
@@ -281,9 +291,17 @@ void HostContentSettingsMap::GetSettingsForOneType(
for (Rules::iterator rule = rules.begin();
rule != rules.end();
++rule) {
- const ContentSettingsPattern& pattern(rule->requesting_url_pattern);
- pattern_str_pattern_setting_pair_map[pattern.ToString()] =
- PatternSettingPair(pattern, rule->content_setting);
+ // As long as we don't support pattern pairs in the UI we display the
+ // primary pattern.
+ ContentSettingsPattern pattern = rule->primary_pattern;
+ std::string key = pattern.ToString();
+ // Only add a rule if no provider with a higher priority has a rule with
+ // an identical primary pattern.
+ if (pattern_str_pattern_setting_pair_map.find(key) ==
+ pattern_str_pattern_setting_pair_map.end()) {
+ pattern_str_pattern_setting_pair_map[key] =
+ PatternSettingPair(pattern, rule->content_setting);
+ }
}
}
@@ -309,7 +327,8 @@ void HostContentSettingsMap::SetDefaultContentSetting(
}
void HostContentSettingsMap::SetContentSetting(
- const ContentSettingsPattern& pattern,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSetting setting) {
@@ -320,22 +339,34 @@ void HostContentSettingsMap::SetContentSetting(
provider != content_settings_providers_.end();
++provider) {
(*provider)->SetContentSetting(
- pattern, pattern, content_type, resource_identifier, setting);
+ primary_pattern,
+ secondary_pattern,
+ content_type,
+ resource_identifier,
+ setting);
}
}
void HostContentSettingsMap::AddExceptionForURL(
- const GURL& url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSetting setting) {
+ // TODO(markusheintz): Until the UI supports pattern pairs, both urls must
+ // match.
+ DCHECK(primary_url == secondary_url);
+
// Make sure there is no entry that would override the pattern we are about
// to insert for exactly this URL.
- SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(url),
+ SetContentSetting(ContentSettingsPattern::FromURLNoWildcard(primary_url),
+ ContentSettingsPattern::Wildcard(),
content_type,
resource_identifier,
CONTENT_SETTING_DEFAULT);
- SetContentSetting(ContentSettingsPattern::FromURL(url),
+
+ SetContentSetting(ContentSettingsPattern::FromURL(primary_url),
+ ContentSettingsPattern::Wildcard(),
content_type,
resource_identifier,
setting);
diff --git a/chrome/browser/content_settings/host_content_settings_map.h b/chrome/browser/content_settings/host_content_settings_map.h
index 5cef393..64556f7 100644
--- a/chrome/browser/content_settings/host_content_settings_map.h
+++ b/chrome/browser/content_settings/host_content_settings_map.h
@@ -54,14 +54,15 @@ class HostContentSettingsMap
ContentSetting GetDefaultContentSetting(
ContentSettingsType content_type) const;
- // Returns a single ContentSetting which applies to a given URL. Note that
+ // Returns a single ContentSetting which applies to the given URLs. Note that
// certain internal schemes are whitelisted. For ContentSettingsTypes that
// require an resource identifier to be specified, the |resource_identifier|
// must be non-empty.
//
// This may be called on any thread.
ContentSetting GetContentSetting(
- const GURL& url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier) const;
@@ -75,7 +76,7 @@ class HostContentSettingsMap
const GURL& first_party_url,
bool setting_cookie) const;
- // Returns a single ContentSetting which applies to a given URL or
+ // Returns a single ContentSetting which applies to the given URLs or
// CONTENT_SETTING_DEFAULT, if no exception applies. Note that certain
// internal schemes are whitelisted. For ContentSettingsTypes that require an
// resource identifier to be specified, the |resource_identifier| must be
@@ -83,23 +84,29 @@ class HostContentSettingsMap
//
// This may be called on any thread.
ContentSetting GetNonDefaultContentSetting(
- const GURL& url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier) const;
- // Returns all ContentSettings which apply to a given URL. For content
+
+ // Returns all ContentSettings which apply to the given URLs. For content
// setting types that require an additional resource identifier, the default
// content setting is returned.
//
// This may be called on any thread.
- ContentSettings GetContentSettings(const GURL& url) const;
+ ContentSettings GetContentSettings(
+ const GURL& primary_url,
+ const GURL& secondary_url) const;
- // Returns all non-default ContentSettings which apply to a given URL. For
+ // Returns all non-default ContentSettings which apply to the given URLs. For
// content setting types that require an additional resource identifier,
// CONTENT_SETTING_DEFAULT is returned.
//
// This may be called on any thread.
- ContentSettings GetNonDefaultContentSettings(const GURL& url) const;
+ ContentSettings GetNonDefaultContentSettings(
+ const GURL& primary_url,
+ const GURL& secondary_url) const;
// For a given content type, returns all patterns with a non-default setting,
// mapped to their actual settings, in lexicographical order. |settings|
@@ -120,25 +127,28 @@ class HostContentSettingsMap
void SetDefaultContentSetting(ContentSettingsType content_type,
ContentSetting setting);
- // Sets the blocking setting for a particular pattern and content type.
+ // Sets the content setting for the given patterns and content type.
// Setting the value to CONTENT_SETTING_DEFAULT causes the default setting
// for that type to be used when loading pages matching this pattern. For
// ContentSettingsTypes that require an resource identifier to be specified,
// the |resource_identifier| must be non-empty.
//
// This should only be called on the UI thread.
- void SetContentSetting(const ContentSettingsPattern& pattern,
+ void SetContentSetting(const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSetting setting);
- // Convenience method to add a content setting for a given URL, making sure
+
+ // Convenience method to add a content setting for the given URLs, making sure
// that there is no setting overriding it. For ContentSettingsTypes that
// require an resource identifier to be specified, the |resource_identifier|
// must be non-empty.
//
// This should only be called on the UI thread.
- void AddExceptionForURL(const GURL& url,
+ void AddExceptionForURL(const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
ContentSetting setting);
@@ -183,7 +193,8 @@ class HostContentSettingsMap
virtual ~HostContentSettingsMap();
ContentSetting GetContentSettingInternal(
- const GURL& url,
+ const GURL& primary_url,
+ const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier) const;
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index f7bcf0c..ed66339 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -60,7 +60,9 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
CONTENT_SETTINGS_TYPE_IMAGES));
EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting(
GURL(chrome::kChromeUINewTabURL),
- CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ GURL(chrome::kChromeUINewTabURL),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string()));
{
// Click-to-play needs to be enabled to set the content setting to ASK.
CommandLine* cmd = CommandLine::ForCurrentProcess();
@@ -89,35 +91,55 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
ContentSettingsPattern::FromString("[*.]example.com");
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_DEFAULT);
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ "",
+ CONTENT_SETTING_DEFAULT);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
+ host, host, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
// Check returning all settings for a host.
ContentSettings desired_settings;
desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES] =
CONTENT_SETTING_ALLOW;
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_DEFAULT);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_DEFAULT);
desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] =
CONTENT_SETTING_ALLOW;
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] =
CONTENT_SETTING_BLOCK;
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_ALLOW);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string(),
+ CONTENT_SETTING_ALLOW);
desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
CONTENT_SETTING_ALLOW;
desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
@@ -127,16 +149,24 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] =
CONTENT_SETTING_ASK;
ContentSettings settings =
- host_content_settings_map->GetContentSettings(host);
+ host_content_settings_map->GetContentSettings(host, host);
EXPECT_TRUE(SettingsEqual(desired_settings, settings));
// Check returning all hosts for a setting.
ContentSettingsPattern pattern2 =
ContentSettingsPattern::FromString("[*.]example.org");
- host_content_settings_map->SetContentSetting(pattern2,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
- host_content_settings_map->SetContentSetting(pattern2,
- CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern2,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern2,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
HostContentSettingsMap::SettingsForOneType host_settings;
host_content_settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES,
"",
@@ -157,14 +187,30 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
// Check clearing one type.
ContentSettingsPattern pattern3 =
ContentSettingsPattern::FromString("[*.]example.net");
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
- host_content_settings_map->SetContentSetting(pattern2,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
- host_content_settings_map->SetContentSetting(pattern2,
- CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_BLOCK);
- host_content_settings_map->SetContentSetting(pattern3,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern3,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern2,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern2,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern3,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
host_content_settings_map->ClearSettingsForOneType(
CONTENT_SETTINGS_TYPE_IMAGES);
host_content_settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES,
@@ -190,23 +236,31 @@ TEST_F(HostContentSettingsMapTest, Patterns) {
ContentSettingsPattern::FromString("example.org");
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host1, CONTENT_SETTINGS_TYPE_IMAGES, ""));
- host_content_settings_map->SetContentSetting(pattern1,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host_content_settings_map->SetContentSetting(
+ pattern1,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host1, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host2, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host2, host2, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host3, CONTENT_SETTINGS_TYPE_IMAGES, ""));
- host_content_settings_map->SetContentSetting(pattern2,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host_content_settings_map->SetContentSetting(
+ pattern2,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host3, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, ""));
}
TEST_F(HostContentSettingsMapTest, Observer) {
@@ -215,20 +269,29 @@ TEST_F(HostContentSettingsMapTest, Observer) {
profile.GetHostContentSettingsMap();
MockSettingsObserver observer;
- ContentSettingsPattern pattern =
- ContentSettingsPattern::FromString("[*.]example.com");
+ ContentSettingsPattern primary_pattern =
+ ContentSettingsPattern::FromString("[*.]example.com");
+ ContentSettingsPattern secondary_pattern =
+ ContentSettingsPattern::Wildcard();
EXPECT_CALL(observer,
OnContentSettingsChanged(host_content_settings_map,
- CONTENT_SETTINGS_TYPE_IMAGES, false,
- pattern, false));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_ALLOW);
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ false,
+ primary_pattern,
+ secondary_pattern,
+ false));
+ host_content_settings_map->SetContentSetting(
+ primary_pattern,
+ secondary_pattern,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string(),
+ CONTENT_SETTING_ALLOW);
::testing::Mock::VerifyAndClearExpectations(&observer);
EXPECT_CALL(observer,
OnContentSettingsChanged(host_content_settings_map,
CONTENT_SETTINGS_TYPE_IMAGES, false,
- _, true));
+ _, _, true));
host_content_settings_map->ClearSettingsForOneType(
CONTENT_SETTINGS_TYPE_IMAGES);
::testing::Mock::VerifyAndClearExpectations(&observer);
@@ -236,7 +299,7 @@ TEST_F(HostContentSettingsMapTest, Observer) {
EXPECT_CALL(observer,
OnContentSettingsChanged(host_content_settings_map,
CONTENT_SETTINGS_TYPE_IMAGES, false,
- _, true));
+ _, _, true));
host_content_settings_map->SetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
}
@@ -292,8 +355,12 @@ TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) {
ContentSettingsPattern::FromString("[*.]example.com");
GURL host("http://example.com");
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ std::string(),
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetCookieContentSetting(
host, host, true));
@@ -326,73 +393,149 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) {
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_DEFAULT);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ std::string()));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ "",
+ CONTENT_SETTING_DEFAULT);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ "",
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetCookieContentSetting(
host_ending_with_dot, host_ending_with_dot, true));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_DEFAULT);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ "",
+ CONTENT_SETTING_DEFAULT);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetCookieContentSetting(
host_ending_with_dot, host_ending_with_dot, true));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ "",
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetCookieContentSetting(
host_ending_with_dot, host_ending_with_dot, true));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_DEFAULT);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ "",
+ CONTENT_SETTING_DEFAULT);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_BLOCK);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ "",
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_DEFAULT);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ "",
+ CONTENT_SETTING_DEFAULT);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_BLOCK);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ "",
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ ""));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_POPUPS, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_POPUPS, "", CONTENT_SETTING_DEFAULT);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ "",
+ CONTENT_SETTING_DEFAULT);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_POPUPS, ""));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_POPUPS, "", CONTENT_SETTING_ALLOW);
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ ""));
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ "",
+ CONTENT_SETTING_ALLOW);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host_ending_with_dot, CONTENT_SETTINGS_TYPE_POPUPS, ""));
+ host_ending_with_dot,
+ host_ending_with_dot,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ ""));
}
TEST_F(HostContentSettingsMapTest, NestedSettings) {
@@ -408,12 +551,26 @@ TEST_F(HostContentSettingsMapTest, NestedSettings) {
ContentSettingsPattern pattern3 =
ContentSettingsPattern::FromString("a.b.example.com");
- host_content_settings_map->SetContentSetting(pattern1,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
- host_content_settings_map->SetContentSetting(pattern2,
- CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK);
- host_content_settings_map->SetContentSetting(pattern3,
- CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern1,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ "",
+ CONTENT_SETTING_BLOCK);
+
+ host_content_settings_map->SetContentSetting(
+ pattern2,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ "",
+ CONTENT_SETTING_BLOCK);
+
+ host_content_settings_map->SetContentSetting(
+ pattern3,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ "",
+ CONTENT_SETTING_BLOCK);
host_content_settings_map->SetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
@@ -433,7 +590,7 @@ TEST_F(HostContentSettingsMapTest, NestedSettings) {
desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] =
CONTENT_SETTING_ASK;
ContentSettings settings =
- host_content_settings_map->GetContentSettings(host);
+ host_content_settings_map->GetContentSettings(host, host);
EXPECT_TRUE(SettingsEqual(desired_settings, settings));
EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES],
settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]);
@@ -464,32 +621,38 @@ TEST_F(HostContentSettingsMapTest, OffTheRecord) {
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
otr_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
// Changing content settings on the main map should also affect the
// incognito map.
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ "",
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
otr_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
// Changing content settings on the incognito map should NOT affect the
// main map.
- otr_map->SetContentSetting(pattern,
+ otr_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_ALLOW);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
otr_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ host, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
}
TEST_F(HostContentSettingsMapTest, MigrateObsoletePrefs) {
@@ -519,7 +682,7 @@ TEST_F(HostContentSettingsMapTest, MigrateObsoletePrefs) {
GURL host("http://example.com");
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_POPUPS, ""));
+ host, host, CONTENT_SETTINGS_TYPE_POPUPS, ""));
}
TEST_F(HostContentSettingsMapTest, MigrateObsoleteNotificationsPrefs) {
@@ -560,7 +723,7 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeOnly) {
DictionaryValue* dummy_payload = new DictionaryValue;
dummy_payload->SetInteger("images", CONTENT_SETTING_ALLOW);
- all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com",
+ all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*",
dummy_payload);
}
profile.GetHostContentSettingsMap();
@@ -569,9 +732,9 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeOnly) {
prefs->GetDictionary(prefs::kContentSettingsPatterns);
DictionaryValue* result = NULL;
EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
- "[*.]\xC4\x87ira.com", &result));
+ "[*.]\xC4\x87ira.com,*", &result));
EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion(
- "[*.]xn--ira-ppa.com", &result));
+ "[*.]xn--ira-ppa.com,*", &result));
}
// If both Unicode and its punycode pattern exist, make sure we don't touch the
@@ -585,12 +748,12 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) {
TestingProfile profile;
scoped_ptr<Value> value(base::JSONReader::Read(
- "{\"[*.]\\xC4\\x87ira.com\":{\"per_plugin\":{\"pluginx\":2}}}", false));
+ "{\"[*.]\\xC4\\x87ira.com,*\":{\"per_plugin\":{\"pluginx\":2}}}", false));
profile.GetPrefs()->Set(prefs::kContentSettingsPatterns, *value);
// Set punycode equivalent, with different setting.
scoped_ptr<Value> puny_value(base::JSONReader::Read(
- "{\"[*.]xn--ira-ppa.com\":{\"per_plugin\":{\"pluginy\":2}}}", false));
+ "{\"[*.]xn--ira-ppa.com,*\":{\"per_plugin\":{\"pluginy\":2}}}", false));
profile.GetPrefs()->Set(prefs::kContentSettingsPatterns, *puny_value);
// Initialize the content map.
@@ -600,7 +763,7 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) {
profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatterns);
std::string prefs_as_json;
base::JSONWriter::Write(content_setting_prefs, false, &prefs_as_json);
- EXPECT_STREQ("{\"[*.]xn--ira-ppa.com\":{\"per_plugin\":{\"pluginy\":2}}}",
+ EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"per_plugin\":{\"pluginy\":2}}}",
prefs_as_json.c_str());
}
@@ -615,15 +778,19 @@ TEST_F(HostContentSettingsMapTest, NonDefaultSettings) {
ContentSettings desired_settings(CONTENT_SETTING_DEFAULT);
ContentSettings settings =
- host_content_settings_map->GetNonDefaultContentSettings(host);
+ host_content_settings_map->GetNonDefaultContentSettings(host, host);
EXPECT_TRUE(SettingsEqual(desired_settings, settings));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ "",
+ CONTENT_SETTING_BLOCK);
desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] =
CONTENT_SETTING_BLOCK;
settings =
- host_content_settings_map->GetNonDefaultContentSettings(host);
+ host_content_settings_map->GetNonDefaultContentSettings(host, host);
EXPECT_TRUE(SettingsEqual(desired_settings, settings));
}
@@ -645,21 +812,26 @@ TEST_F(HostContentSettingsMapTest, ResourceIdentifier) {
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS, resource1, CONTENT_SETTING_BLOCK);
+ host, host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1));
+
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ resource1,
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1));
+ host, host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_PLUGINS, resource2));
+ host, host, CONTENT_SETTINGS_TYPE_PLUGINS, resource2));
// If resource content settings are enabled GetContentSettings should return
// CONTENT_SETTING_DEFAULT for content types that require resource
// identifiers.
ContentSettings settings =
- host_content_settings_map->GetContentSettings(host);
+ host_content_settings_map->GetContentSettings(host, host);
EXPECT_EQ(CONTENT_SETTING_DEFAULT,
settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]);
}
@@ -672,23 +844,29 @@ TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) {
TestingProfile profile;
scoped_ptr<Value> value(base::JSONReader::Read(
- "{\"[*.]example.com\":{\"per_plugin\":{\"someplugin\":2}}}", false));
+ "{\"[*.]example.com,*\":{\"per_plugin\":{\"someplugin\":2}}}", false));
profile.GetPrefs()->Set(prefs::kContentSettingsPatterns, *value);
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
GURL host("http://example.com/");
- ContentSettingsPattern pattern =
+ ContentSettingsPattern item_pattern =
ContentSettingsPattern::FromString("[*.]example.com");
+ ContentSettingsPattern top_level_frame_pattern =
+ ContentSettingsPattern::Wildcard();
std::string resource1("someplugin");
std::string resource2("otherplugin");
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1));
+ host, host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1));
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS, resource1, CONTENT_SETTING_DEFAULT);
+ host_content_settings_map->SetContentSetting(
+ item_pattern,
+ top_level_frame_pattern,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ resource1,
+ CONTENT_SETTING_DEFAULT);
const DictionaryValue* content_setting_prefs =
profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatterns);
@@ -696,13 +874,17 @@ TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) {
base::JSONWriter::Write(content_setting_prefs, false, &prefs_as_json);
EXPECT_STREQ("{}", prefs_as_json.c_str());
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_PLUGINS, resource2, CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ item_pattern,
+ top_level_frame_pattern,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ resource2,
+ CONTENT_SETTING_BLOCK);
content_setting_prefs =
profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatterns);
base::JSONWriter::Write(content_setting_prefs, false, &prefs_as_json);
- EXPECT_STREQ("{\"[*.]example.com\":{\"per_plugin\":{\"otherplugin\":2}}}",
+ EXPECT_STREQ("{\"[*.]example.com,*\":{\"per_plugin\":{\"otherplugin\":2}}}",
prefs_as_json.c_str());
}
@@ -755,8 +937,12 @@ TEST_F(HostContentSettingsMapTest,
// Set pattern for JavaScript setting.
ContentSettingsPattern pattern =
ContentSettingsPattern::FromString("[*.]example.com");
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ "",
+ CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetDefaultContentSetting(
@@ -765,14 +951,14 @@ TEST_F(HostContentSettingsMapTest,
GURL host("http://example.com/");
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
// Set managed-default-content-setting for content-settings-type JavaScript.
prefs->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting,
Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
}
// Managed default content setting should have higher priority
@@ -791,8 +977,13 @@ TEST_F(HostContentSettingsMapTest,
// Set an exception to allow "[*.]example.com"
ContentSettingsPattern pattern =
ContentSettingsPattern::FromString("[*.]example.com");
- host_content_settings_map->SetContentSetting(pattern,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", CONTENT_SETTING_ALLOW);
+
+ host_content_settings_map->SetContentSetting(
+ pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ "",
+ CONTENT_SETTING_ALLOW);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetDefaultContentSetting(
@@ -800,20 +991,20 @@ TEST_F(HostContentSettingsMapTest,
GURL host("http://example.com/");
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
// Set managed-default-content-settings-preferences.
prefs->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting,
Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
// Remove managed-default-content-settings-preferences.
prefs->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
- host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
}
// If a default-content-setting is set to managed setting, the user defined
@@ -911,7 +1102,10 @@ TEST_F(HostContentSettingsMapTest, CookiesBlockSingle) {
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
host_content_settings_map->AddExceptionForURL(
- kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
+ kBlockedSite,
+ kBlockedSite,
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ "",
CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetCookieContentSetting(
@@ -959,7 +1153,7 @@ TEST_F(HostContentSettingsMapTest, CookiesExplicitBlockSingleThirdParty) {
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
host_content_settings_map->AddExceptionForURL(
- kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
+ kBlockedSite, kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
CONTENT_SETTING_BLOCK);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
host_content_settings_map->GetCookieContentSetting(
@@ -977,7 +1171,7 @@ TEST_F(HostContentSettingsMapTest, CookiesExplicitSessionOnly) {
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
host_content_settings_map->AddExceptionForURL(
- kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
+ kBlockedSite, kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
CONTENT_SETTING_SESSION_ONLY);
EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY,
host_content_settings_map->GetCookieContentSetting(
@@ -1000,7 +1194,7 @@ TEST_F(HostContentSettingsMapTest, CookiesThirdPartyAlwaysBlocked) {
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
host_content_settings_map->AddExceptionForURL(
- kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
+ kAllowedSite, kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
CONTENT_SETTING_ALLOW);
host_content_settings_map->SetBlockThirdPartyCookies(true);
EXPECT_EQ(CONTENT_SETTING_ALLOW,
@@ -1060,7 +1254,7 @@ TEST_F(HostContentSettingsMapTest, CookiesBlockEverythingExceptAllowed) {
host_content_settings_map->SetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK);
host_content_settings_map->AddExceptionForURL(
- kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
+ kAllowedSite, kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "",
CONTENT_SETTING_ALLOW);
EXPECT_EQ(CONTENT_SETTING_BLOCK,
diff --git a/chrome/browser/content_settings/mock_settings_observer.cc b/chrome/browser/content_settings/mock_settings_observer.cc
index e5c6470..b968f3f 100644
--- a/chrome/browser/content_settings/mock_settings_observer.cc
+++ b/chrome/browser/content_settings/mock_settings_observer.cc
@@ -27,9 +27,11 @@ void MockSettingsObserver::Observe(NotificationType type,
OnContentSettingsChanged(map,
settings_details->type(),
settings_details->update_all_types(),
- settings_details->pattern(),
+ settings_details->primary_pattern(),
+ settings_details->secondary_pattern(),
settings_details->update_all());
// This checks that calling a Get function from an observer doesn't
// deadlock.
- map->GetContentSettings(GURL("http://random-hostname.com/"));
+ map->GetContentSettings(GURL("http://random-hostname.com/"),
+ GURL("http://random-hostname.com/"));
}
diff --git a/chrome/browser/content_settings/mock_settings_observer.h b/chrome/browser/content_settings/mock_settings_observer.h
index 082a719..d96c6f7 100644
--- a/chrome/browser/content_settings/mock_settings_observer.h
+++ b/chrome/browser/content_settings/mock_settings_observer.h
@@ -23,11 +23,12 @@ class MockSettingsObserver : public NotificationObserver {
const NotificationSource& source,
const NotificationDetails& details);
- MOCK_METHOD5(OnContentSettingsChanged,
+ MOCK_METHOD6(OnContentSettingsChanged,
void(HostContentSettingsMap*,
ContentSettingsType,
bool,
const ContentSettingsPattern&,
+ const ContentSettingsPattern&,
bool));
private:
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc
index 7ee612b..0a8716a 100644
--- a/chrome/browser/content_settings/tab_specific_content_settings.cc
+++ b/chrome/browser/content_settings/tab_specific_content_settings.cc
@@ -450,7 +450,7 @@ void TabSpecificContentSettings::DidStartProvisionalLoadForFrame(
tab_contents()->profile()->GetHostContentSettingsMap();
render_view_host->Send(new ViewMsg_SetContentSettingsForLoadingURL(
render_view_host->routing_id(), validated_url,
- map->GetContentSettings(validated_url)));
+ map->GetContentSettings(validated_url, validated_url)));
}
void TabSpecificContentSettings::Observe(NotificationType type,
@@ -465,10 +465,12 @@ void TabSpecificContentSettings::Observe(NotificationType type,
if (entry)
entry_url = entry->url();
if (settings_details.ptr()->update_all() ||
- settings_details.ptr()->pattern().Matches(entry_url)) {
+ // The active NavigationEntry is the URL in the URL field of a tab.
+ // Currently this should be matched by the |primary_pattern|.
+ settings_details.ptr()->primary_pattern().Matches(entry_url)) {
Send(new ViewMsg_SetContentSettingsForCurrentURL(
entry_url, tab_contents()->profile()->GetHostContentSettingsMap()->
- GetContentSettings(entry_url)));
+ GetContentSettings(entry_url, entry_url)));
}
}
diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc
index 0b6c790..f4d18f7 100644
--- a/chrome/browser/cookies_tree_model.cc
+++ b/chrome/browser/cookies_tree_model.cc
@@ -403,6 +403,7 @@ void CookieTreeOriginNode::CreateContentException(
HostContentSettingsMap* content_settings, ContentSetting setting) const {
if (CanCreateContentException()) {
content_settings->AddExceptionForURL(url_,
+ url_,
CONTENT_SETTINGS_TYPE_COOKIES,
"",
setting);
diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc
index e80b326..f97e9d4 100644
--- a/chrome/browser/cookies_tree_model_unittest.cc
+++ b/chrome/browser/cookies_tree_model_unittest.cc
@@ -841,8 +841,6 @@ TEST_F(CookiesTreeModelTest, OriginOrdering) {
TEST_F(CookiesTreeModelTest, ContentSettings) {
GURL host("http://example.com/");
- ContentSettingsPattern pattern =
- ContentSettingsPattern::FromString("[*.]example.com");
net::CookieMonster* monster = profile_->GetCookieMonster();
monster->SetCookie(host, "A=1");
@@ -867,13 +865,20 @@ TEST_F(CookiesTreeModelTest, ContentSettings) {
EXPECT_EQ(1, origin->child_count());
EXPECT_TRUE(origin->CanCreateContentException());
EXPECT_CALL(observer,
- OnContentSettingsChanged(content_settings,
- CONTENT_SETTINGS_TYPE_COOKIES, false,
- _, false));
+ OnContentSettingsChanged(
+ content_settings,
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ false,
+ ContentSettingsPattern::FromURLNoWildcard(host),
+ ContentSettingsPattern::Wildcard(),
+ false));
EXPECT_CALL(observer,
OnContentSettingsChanged(content_settings,
- CONTENT_SETTINGS_TYPE_COOKIES, false,
- pattern, false));
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ false,
+ ContentSettingsPattern::FromURL(host),
+ ContentSettingsPattern::Wildcard(),
+ false));
origin->CreateContentException(
content_settings, CONTENT_SETTING_SESSION_ONLY);
EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY,
diff --git a/chrome/browser/extensions/extension_content_settings_api.cc b/chrome/browser/extensions/extension_content_settings_api.cc
index c17ac6c..eaed7c0 100644
--- a/chrome/browser/extensions/extension_content_settings_api.cc
+++ b/chrome/browser/extensions/extension_content_settings_api.cc
@@ -146,7 +146,7 @@ bool GetContentSettingFunction::RunImpl() {
setting = map->GetCookieContentSetting(embedded_url, top_level_url,
setting_cookie);
} else {
- setting = map->GetContentSetting(top_level_url, content_type,
+ setting = map->GetContentSetting(embedded_url, top_level_url, content_type,
resource_identifier);
}
diff --git a/chrome/browser/extensions/extension_content_settings_apitest.cc b/chrome/browser/extensions/extension_content_settings_apitest.cc
index 078c009..11411df 100644
--- a/chrome/browser/extensions/extension_content_settings_apitest.cc
+++ b/chrome/browser/extensions/extension_content_settings_apitest.cc
@@ -35,31 +35,40 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) {
// Check default content settings by using an unknown URL.
GURL example_url("http://www.example.com");
EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY,
- map->GetCookieContentSetting(example_url, example_url,
- false));
+ map->GetCookieContentSetting(
+ example_url, example_url, false));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(example_url, CONTENT_SETTINGS_TYPE_IMAGES,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_IMAGES,
std::string()));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetContentSetting(example_url,
+ example_url,
CONTENT_SETTINGS_TYPE_JAVASCRIPT,
std::string()));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(example_url, CONTENT_SETTINGS_TYPE_PLUGINS,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
std::string()));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(example_url, CONTENT_SETTINGS_TYPE_POPUPS,
+ map->GetContentSetting(example_url,
+ example_url,
+ CONTENT_SETTINGS_TYPE_POPUPS,
std::string()));
#if 0
// TODO(bauerb): Enable once geolocation settings are integrated into the
// HostContentSettingsMap.
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(example_url,
+ example_url,
CONTENT_SETTINGS_TYPE_GEOLOCATION,
std::string()));
#endif
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(example_url,
+ example_url,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
std::string()));
@@ -68,20 +77,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) {
EXPECT_EQ(CONTENT_SETTING_BLOCK,
map->GetCookieContentSetting(url, url, false));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
- map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_POPUPS, ""));
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_POPUPS, ""));
#if 0
EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_GEOLOCATION, ""));
#endif
EXPECT_EQ(CONTENT_SETTING_BLOCK,
- map->GetContentSetting(url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
- ""));
+ map->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, ""));
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PersistentIncognitoContentSettings) {
diff --git a/chrome/browser/geolocation/geolocation_content_settings_map.cc b/chrome/browser/geolocation/geolocation_content_settings_map.cc
index 443ecc8..8f65eb5 100644
--- a/chrome/browser/geolocation/geolocation_content_settings_map.cc
+++ b/chrome/browser/geolocation/geolocation_content_settings_map.cc
@@ -212,6 +212,7 @@ void GeolocationContentSettingsMap::Observe(
const std::string& name = *Details<std::string>(details).ptr();
if (name == prefs::kGeolocationDefaultContentSetting) {
ContentSettingsDetails details(ContentSettingsPattern(),
+ ContentSettingsPattern(),
CONTENT_SETTINGS_TYPE_DEFAULT,
std::string());
NotifyObservers(details);
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 65a1da2..04ec476 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -59,8 +59,8 @@ void GetOriginsWithSettingFromContentSettingsRules(
rule != content_setting_rules.end();
++rule) {
if (setting == rule->content_setting) {
- std::string url_str = rule->requesting_url_pattern.ToString();
- if (!rule->requesting_url_pattern.IsValid()) {
+ std::string url_str = rule->primary_pattern.ToString();
+ if (!rule->primary_pattern.IsValid()) {
// TODO(markusheintz): This will be removed in one of the next
// refactoring steps as this entire function will disapear.
LOG(DFATAL) << "Ignoring invalid content settings pattern: "
@@ -76,7 +76,7 @@ void GetOriginsWithSettingFromContentSettingsRules(
} else {
origins->push_back(
content_settings::NotificationProvider::ToGURL(
- rule->requesting_url_pattern));
+ rule->primary_pattern));
}
}
}
diff --git a/chrome/browser/plugin_exceptions_table_model.cc b/chrome/browser/plugin_exceptions_table_model.cc
index c6b310b..abbe3b9 100644
--- a/chrome/browser/plugin_exceptions_table_model.cc
+++ b/chrome/browser/plugin_exceptions_table_model.cc
@@ -41,6 +41,7 @@ void PluginExceptionsTableModel::RemoveRows(const Rows& rows) {
SettingsEntry entry = settings_[*it];
HostContentSettingsMap* map = entry.is_otr ? otr_map_ : map_;
map->SetContentSetting(entry.pattern,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
resources_[entry.plugin_id],
CONTENT_SETTING_DEFAULT);
diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc
index 80b3526..54c9e87 100644
--- a/chrome/browser/plugin_exceptions_table_model_unittest.cc
+++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc
@@ -72,14 +72,17 @@ class PluginExceptionsTableModelTest : public testing::Test {
ContentSettingsPattern moose_org =
ContentSettingsPattern::FromString("[*.]moose.org");
map->SetContentSetting(example_com,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"a-foo",
CONTENT_SETTING_ALLOW);
map->SetContentSetting(moose_org,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"b-bar",
CONTENT_SETTING_BLOCK);
map->SetContentSetting(example_com,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"b-bar",
CONTENT_SETTING_ALLOW);
@@ -188,6 +191,7 @@ TEST_F(PluginExceptionsTableModelTest, RemoveLastRowInGroup) {
HostContentSettingsMap* map = profile_->GetHostContentSettingsMap();
EXPECT_CALL(observer, OnModelChanged());
map->SetContentSetting(ContentSettingsPattern::FromString("[*.]blurp.net"),
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"b-bar",
CONTENT_SETTING_BLOCK);
diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc
index 906950b..0d7c47a 100644
--- a/chrome/browser/plugin_observer.cc
+++ b/chrome/browser/plugin_observer.cc
@@ -159,7 +159,10 @@ bool BlockedPluginInfoBarDelegate::Cancel() {
UserMetrics::RecordAction(
UserMetricsAction("BlockedPluginInfobar.AlwaysAllow"));
tab_contents_->profile()->GetHostContentSettingsMap()->AddExceptionForURL(
- tab_contents_->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(),
+ tab_contents_->GetURL(),
+ tab_contents_->GetURL(),
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string(),
CONTENT_SETTING_ALLOW);
return PluginInfoBarDelegate::Cancel();
}
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 15852e2..a43e231 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -453,7 +453,10 @@ void ChromeRenderMessageFilter::OnGetPluginContentSetting(
const std::string& resource,
ContentSetting* setting) {
*setting = host_content_settings_map_->GetContentSetting(
- policy_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource);
+ policy_url,
+ policy_url,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ resource);
}
void ChromeRenderMessageFilter::OnCanTriggerClipboardRead(const GURL& url,
diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
index f0d73ef0..1eb3213 100644
--- a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
+++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
@@ -85,7 +85,10 @@ void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents,
if (creator.is_valid() &&
tab_contents()->profile()->GetHostContentSettingsMap()->GetContentSetting(
- creator, CONTENT_SETTINGS_TYPE_POPUPS, "") == CONTENT_SETTING_ALLOW) {
+ creator,
+ creator,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ "") == CONTENT_SETTING_ALLOW) {
tab_contents()->AddNewContents(new_contents->tab_contents(),
NEW_POPUP,
initial_pos,
diff --git a/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm b/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm
index f7ce628..4666252 100644
--- a/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm
@@ -38,14 +38,17 @@ class TableModelArrayControllerTest : public CocoaTest {
ContentSettingsPattern moose_org =
ContentSettingsPattern::FromString("[*.]moose.org");
map->SetContentSetting(example_com,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"a-foo",
CONTENT_SETTING_ALLOW);
map->SetContentSetting(moose_org,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"b-bar",
CONTENT_SETTING_BLOCK);
map->SetContentSetting(example_com,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"b-bar",
CONTENT_SETTING_ALLOW);
@@ -147,6 +150,7 @@ TEST_F(TableModelArrayControllerTest, AddException) {
ContentSettingsPattern example_com =
ContentSettingsPattern::FromString("[*.]example.com");
map->SetContentSetting(example_com,
+ ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
"c-blurp",
CONTENT_SETTING_BLOCK);
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
index 7dff1b9..f4e0791 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -258,12 +258,13 @@ class ContentSettingSingleRadioGroup
mostRestrictiveSetting =
content_type() == CONTENT_SETTINGS_TYPE_COOKIES ?
map->GetCookieContentSetting(url, url, true) :
- map->GetContentSetting(url, content_type(), std::string());
+ map->GetContentSetting(url, url, content_type(), std::string());
} else {
mostRestrictiveSetting = CONTENT_SETTING_ALLOW;
for (std::set<std::string>::const_iterator it = resources.begin();
it != resources.end(); ++it) {
ContentSetting setting = map->GetContentSetting(url,
+ url,
content_type(),
*it);
if (setting == CONTENT_SETTING_BLOCK) {
@@ -288,7 +289,10 @@ class ContentSettingSingleRadioGroup
void AddException(ContentSetting setting,
const std::string& resource_identifier) {
profile()->GetHostContentSettingsMap()->AddExceptionForURL(
- bubble_content().radio_group.url, content_type(), resource_identifier,
+ bubble_content().radio_group.url,
+ bubble_content().radio_group.url,
+ content_type(),
+ resource_identifier,
setting);
}
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
index fcf5818..65e2c0f 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
@@ -117,10 +117,12 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) {
contents()->NavigateAndCommit(GURL("http://www.example.com"));
GURL url = contents()->GetURL();
map->AddExceptionForURL(url,
+ url,
CONTENT_SETTINGS_TYPE_PLUGINS,
fooPlugin,
CONTENT_SETTING_ALLOW);
map->AddExceptionForURL(url,
+ url,
CONTENT_SETTINGS_TYPE_PLUGINS,
barPlugin,
CONTENT_SETTING_ASK);
@@ -145,10 +147,12 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) {
// Nothing should have changed.
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url,
+ url,
CONTENT_SETTINGS_TYPE_PLUGINS,
fooPlugin));
EXPECT_EQ(CONTENT_SETTING_ASK,
map->GetContentSetting(url,
+ url,
CONTENT_SETTINGS_TYPE_PLUGINS,
barPlugin));
@@ -156,10 +160,12 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) {
// Both plug-ins should be click-to-play now.
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url,
+ url,
CONTENT_SETTINGS_TYPE_PLUGINS,
fooPlugin));
EXPECT_EQ(CONTENT_SETTING_ALLOW,
map->GetContentSetting(url,
+ url,
CONTENT_SETTINGS_TYPE_PLUGINS,
barPlugin));
}
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
index 3e90918..bc21b847 100644
--- a/chrome/browser/ui/webui/options/content_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -13,6 +13,7 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/content_settings_details.h"
+#include "chrome/browser/content_settings/content_settings_utils.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
@@ -656,6 +657,7 @@ void ContentSettingsHandler::RemoveException(const ListValue* args) {
if (settings_map) {
settings_map->SetContentSetting(
ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
ContentSettingsTypeFromGroupName(type_string),
"",
CONTENT_SETTING_DEFAULT);
@@ -689,9 +691,8 @@ void ContentSettingsHandler::SetException(const ListValue* args) {
// got destroyed before we received this message.
if (!settings_map)
return;
-
- settings_map->SetContentSetting(ContentSettingsPattern::FromString(
- pattern),
+ settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
type,
"",
ContentSettingFromString(setting));
diff --git a/chrome/test/functional/cookies.py b/chrome/test/functional/cookies.py
index 1081640..c4685c6 100644
--- a/chrome/test/functional/cookies.py
+++ b/chrome/test/functional/cookies.py
@@ -120,7 +120,7 @@ class CookiesTest(pyauto.PyUITest):
# Creating an exception to allow cookies from http://www.google.com.
self.SetPrefs(pyauto.kContentSettingsPatterns,
- {'[*.]google.com': { 'cookies': 1}})
+ {'[*.]google.com,*': { 'cookies': 1}})
# Navigate to google.com and check if cookies are set.
self.NavigateToURL('http://www.google.com')
self.assertTrue(self.GetCookie(pyauto.GURL('http://www.google.com')),
@@ -134,7 +134,7 @@ class CookiesTest(pyauto.PyUITest):
# Create an exception to block cookies from http://www.google.com
self.SetPrefs(pyauto.kContentSettingsPatterns,
- {'[*.]google.com': { 'cookies': 2}})
+ {'[*.]google.com,*': { 'cookies': 2}})
# Navigate to google.com and check if cookies are blocked.
self.NavigateToURL('http://www.google.com')
@@ -160,7 +160,7 @@ class CookiesTest(pyauto.PyUITest):
# Creating an exception to allow cookies for a session for google.com.
self.SetPrefs(pyauto.kContentSettingsPatterns,
- {'[*.]google.com': { 'cookies': 4}})
+ {'[*.]google.com,*': { 'cookies': 4}})
# Navigate to google.com and check if cookies are set.
self.NavigateToURL('http://www.google.com')
diff --git a/chrome/test/functional/plugins.py b/chrome/test/functional/plugins.py
index 0fff1e0..3ec84ef 100644
--- a/chrome/test/functional/plugins.py
+++ b/chrome/test/functional/plugins.py
@@ -199,7 +199,7 @@ class PluginsTest(pyauto.PyUITest):
# Add an exception to allow plugins on hulu.com.
self.SetPrefs(pyauto.kContentSettingsPatterns,
- {'[*.]hulu.com': {'plugins': 1}})
+ {'[*.]hulu.com,*': {'plugins': 1}})
self.AppendTab(pyauto.GURL('http://www.hulu.com'))
self.assertTrue(self._GetPluginPID('Shockwave Flash'),
msg='No plugin process for Shockwave Flash')
@@ -221,7 +221,7 @@ class PluginsTest(pyauto.PyUITest):
# Add an exception to block plugins on localhost.
self.SetPrefs(pyauto.kContentSettingsPatterns,
- {'[*.]127.0.0.1': {'plugins': 2}})
+ {'[*.]127.0.0.1,*': {'plugins': 2}})
self.GetBrowserWindow(0).GetTab(0).Reload()
self.assertFalse(self._GetPluginPID('Shockwave Flash'),
msg='Shockwave Flash Plug-in not blocked.')
diff --git a/chrome/test/functional/popups.py b/chrome/test/functional/popups.py
index 384afd6..3509766 100644
--- a/chrome/test/functional/popups.py
+++ b/chrome/test/functional/popups.py
@@ -106,7 +106,7 @@ class PopupsTest(pyauto.PyUITest):
def _SetPopupsException(self):
"""Set an exception to allow popups from www.popuptest.com."""
- value = {'[*.]www.popuptest.com': {'popups': 1}}
+ value = {'[*.]www.popuptest.com,*': {'popups': 1}}
return self.SetPrefs(pyauto.kContentSettingsPatterns, value)
def testAllowPopupsFromExternalSite(self):