diff options
Diffstat (limited to 'chrome/browser/content_settings')
15 files changed, 409 insertions, 327 deletions
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc index 88c664c..f4105ad 100644 --- a/chrome/browser/content_settings/content_settings_browsertest.cc +++ b/chrome/browser/content_settings/content_settings_browsertest.cc @@ -338,12 +338,12 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); - browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( - ContentSettingsPattern::FromURL(url), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - "", - CONTENT_SETTING_ALLOW); + browser()->profile()->GetHostContentSettingsMap() + ->SetContentSetting(ContentSettingsPattern::FromURL(url), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTINGS_TYPE_PLUGINS, + std::string(), + CONTENT_SETTING_ALLOW); string16 expected_title(ASCIIToUTF16("OK")); content::TitleWatcher title_watcher( @@ -357,12 +357,12 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, BlockException) { GURL url = ui_test_utils::GetTestUrl( base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); - browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( - ContentSettingsPattern::FromURL(url), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - "", - CONTENT_SETTING_BLOCK); + browser()->profile()->GetHostContentSettingsMap() + ->SetContentSetting(ContentSettingsPattern::FromURL(url), + ContentSettingsPattern::Wildcard(), + CONTENT_SETTINGS_TYPE_PLUGINS, + std::string(), + CONTENT_SETTING_BLOCK); string16 expected_title(ASCIIToUTF16("Click To Play")); content::TitleWatcher title_watcher( diff --git a/chrome/browser/content_settings/content_settings_internal_extension_provider.cc b/chrome/browser/content_settings/content_settings_internal_extension_provider.cc index 815d037..56dd993 100644 --- a/chrome/browser/content_settings/content_settings_internal_extension_provider.cc +++ b/chrome/browser/content_settings/content_settings_internal_extension_provider.cc @@ -117,19 +117,19 @@ void InternalExtensionProvider::SetContentSettingForExtension( value_map_.DeleteValue(primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_PLUGINS, - ResourceIdentifier("")); + ResourceIdentifier()); } else { value_map_.SetValue(primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_PLUGINS, - ResourceIdentifier(""), + ResourceIdentifier(), Value::CreateIntegerValue(setting)); } } NotifyObservers(primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_PLUGINS, - ResourceIdentifier("")); + ResourceIdentifier()); } } // namespace content_settings diff --git a/chrome/browser/content_settings/content_settings_origin_identifier_value_map_unittest.cc b/chrome/browser/content_settings/content_settings_origin_identifier_value_map_unittest.cc index 21089fb..b8612a5 100644 --- a/chrome/browser/content_settings/content_settings_origin_identifier_value_map_unittest.cc +++ b/chrome/browser/content_settings/content_settings_origin_identifier_value_map_unittest.cc @@ -14,38 +14,40 @@ TEST(OriginIdentifierValueMapTest, SetGetValue) { content_settings::OriginIdentifierValueMap map; - EXPECT_EQ(NULL, map.GetValue(GURL("http://www.google.com"), - GURL("http://www.google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "")); - map.SetValue( - ContentSettingsPattern::FromString("[*.]google.com"), - ContentSettingsPattern::FromString("[*.]google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(1)); + EXPECT_EQ(NULL, + map.GetValue(GURL("http://www.google.com"), + GURL("http://www.google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string())); + map.SetValue(ContentSettingsPattern::FromString("[*.]google.com"), + ContentSettingsPattern::FromString("[*.]google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(1)); scoped_ptr<Value> expected_value(Value::CreateIntegerValue(1)); - EXPECT_TRUE(expected_value->Equals( - map.GetValue(GURL("http://www.google.com"), - GURL("http://www.google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - ""))); - - EXPECT_EQ(NULL, map.GetValue(GURL("http://www.google.com"), - GURL("http://www.youtube.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "")); - - EXPECT_EQ(NULL, map.GetValue(GURL("http://www.youtube.com"), - GURL("http://www.google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "")); - - EXPECT_EQ(NULL, map.GetValue(GURL("http://www.google.com"), - GURL("http://www.google.com"), - CONTENT_SETTINGS_TYPE_POPUPS, - "")); + EXPECT_TRUE(expected_value->Equals(map.GetValue(GURL("http://www.google.com"), + GURL("http://www.google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string()))); + + EXPECT_EQ(NULL, + map.GetValue(GURL("http://www.google.com"), + GURL("http://www.youtube.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string())); + + EXPECT_EQ(NULL, + map.GetValue(GURL("http://www.youtube.com"), + GURL("http://www.google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string())); + + EXPECT_EQ(NULL, + map.GetValue(GURL("http://www.google.com"), + GURL("http://www.google.com"), + CONTENT_SETTINGS_TYPE_POPUPS, + std::string())); EXPECT_EQ(NULL, map.GetValue(GURL("http://www.google.com"), GURL("http://www.google.com"), @@ -119,12 +121,11 @@ TEST(OriginIdentifierValueMapTest, Clear) { CONTENT_SETTINGS_TYPE_PLUGINS, "java-plugin", Value::CreateIntegerValue(1)); - map.SetValue( - ContentSettingsPattern::FromString("[*.]google.com"), - ContentSettingsPattern::FromString("[*.]google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(1)); + map.SetValue(ContentSettingsPattern::FromString("[*.]google.com"), + ContentSettingsPattern::FromString("[*.]google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(1)); EXPECT_FALSE(map.empty()); int actual_value; EXPECT_TRUE(map.GetValue(GURL("http://www.google.com"), @@ -145,38 +146,36 @@ TEST(OriginIdentifierValueMapTest, Clear) { TEST(OriginIdentifierValueMapTest, ListEntryPrecedences) { content_settings::OriginIdentifierValueMap map; - map.SetValue( - ContentSettingsPattern::FromString("[*.]google.com"), - ContentSettingsPattern::FromString("[*.]google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(1)); + map.SetValue(ContentSettingsPattern::FromString("[*.]google.com"), + ContentSettingsPattern::FromString("[*.]google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(1)); - map.SetValue( - ContentSettingsPattern::FromString("www.google.com"), - ContentSettingsPattern::FromString("[*.]google.com"), - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(2)); + map.SetValue(ContentSettingsPattern::FromString("www.google.com"), + ContentSettingsPattern::FromString("[*.]google.com"), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(2)); int actual_value; EXPECT_TRUE(map.GetValue(GURL("http://mail.google.com"), GURL("http://www.google.com"), CONTENT_SETTINGS_TYPE_COOKIES, - "")->GetAsInteger(&actual_value)); + std::string())->GetAsInteger(&actual_value)); EXPECT_EQ(1, actual_value); EXPECT_TRUE(map.GetValue(GURL("http://www.google.com"), GURL("http://www.google.com"), CONTENT_SETTINGS_TYPE_COOKIES, - "")->GetAsInteger(&actual_value)); + std::string())->GetAsInteger(&actual_value)); EXPECT_EQ(2, actual_value); } TEST(OriginIdentifierValueMapTest, IterateEmpty) { content_settings::OriginIdentifierValueMap map; scoped_ptr<content_settings::RuleIterator> rule_iterator( - map.GetRuleIterator(CONTENT_SETTINGS_TYPE_COOKIES, "", NULL)); + map.GetRuleIterator(CONTENT_SETTINGS_TYPE_COOKIES, std::string(), NULL)); EXPECT_FALSE(rule_iterator->HasNext()); } @@ -187,21 +186,19 @@ TEST(OriginIdentifierValueMapTest, IterateNonempty) { ContentSettingsPattern::FromString("[*.]google.com"); ContentSettingsPattern sub_pattern = ContentSettingsPattern::FromString("sub.google.com"); - map.SetValue( - pattern, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(1)); - map.SetValue( - sub_pattern, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(2)); + map.SetValue(pattern, + ContentSettingsPattern::Wildcard(), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(1)); + map.SetValue(sub_pattern, + ContentSettingsPattern::Wildcard(), + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(2)); scoped_ptr<content_settings::RuleIterator> rule_iterator( - map.GetRuleIterator(CONTENT_SETTINGS_TYPE_COOKIES, "", NULL)); + map.GetRuleIterator(CONTENT_SETTINGS_TYPE_COOKIES, std::string(), NULL)); ASSERT_TRUE(rule_iterator->HasNext()); content_settings::Rule rule = rule_iterator->Next(); EXPECT_EQ(sub_pattern, rule.primary_pattern); diff --git a/chrome/browser/content_settings/content_settings_policy_provider.cc b/chrome/browser/content_settings/content_settings_policy_provider.cc index b112db0..f1e40fb 100644 --- a/chrome/browser/content_settings/content_settings_policy_provider.cc +++ b/chrome/browser/content_settings/content_settings_policy_provider.cc @@ -276,7 +276,7 @@ void PolicyProvider::GetContentSettingsFromPreferences( pattern_pair.first, secondary_pattern, content_type, - ResourceIdentifier(NO_RESOURCE_IDENTIFIER), + NO_RESOURCE_IDENTIFIER, base::Value::CreateIntegerValue( kPrefsForManagedContentSettingsMap[i].setting)); } 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 23c43f8..37b718c 100644 --- a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc +++ b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc @@ -150,22 +150,34 @@ TEST_F(PolicyProviderTest, GettingManagedContentSettings) { GURL google_url("http://mail.google.com"); EXPECT_EQ(CONTENT_SETTING_DEFAULT, - GetContentSetting( - &provider, youtube_url, youtube_url, - CONTENT_SETTINGS_TYPE_COOKIES, "", false)); + GetContentSetting(&provider, + youtube_url, + youtube_url, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + false)); EXPECT_EQ(NULL, - GetContentSettingValue( - &provider, youtube_url, youtube_url, - CONTENT_SETTINGS_TYPE_COOKIES, "", false)); + GetContentSettingValue(&provider, + youtube_url, + youtube_url, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + false)); EXPECT_EQ(CONTENT_SETTING_BLOCK, - GetContentSetting( - &provider, google_url, google_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&provider, + google_url, + google_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); scoped_ptr<Value> value_ptr( - GetContentSettingValue( - &provider, google_url, google_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSettingValue(&provider, + google_url, + google_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); int int_value = -1; value_ptr->GetAsInteger(&int_value); @@ -176,17 +188,19 @@ TEST_F(PolicyProviderTest, GettingManagedContentSettings) { // SetWebsiteSetting does nothing. scoped_ptr<base::Value> value_block( Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); - bool owned = provider.SetWebsiteSetting( - yt_url_pattern, - yt_url_pattern, - CONTENT_SETTINGS_TYPE_COOKIES, - "", - value_block.get()); + bool owned = provider.SetWebsiteSetting(yt_url_pattern, + yt_url_pattern, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + value_block.get()); EXPECT_FALSE(owned); EXPECT_EQ(CONTENT_SETTING_DEFAULT, - GetContentSetting( - &provider, youtube_url, youtube_url, - CONTENT_SETTINGS_TYPE_COOKIES, "", false)); + GetContentSetting(&provider, + youtube_url, + youtube_url, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + false)); provider.ShutdownOnUIThread(); } @@ -213,9 +227,12 @@ TEST_F(PolicyProviderTest, ResourceIdentifier) { // There is currently no policy support for resource content settings. // Resource identifiers are simply ignored by the PolicyProvider. EXPECT_EQ(CONTENT_SETTING_ALLOW, - GetContentSetting( - &provider, google_url, google_url, - CONTENT_SETTINGS_TYPE_PLUGINS, "", false)); + GetContentSetting(&provider, + google_url, + google_url, + CONTENT_SETTINGS_TYPE_PLUGINS, + std::string(), + false)); EXPECT_EQ(CONTENT_SETTING_DEFAULT, GetContentSetting( @@ -232,10 +249,14 @@ TEST_F(PolicyProviderTest, AutoSelectCertificateList) { PolicyProvider provider(prefs); GURL google_url("https://mail.google.com"); // Tests the default setting for auto selecting certificates - EXPECT_EQ(NULL, - GetContentSettingValue( - &provider, google_url, google_url, - CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "", false)); + EXPECT_EQ( + NULL, + GetContentSettingValue(&provider, + google_url, + google_url, + CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, + std::string(), + false)); // Set the content settings pattern list for origins to auto select // certificates. @@ -247,13 +268,21 @@ TEST_F(PolicyProviderTest, AutoSelectCertificateList) { prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls, value); GURL youtube_url("https://www.youtube.com"); - EXPECT_EQ(NULL, - GetContentSettingValue( - &provider, youtube_url, youtube_url, - CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "", false)); - scoped_ptr<Value> cert_filter(GetContentSettingValue( - &provider, google_url, google_url, - CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "", false)); + EXPECT_EQ( + NULL, + GetContentSettingValue(&provider, + youtube_url, + youtube_url, + CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, + std::string(), + false)); + scoped_ptr<Value> cert_filter( + GetContentSettingValue(&provider, + google_url, + google_url, + CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, + std::string(), + false)); ASSERT_EQ(Value::TYPE_DICTIONARY, cert_filter->GetType()); DictionaryValue* dict_value = diff --git a/chrome/browser/content_settings/content_settings_pref_provider.cc b/chrome/browser/content_settings/content_settings_pref_provider.cc index a92315e..4690f2f 100644 --- a/chrome/browser/content_settings/content_settings_pref_provider.cc +++ b/chrome/browser/content_settings/content_settings_pref_provider.cc @@ -188,22 +188,21 @@ void PrefProvider::ClearAllContentSettingsRules( { base::AutoLock auto_lock(lock_); scoped_ptr<RuleIterator> rule_iterator( - map_to_modify->GetRuleIterator(content_type, "", NULL)); + map_to_modify->GetRuleIterator(content_type, std::string(), NULL)); // Copy the rules; we cannot call |UpdatePref| while holding |lock_|. while (rule_iterator->HasNext()) rules_to_delete.push_back(rule_iterator->Next()); - map_to_modify->DeleteValues(content_type, ""); + map_to_modify->DeleteValues(content_type, std::string()); } for (std::vector<Rule>::const_iterator it = rules_to_delete.begin(); it != rules_to_delete.end(); ++it) { - UpdatePref( - it->primary_pattern, - it->secondary_pattern, - content_type, - "", - NULL); + UpdatePref(it->primary_pattern, + it->secondary_pattern, + content_type, + std::string(), + NULL); } NotifyObservers(ContentSettingsPattern(), ContentSettingsPattern(), @@ -307,8 +306,8 @@ void PrefProvider::UpdatePref( void PrefProvider::MigrateObsoleteMediaContentSetting() { std::vector<Rule> rules_to_delete; { - scoped_ptr<RuleIterator> rule_iterator( - GetRuleIterator(CONTENT_SETTINGS_TYPE_MEDIASTREAM, "", false)); + scoped_ptr<RuleIterator> rule_iterator(GetRuleIterator( + CONTENT_SETTINGS_TYPE_MEDIASTREAM, std::string(), false)); while (rule_iterator->HasNext()) { // Skip default setting and rules without a value. const content_settings::Rule& rule = rule_iterator->Next(); @@ -333,7 +332,7 @@ void PrefProvider::MigrateObsoleteMediaContentSetting() { SetWebsiteSetting(it->primary_pattern, it->secondary_pattern, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); } // Add the exception to the new camera content setting. @@ -341,7 +340,7 @@ void PrefProvider::MigrateObsoleteMediaContentSetting() { SetWebsiteSetting(it->primary_pattern, it->secondary_pattern, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); } @@ -349,7 +348,7 @@ void PrefProvider::MigrateObsoleteMediaContentSetting() { SetWebsiteSetting(it->primary_pattern, it->secondary_pattern, CONTENT_SETTINGS_TYPE_MEDIASTREAM, - "", + std::string(), NULL); } } @@ -455,7 +454,7 @@ void PrefProvider::ReadContentSettingsFromPref(bool overwrite) { value_map_.SetValue(pattern_pair.first, pattern_pair.second, content_type, - ResourceIdentifier(""), + ResourceIdentifier(), value); if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { ContentSetting s = ValueToContentSetting(value); 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 f951829..1ddc6d0 100644 --- a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc +++ b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc @@ -121,7 +121,7 @@ TEST_F(PrefProviderTest, Observer) { pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); pref_content_settings_provider.ShutdownOnUIThread(); @@ -166,20 +166,26 @@ TEST_F(PrefProviderTest, Incognito) { pattern, pattern, CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); GURL host("http://example.com/"); // The value should of course be visible in the regular PrefProvider. EXPECT_EQ(CONTENT_SETTING_ALLOW, - GetContentSetting( - &pref_content_settings_provider, - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host, + host, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); // And also in the OTR version. EXPECT_EQ(CONTENT_SETTING_ALLOW, - GetContentSetting( - &pref_content_settings_provider_incognito, - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider_incognito, + host, + host, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); // But the value should not be overridden in the OTR user prefs accidentally. EXPECT_FALSE(otr_user_prefs->IsSetInOverlay( prefs::kContentSettingsPatternPairs)); @@ -197,26 +203,40 @@ TEST_F(PrefProviderTest, GetContentSettingsValue) { ContentSettingsPattern::FromString("[*.]example.com"); EXPECT_EQ(CONTENT_SETTING_DEFAULT, - GetContentSetting(&provider, primary_url, primary_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&provider, + primary_url, + primary_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); EXPECT_EQ(NULL, - GetContentSettingValue( - &provider, primary_url, primary_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSettingValue(&provider, + primary_url, + primary_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); - provider.SetWebsiteSetting( - primary_pattern, - primary_pattern, - CONTENT_SETTINGS_TYPE_IMAGES, - "", - Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); + provider.SetWebsiteSetting(primary_pattern, + primary_pattern, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); EXPECT_EQ(CONTENT_SETTING_BLOCK, - GetContentSetting(&provider, primary_url, primary_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&provider, + primary_url, + primary_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); scoped_ptr<Value> value_ptr( - GetContentSettingValue(&provider, primary_url, primary_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSettingValue(&provider, + primary_url, + primary_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); int int_value = -1; value_ptr->GetAsInteger(&int_value); EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value)); @@ -224,12 +244,15 @@ TEST_F(PrefProviderTest, GetContentSettingsValue) { provider.SetWebsiteSetting(primary_pattern, primary_pattern, CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), NULL); EXPECT_EQ(NULL, - GetContentSettingValue( - &provider, primary_url, primary_url, - CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSettingValue(&provider, + primary_url, + primary_url, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); provider.ShutdownOnUIThread(); } @@ -250,53 +273,74 @@ TEST_F(PrefProviderTest, Patterns) { ContentSettingsPattern::FromString("file:///tmp/test.html"); EXPECT_EQ(CONTENT_SETTING_DEFAULT, - GetContentSetting( - &pref_content_settings_provider, - host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host1, + host1, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); pref_content_settings_provider.SetWebsiteSetting( pattern1, pattern1, CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); EXPECT_EQ(CONTENT_SETTING_BLOCK, - GetContentSetting( - &pref_content_settings_provider, - host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host1, + host1, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); EXPECT_EQ(CONTENT_SETTING_BLOCK, - GetContentSetting( - &pref_content_settings_provider, - host2, host2, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host2, + host2, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); EXPECT_EQ(CONTENT_SETTING_DEFAULT, - GetContentSetting( - &pref_content_settings_provider, - host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host3, + host3, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); pref_content_settings_provider.SetWebsiteSetting( pattern2, pattern2, CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); EXPECT_EQ(CONTENT_SETTING_BLOCK, - GetContentSetting( - &pref_content_settings_provider, - host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host3, + host3, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); EXPECT_EQ(CONTENT_SETTING_DEFAULT, GetContentSetting(&pref_content_settings_provider, - host4, host4, CONTENT_SETTINGS_TYPE_IMAGES, "", + host4, + host4, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), false)); pref_content_settings_provider.SetWebsiteSetting( pattern3, pattern3, CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); EXPECT_EQ(CONTENT_SETTING_BLOCK, - GetContentSetting( - &pref_content_settings_provider, - host4, host4, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); + GetContentSetting(&pref_content_settings_provider, + host4, + host4, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + false)); pref_content_settings_provider.ShutdownOnUIThread(); } diff --git a/chrome/browser/content_settings/content_settings_provider.h b/chrome/browser/content_settings/content_settings_provider.h index fefa226..6bc64de 100644 --- a/chrome/browser/content_settings/content_settings_provider.h +++ b/chrome/browser/content_settings/content_settings_provider.h @@ -7,7 +7,7 @@ #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ -#define NO_RESOURCE_IDENTIFIER "" +#define NO_RESOURCE_IDENTIFIER std::string() #include <string> #include <vector> diff --git a/chrome/browser/content_settings/content_settings_provider_unittest.cc b/chrome/browser/content_settings/content_settings_provider_unittest.cc index e0857b3..0832a1c 100644 --- a/chrome/browser/content_settings/content_settings_provider_unittest.cc +++ b/chrome/browser/content_settings/content_settings_provider_unittest.cc @@ -46,11 +46,18 @@ TEST(ContentSettingsProviderTest, Mock) { CONTENT_SETTINGS_TYPE_PLUGINS, "flash_plugin", false)); EXPECT_EQ(CONTENT_SETTING_DEFAULT, - GetContentSetting(&mock_provider, url, url, - CONTENT_SETTINGS_TYPE_GEOLOCATION, "", false)); + GetContentSetting(&mock_provider, + url, + url, + CONTENT_SETTINGS_TYPE_GEOLOCATION, + std::string(), + false)); EXPECT_EQ(NULL, - GetContentSettingValue(&mock_provider, url, url, - CONTENT_SETTINGS_TYPE_GEOLOCATION, "", + GetContentSettingValue(&mock_provider, + url, + url, + CONTENT_SETTINGS_TYPE_GEOLOCATION, + std::string(), false)); bool owned = mock_provider.SetWebsiteSetting( diff --git a/chrome/browser/content_settings/content_settings_utils.cc b/chrome/browser/content_settings/content_settings_utils.cc index d3a2869..9754ba1 100644 --- a/chrome/browser/content_settings/content_settings_utils.cc +++ b/chrome/browser/content_settings/content_settings_utils.cc @@ -190,10 +190,10 @@ ContentSetting GetContentSetting(const ProviderInterface* provider, void GetRendererContentSettingRules(const HostContentSettingsMap* map, RendererContentSettingRules* rules) { - map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, "", - &(rules->image_rules)); - map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, "", - &(rules->script_rules)); + map->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &(rules->image_rules)); + map->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), &(rules->script_rules)); } } // namespace content_settings diff --git a/chrome/browser/content_settings/content_settings_utils_unittest.cc b/chrome/browser/content_settings/content_settings_utils_unittest.cc index 69f88c1..d5eeeca 100644 --- a/chrome/browser/content_settings/content_settings_utils_unittest.cc +++ b/chrome/browser/content_settings/content_settings_utils_unittest.cc @@ -11,7 +11,7 @@ TEST(ContentSettingsUtilsTest, ParsePatternString) { content_settings::PatternPair pattern_pair; - pattern_pair = content_settings::ParsePatternString(""); + pattern_pair = content_settings::ParsePatternString(std::string()); EXPECT_FALSE(pattern_pair.first.IsValid()); EXPECT_FALSE(pattern_pair.second.IsValid()); diff --git a/chrome/browser/content_settings/cookie_settings.cc b/chrome/browser/content_settings/cookie_settings.cc index e34a56e..e0b1ff6 100644 --- a/chrome/browser/content_settings/cookie_settings.cc +++ b/chrome/browser/content_settings/cookie_settings.cc @@ -130,7 +130,7 @@ bool CookieSettings::IsCookieSessionOnly(const GURL& origin) const { void CookieSettings::GetCookieSettings( ContentSettingsForOneType* settings) const { return host_content_settings_map_->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_COOKIES, "", settings); + CONTENT_SETTINGS_TYPE_COOKIES, std::string(), settings); } void CookieSettings::SetDefaultCookieSetting(ContentSetting setting) { @@ -147,17 +147,21 @@ void CookieSettings::SetCookieSetting( if (setting == CONTENT_SETTING_SESSION_ONLY) { DCHECK(secondary_pattern == ContentSettingsPattern::Wildcard()); } - host_content_settings_map_->SetContentSetting( - primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", - setting); + host_content_settings_map_->SetContentSetting(primary_pattern, + secondary_pattern, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + setting); } void CookieSettings::ResetCookieSetting( const ContentSettingsPattern& primary_pattern, const ContentSettingsPattern& secondary_pattern) { - host_content_settings_map_->SetContentSetting( - primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", - CONTENT_SETTING_DEFAULT); + host_content_settings_map_->SetContentSetting(primary_pattern, + secondary_pattern, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + CONTENT_SETTING_DEFAULT); } void CookieSettings::ShutdownOnUIThread() { @@ -176,9 +180,12 @@ ContentSetting CookieSettings::GetCookieSetting( // First get any host-specific settings. content_settings::SettingInfo info; - scoped_ptr<base::Value> value( - host_content_settings_map_->GetWebsiteSetting( - url, first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, "", &info)); + scoped_ptr<base::Value> value(host_content_settings_map_->GetWebsiteSetting( + url, + first_party_url, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + &info)); if (source) *source = info.source; diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc index 8749d6f..777203d 100644 --- a/chrome/browser/content_settings/host_content_settings_map.cc +++ b/chrome/browser/content_settings/host_content_settings_map.cc @@ -133,7 +133,7 @@ void HostContentSettingsMap::RegisterExtensionService( OnContentSettingChanged(ContentSettingsPattern(), ContentSettingsPattern(), CONTENT_SETTINGS_TYPE_DEFAULT, - ""); + std::string()); } #endif @@ -159,7 +159,7 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSettingFromProvider( ContentSettingsType content_type, content_settings::ProviderInterface* provider) const { scoped_ptr<content_settings::RuleIterator> rule_iterator( - provider->GetRuleIterator(content_type, "", false)); + provider->GetRuleIterator(content_type, std::string(), false)); ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); while (rule_iterator->HasNext()) { @@ -460,19 +460,18 @@ void HostContentSettingsMap::MigrateObsoleteClearOnExitPref() { AddSettingsForOneType(content_settings_providers_[PREF_PROVIDER], PREF_PROVIDER, CONTENT_SETTINGS_TYPE_COOKIES, - "", + std::string(), &exceptions, false); for (ContentSettingsForOneType::iterator it = exceptions.begin(); it != exceptions.end(); ++it) { if (it->setting != CONTENT_SETTING_ALLOW) continue; - SetWebsiteSetting( - it->primary_pattern, - it->secondary_pattern, - CONTENT_SETTINGS_TYPE_COOKIES, - "", - Value::CreateIntegerValue(CONTENT_SETTING_SESSION_ONLY)); + SetWebsiteSetting(it->primary_pattern, + it->secondary_pattern, + CONTENT_SETTINGS_TYPE_COOKIES, + std::string(), + Value::CreateIntegerValue(CONTENT_SETTING_SESSION_ONLY)); } prefs_->SetBoolean(prefs::kContentSettingsClearOnExitMigrated, true); 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 57fd929..bba4336 100644 --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc @@ -81,16 +81,16 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { ContentSettingsPattern::FromString("[*.]example.com"); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), CONTENT_SETTING_DEFAULT); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), @@ -99,10 +99,10 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "")); + host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); // Check returning all settings for a host. host_content_settings_map->SetContentSetting( @@ -113,7 +113,7 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { CONTENT_SETTING_DEFAULT); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), @@ -122,7 +122,7 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), @@ -131,22 +131,23 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { CONTENT_SETTING_ALLOW); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "")); + host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_POPUPS, "")); - EXPECT_EQ(CONTENT_SETTING_ASK, - host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, "")); + host, host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); EXPECT_EQ(CONTENT_SETTING_ASK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "")); + host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); + EXPECT_EQ( + CONTENT_SETTING_ASK, + host_content_settings_map->GetContentSetting( + host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); EXPECT_EQ(CONTENT_SETTING_ASK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, "")); + host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string())); EXPECT_EQ(CONTENT_SETTING_ASK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, "")); + host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); // Check returning all hosts for a setting. ContentSettingsPattern pattern2 = @@ -164,18 +165,16 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { std::string(), CONTENT_SETTING_BLOCK); ContentSettingsForOneType host_settings; - host_content_settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, - "", - &host_settings); + host_content_settings_map->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); // |host_settings| contains the default setting and an exception. EXPECT_EQ(2U, host_settings.size()); host_content_settings_map->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_PLUGINS, "", &host_settings); + CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), &host_settings); // |host_settings| contains the default setting and 2 exceptions. EXPECT_EQ(3U, host_settings.size()); - host_content_settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_POPUPS, - "", - &host_settings); + host_content_settings_map->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &host_settings); // |host_settings| contains only the default setting. EXPECT_EQ(1U, host_settings.size()); } @@ -217,13 +216,12 @@ TEST_F(HostContentSettingsMapTest, Clear) { host_content_settings_map->ClearSettingsForOneType( CONTENT_SETTINGS_TYPE_IMAGES); ContentSettingsForOneType host_settings; - host_content_settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, - "", - &host_settings); + host_content_settings_map->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); // |host_settings| contains only the default setting. EXPECT_EQ(1U, host_settings.size()); host_content_settings_map->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_PLUGINS, "", &host_settings); + CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), &host_settings); // |host_settings| contains the default setting and an exception. EXPECT_EQ(2U, host_settings.size()); } @@ -242,7 +240,7 @@ TEST_F(HostContentSettingsMapTest, Patterns) { ContentSettingsPattern::FromString("example.org"); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); host_content_settings_map->SetContentSetting( pattern1, ContentSettingsPattern::Wildcard(), @@ -251,13 +249,13 @@ TEST_F(HostContentSettingsMapTest, Patterns) { CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host2, host2, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host2, host2, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); host_content_settings_map->SetContentSetting( pattern2, ContentSettingsPattern::Wildcard(), @@ -266,7 +264,7 @@ TEST_F(HostContentSettingsMapTest, Patterns) { CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); } TEST_F(HostContentSettingsMapTest, Observer) { @@ -327,7 +325,7 @@ TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); // Make a copy of the pref's new value so we can reset it later. scoped_ptr<Value> new_value(prefs->FindPreference( @@ -337,13 +335,13 @@ TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { prefs->Set(prefs::kDefaultContentSettings, *default_value); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); // Reseting the pref to its previous value should update the cache. prefs->Set(prefs::kDefaultContentSettings, *new_value); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); } TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { @@ -363,7 +361,7 @@ TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); host_content_settings_map->SetContentSetting( pattern, @@ -373,7 +371,7 @@ TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); // Make a copy of the pref's new value so we can reset it later. scoped_ptr<Value> new_value(prefs->FindPreference( @@ -383,13 +381,13 @@ TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { prefs->Set(prefs::kContentSettingsPatternPairs, *default_value); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); // Reseting the pref to its previous value should update the cache. prefs->Set(prefs::kContentSettingsPatternPairs, *new_value); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); } TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { @@ -413,26 +411,26 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), CONTENT_SETTING_DEFAULT); - EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, - host_ending_with_dot, - CONTENT_SETTINGS_TYPE_IMAGES, - "")); + EXPECT_EQ( + CONTENT_SETTING_ALLOW, + host_content_settings_map->GetContentSetting(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, - "", + std::string(), CONTENT_SETTING_BLOCK); - EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, - host_ending_with_dot, - CONTENT_SETTINGS_TYPE_IMAGES, - "")); + EXPECT_EQ( + CONTENT_SETTING_BLOCK, + host_content_settings_map->GetContentSetting(host_ending_with_dot, + host_ending_with_dot, + CONTENT_SETTINGS_TYPE_IMAGES, + std::string())); EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed( host_ending_with_dot, host_ending_with_dot)); @@ -440,7 +438,7 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, - "", + std::string(), CONTENT_SETTING_DEFAULT); EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed( host_ending_with_dot, host_ending_with_dot)); @@ -448,7 +446,7 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, - "", + std::string(), CONTENT_SETTING_BLOCK); EXPECT_FALSE(cookie_settings->IsSettingCookieAllowed( host_ending_with_dot, host_ending_with_dot)); @@ -458,93 +456,93 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { host_ending_with_dot, host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "")); + std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "", + std::string(), CONTENT_SETTING_DEFAULT); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( host_ending_with_dot, host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "")); + std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "", + std::string(), CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( host_ending_with_dot, host_ending_with_dot, CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "")); + std::string())); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( host_ending_with_dot, host_ending_with_dot, CONTENT_SETTINGS_TYPE_PLUGINS, - "")); + std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_PLUGINS, - "", + std::string(), CONTENT_SETTING_DEFAULT); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( host_ending_with_dot, host_ending_with_dot, CONTENT_SETTINGS_TYPE_PLUGINS, - "")); + std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_PLUGINS, - "", + std::string(), CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( host_ending_with_dot, host_ending_with_dot, CONTENT_SETTINGS_TYPE_PLUGINS, - "")); + std::string())); - EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, - host_ending_with_dot, - CONTENT_SETTINGS_TYPE_POPUPS, - "")); + EXPECT_EQ( + CONTENT_SETTING_BLOCK, + host_content_settings_map->GetContentSetting(host_ending_with_dot, + host_ending_with_dot, + CONTENT_SETTINGS_TYPE_POPUPS, + std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_POPUPS, - "", + std::string(), CONTENT_SETTING_DEFAULT); - EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, - host_ending_with_dot, - CONTENT_SETTINGS_TYPE_POPUPS, - "")); + EXPECT_EQ( + CONTENT_SETTING_BLOCK, + host_content_settings_map->GetContentSetting(host_ending_with_dot, + host_ending_with_dot, + CONTENT_SETTINGS_TYPE_POPUPS, + std::string())); host_content_settings_map->SetContentSetting( pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_POPUPS, - "", + std::string(), CONTENT_SETTING_ALLOW); - EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, - host_ending_with_dot, - CONTENT_SETTINGS_TYPE_POPUPS, - "")); + EXPECT_EQ( + CONTENT_SETTING_ALLOW, + host_content_settings_map->GetContentSetting(host_ending_with_dot, + host_ending_with_dot, + CONTENT_SETTINGS_TYPE_POPUPS, + std::string())); } TEST_F(HostContentSettingsMapTest, NestedSettings) { @@ -564,52 +562,53 @@ TEST_F(HostContentSettingsMapTest, NestedSettings) { pattern1, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), CONTENT_SETTING_BLOCK); host_content_settings_map->SetContentSetting( pattern2, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, - "", + std::string(), CONTENT_SETTING_BLOCK); host_content_settings_map->SetContentSetting( pattern3, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_PLUGINS, - "", + std::string(), CONTENT_SETTING_BLOCK); host_content_settings_map->SetDefaultContentSetting( CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "")); + host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_POPUPS, "")); + host, host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); EXPECT_EQ(CONTENT_SETTING_ASK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, "")); + host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); + EXPECT_EQ( + CONTENT_SETTING_ASK, + host_content_settings_map->GetContentSetting( + host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); EXPECT_EQ(CONTENT_SETTING_ASK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "")); + host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string())); EXPECT_EQ(CONTENT_SETTING_ASK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, "")); - EXPECT_EQ(CONTENT_SETTING_ASK, - host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, "")); + host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); } TEST_F(HostContentSettingsMapTest, OffTheRecord) { @@ -626,10 +625,10 @@ TEST_F(HostContentSettingsMapTest, OffTheRecord) { EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_ALLOW, otr_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); // Changing content settings on the main map should also affect the // incognito map. @@ -637,27 +636,28 @@ TEST_F(HostContentSettingsMapTest, OffTheRecord) { pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, - "", + std::string(), CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_BLOCK, otr_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); // Changing content settings on the incognito map should NOT affect the // main map. - otr_map->SetContentSetting( - pattern, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_ALLOW); + otr_map->SetContentSetting(pattern, + ContentSettingsPattern::Wildcard(), + CONTENT_SETTINGS_TYPE_IMAGES, + std::string(), + CONTENT_SETTING_ALLOW); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_ALLOW, otr_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); otr_map->ShutdownOnUIThread(); } @@ -738,7 +738,7 @@ TEST_F(HostContentSettingsMapTest, ResourceIdentifier) { CONTENT_SETTINGS_TYPE_PLUGINS, NULL); EXPECT_EQ(default_plugin_setting, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "")); + host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); // If no resource-specific content settings are defined, the setting should be // DEFAULT. @@ -865,7 +865,7 @@ TEST_F(HostContentSettingsMapTest, pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "", + std::string(), CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_ALLOW, @@ -875,14 +875,14 @@ TEST_F(HostContentSettingsMapTest, GURL host("http://example.com/"); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); // 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, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); } // Managed default content setting should have higher priority @@ -906,7 +906,7 @@ TEST_F(HostContentSettingsMapTest, pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_JAVASCRIPT, - "", + std::string(), CONTENT_SETTING_ALLOW); EXPECT_EQ(CONTENT_SETTING_BLOCK, @@ -915,20 +915,20 @@ TEST_F(HostContentSettingsMapTest, GURL host("http://example.com/"); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); // 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, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); // Remove managed-default-content-settings-preferences. prefs->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); + host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); } // If a default-content-setting is set to managed setting, the user defined @@ -1004,10 +1004,10 @@ TEST_F(HostContentSettingsMapTest, GetContentSetting) { CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetContentSetting( - host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( - embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); + embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); } TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) { diff --git a/chrome/browser/content_settings/mock_settings_observer.cc b/chrome/browser/content_settings/mock_settings_observer.cc index a281a1d..c8de7fa 100644 --- a/chrome/browser/content_settings/mock_settings_observer.cc +++ b/chrome/browser/content_settings/mock_settings_observer.cc @@ -35,5 +35,5 @@ void MockSettingsObserver::Observe( // This checks that calling a Get function from an observer doesn't // deadlock. GURL url("http://random-hostname.com/"); - map->GetContentSetting(url, url, CONTENT_SETTINGS_TYPE_IMAGES, ""); + map->GetContentSetting(url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string()); } |