Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "base/values.h" | |
| 11 #include "chrome/browser/content_settings/content_settings_mock_observer.h" | 12 #include "chrome/browser/content_settings/content_settings_mock_observer.h" |
| 12 #include "chrome/browser/content_settings/content_settings_utils.h" | 13 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 13 #include "chrome/browser/prefs/browser_prefs.h" | 14 #include "chrome/browser/prefs/browser_prefs.h" |
| 14 #include "chrome/browser/prefs/default_pref_store.h" | 15 #include "chrome/browser/prefs/default_pref_store.h" |
| 15 #include "chrome/browser/prefs/incognito_user_pref_store.h" | 16 #include "chrome/browser/prefs/incognito_user_pref_store.h" |
| 16 #include "chrome/browser/prefs/pref_change_registrar.h" | 17 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 19 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 20 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 20 #include "chrome/browser/prefs/testing_pref_store.h" | 21 #include "chrome/browser/prefs/testing_pref_store.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 PrefProvider* provider_; | 114 PrefProvider* provider_; |
| 114 PrefChangeRegistrar pref_change_registrar_; | 115 PrefChangeRegistrar pref_change_registrar_; |
| 115 bool notification_received_; | 116 bool notification_received_; |
| 116 DISALLOW_COPY_AND_ASSIGN(DeadlockCheckerObserver); | 117 DISALLOW_COPY_AND_ASSIGN(DeadlockCheckerObserver); |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 class PrefProviderTest : public testing::Test { | 120 class PrefProviderTest : public testing::Test { |
| 120 public: | 121 public: |
| 121 PrefProviderTest() : ui_thread_( | 122 PrefProviderTest() : ui_thread_( |
| 122 BrowserThread::UI, &message_loop_) { | 123 BrowserThread::UI, &message_loop_) { |
| 124 value_allow.reset(Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); | |
| 125 value_block.reset(Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); | |
| 123 } | 126 } |
| 124 | 127 |
| 125 protected: | 128 protected: |
| 126 MessageLoop message_loop_; | 129 MessageLoop message_loop_; |
| 127 content::TestBrowserThread ui_thread_; | 130 content::TestBrowserThread ui_thread_; |
| 131 scoped_ptr<base::Value> value_allow; | |
|
Bernhard Bauer
2011/11/11 14:00:40
Class member names end with an underscore.
markusheintz_
2011/11/14 11:15:10
Shame on me. Glad I removed them now.
| |
| 132 scoped_ptr<base::Value> value_block; | |
| 128 }; | 133 }; |
| 129 | 134 |
| 130 TEST_F(PrefProviderTest, Observer) { | 135 TEST_F(PrefProviderTest, Observer) { |
| 131 TestingProfile profile; | 136 TestingProfile profile; |
| 132 PrefProvider pref_content_settings_provider(profile.GetPrefs(), false); | 137 PrefProvider pref_content_settings_provider(profile.GetPrefs(), false); |
| 133 | 138 |
| 134 ContentSettingsPattern pattern = | 139 ContentSettingsPattern pattern = |
| 135 ContentSettingsPattern::FromString("[*.]example.com"); | 140 ContentSettingsPattern::FromString("[*.]example.com"); |
| 136 content_settings::MockObserver mock_observer; | 141 content_settings::MockObserver mock_observer; |
| 137 EXPECT_CALL(mock_observer, | 142 EXPECT_CALL(mock_observer, |
| 138 OnContentSettingChanged(pattern, | 143 OnContentSettingChanged(pattern, |
| 139 ContentSettingsPattern::Wildcard(), | 144 ContentSettingsPattern::Wildcard(), |
| 140 CONTENT_SETTINGS_TYPE_IMAGES, | 145 CONTENT_SETTINGS_TYPE_IMAGES, |
| 141 "")); | 146 "")); |
| 142 | 147 |
| 143 pref_content_settings_provider.AddObserver(&mock_observer); | 148 pref_content_settings_provider.AddObserver(&mock_observer); |
| 144 | 149 |
| 145 pref_content_settings_provider.SetContentSetting( | 150 pref_content_settings_provider.SetWebsiteSetting( |
| 146 pattern, | 151 pattern, |
| 147 ContentSettingsPattern::Wildcard(), | 152 ContentSettingsPattern::Wildcard(), |
| 148 CONTENT_SETTINGS_TYPE_IMAGES, | 153 CONTENT_SETTINGS_TYPE_IMAGES, |
| 149 "", | 154 "", |
| 150 CONTENT_SETTING_ALLOW); | 155 value_allow.get()); |
| 151 | 156 |
| 152 pref_content_settings_provider.ShutdownOnUIThread(); | 157 pref_content_settings_provider.ShutdownOnUIThread(); |
| 153 } | 158 } |
| 154 | 159 |
| 155 // Test for regression in which the PrefProvider modified the user pref store | 160 // Test for regression in which the PrefProvider modified the user pref store |
| 156 // of the OTR unintentionally: http://crbug.com/74466. | 161 // of the OTR unintentionally: http://crbug.com/74466. |
| 157 TEST_F(PrefProviderTest, Incognito) { | 162 TEST_F(PrefProviderTest, Incognito) { |
| 158 PersistentPrefStore* user_prefs = new TestingPrefStore(); | 163 PersistentPrefStore* user_prefs = new TestingPrefStore(); |
| 159 IncognitoUserPrefStore* otr_user_prefs = | 164 IncognitoUserPrefStore* otr_user_prefs = |
| 160 new IncognitoUserPrefStore(user_prefs); | 165 new IncognitoUserPrefStore(user_prefs); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 174 TestingProfile* otr_profile = new TestingProfile; | 179 TestingProfile* otr_profile = new TestingProfile; |
| 175 profile.SetOffTheRecordProfile(otr_profile); | 180 profile.SetOffTheRecordProfile(otr_profile); |
| 176 profile.SetPrefService(regular_prefs); | 181 profile.SetPrefService(regular_prefs); |
| 177 otr_profile->set_incognito(true); | 182 otr_profile->set_incognito(true); |
| 178 otr_profile->SetPrefService(otr_prefs); | 183 otr_profile->SetPrefService(otr_prefs); |
| 179 | 184 |
| 180 PrefProvider pref_content_settings_provider(regular_prefs, false); | 185 PrefProvider pref_content_settings_provider(regular_prefs, false); |
| 181 PrefProvider pref_content_settings_provider_incognito(otr_prefs, true); | 186 PrefProvider pref_content_settings_provider_incognito(otr_prefs, true); |
| 182 ContentSettingsPattern pattern = | 187 ContentSettingsPattern pattern = |
| 183 ContentSettingsPattern::FromString("[*.]example.com"); | 188 ContentSettingsPattern::FromString("[*.]example.com"); |
| 184 pref_content_settings_provider.SetContentSetting( | 189 pref_content_settings_provider.SetWebsiteSetting( |
| 185 pattern, | 190 pattern, |
| 186 pattern, | 191 pattern, |
| 187 CONTENT_SETTINGS_TYPE_IMAGES, | 192 CONTENT_SETTINGS_TYPE_IMAGES, |
| 188 "", | 193 "", |
| 189 CONTENT_SETTING_ALLOW); | 194 value_allow.get()); |
| 190 | 195 |
| 191 GURL host("http://example.com/"); | 196 GURL host("http://example.com/"); |
| 192 // The value should of course be visible in the regular PrefProvider. | 197 // The value should of course be visible in the regular PrefProvider. |
| 193 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 198 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 194 GetContentSetting( | 199 GetContentSetting( |
| 195 &pref_content_settings_provider, | 200 &pref_content_settings_provider, |
| 196 host, host, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 201 host, host, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 197 // And also in the OTR version. | 202 // And also in the OTR version. |
| 198 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 203 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 199 GetContentSetting( | 204 GetContentSetting( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 216 | 221 |
| 217 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 222 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 218 GetContentSetting(&provider, primary_url, primary_url, | 223 GetContentSetting(&provider, primary_url, primary_url, |
| 219 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 224 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 220 | 225 |
| 221 EXPECT_EQ(NULL, | 226 EXPECT_EQ(NULL, |
| 222 GetContentSettingValue( | 227 GetContentSettingValue( |
| 223 &provider, primary_url, primary_url, | 228 &provider, primary_url, primary_url, |
| 224 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 229 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 225 | 230 |
| 226 provider.SetContentSetting(primary_pattern, | 231 provider.SetWebsiteSetting(primary_pattern, |
| 227 primary_pattern, | 232 primary_pattern, |
| 228 CONTENT_SETTINGS_TYPE_IMAGES, | 233 CONTENT_SETTINGS_TYPE_IMAGES, |
| 229 "", | 234 "", |
| 230 CONTENT_SETTING_BLOCK); | 235 value_block.get()); |
| 231 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 236 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 232 GetContentSetting(&provider, primary_url, primary_url, | 237 GetContentSetting(&provider, primary_url, primary_url, |
| 233 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 238 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 234 scoped_ptr<Value> value_ptr( | 239 scoped_ptr<Value> value_ptr( |
| 235 GetContentSettingValue(&provider, primary_url, primary_url, | 240 GetContentSettingValue(&provider, primary_url, primary_url, |
| 236 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 241 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 237 int int_value = -1; | 242 int int_value = -1; |
| 238 value_ptr->GetAsInteger(&int_value); | 243 value_ptr->GetAsInteger(&int_value); |
| 239 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value)); | 244 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value)); |
| 240 | 245 |
| 241 provider.SetContentSetting(primary_pattern, | 246 provider.SetWebsiteSetting(primary_pattern, |
| 242 primary_pattern, | 247 primary_pattern, |
| 243 CONTENT_SETTINGS_TYPE_IMAGES, | 248 CONTENT_SETTINGS_TYPE_IMAGES, |
| 244 "", | 249 "", |
| 245 CONTENT_SETTING_DEFAULT); | 250 NULL); |
| 246 EXPECT_EQ(NULL, | 251 EXPECT_EQ(NULL, |
| 247 GetContentSettingValue( | 252 GetContentSettingValue( |
| 248 &provider, primary_url, primary_url, | 253 &provider, primary_url, primary_url, |
| 249 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 254 CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 250 provider.ShutdownOnUIThread(); | 255 provider.ShutdownOnUIThread(); |
| 251 } | 256 } |
| 252 | 257 |
| 253 TEST_F(PrefProviderTest, Patterns) { | 258 TEST_F(PrefProviderTest, Patterns) { |
| 254 TestingProfile testing_profile; | 259 TestingProfile testing_profile; |
| 255 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), | 260 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), |
| 256 false); | 261 false); |
| 257 | 262 |
| 258 GURL host1("http://example.com/"); | 263 GURL host1("http://example.com/"); |
| 259 GURL host2("http://www.example.com/"); | 264 GURL host2("http://www.example.com/"); |
| 260 GURL host3("http://example.org/"); | 265 GURL host3("http://example.org/"); |
| 261 GURL host4("file:///tmp/test.html"); | 266 GURL host4("file:///tmp/test.html"); |
| 262 ContentSettingsPattern pattern1 = | 267 ContentSettingsPattern pattern1 = |
| 263 ContentSettingsPattern::FromString("[*.]example.com"); | 268 ContentSettingsPattern::FromString("[*.]example.com"); |
| 264 ContentSettingsPattern pattern2 = | 269 ContentSettingsPattern pattern2 = |
| 265 ContentSettingsPattern::FromString("example.org"); | 270 ContentSettingsPattern::FromString("example.org"); |
| 266 ContentSettingsPattern pattern3 = | 271 ContentSettingsPattern pattern3 = |
| 267 ContentSettingsPattern::FromString("file:///tmp/test.html"); | 272 ContentSettingsPattern::FromString("file:///tmp/test.html"); |
| 268 | 273 |
| 269 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 274 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 270 GetContentSetting( | 275 GetContentSetting( |
| 271 &pref_content_settings_provider, | 276 &pref_content_settings_provider, |
| 272 host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 277 host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 273 pref_content_settings_provider.SetContentSetting( | 278 pref_content_settings_provider.SetWebsiteSetting( |
| 274 pattern1, | 279 pattern1, |
| 275 pattern1, | 280 pattern1, |
| 276 CONTENT_SETTINGS_TYPE_IMAGES, | 281 CONTENT_SETTINGS_TYPE_IMAGES, |
| 277 "", | 282 "", |
| 278 CONTENT_SETTING_BLOCK); | 283 value_block.get()); |
| 279 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 284 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 280 GetContentSetting( | 285 GetContentSetting( |
| 281 &pref_content_settings_provider, | 286 &pref_content_settings_provider, |
| 282 host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 287 host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 283 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 288 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 284 GetContentSetting( | 289 GetContentSetting( |
| 285 &pref_content_settings_provider, | 290 &pref_content_settings_provider, |
| 286 host2, host2, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 291 host2, host2, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 287 | 292 |
| 288 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 293 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 289 GetContentSetting( | 294 GetContentSetting( |
| 290 &pref_content_settings_provider, | 295 &pref_content_settings_provider, |
| 291 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 296 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 292 pref_content_settings_provider.SetContentSetting( | 297 pref_content_settings_provider.SetWebsiteSetting( |
| 293 pattern2, | 298 pattern2, |
| 294 pattern2, | 299 pattern2, |
| 295 CONTENT_SETTINGS_TYPE_IMAGES, | 300 CONTENT_SETTINGS_TYPE_IMAGES, |
| 296 "", | 301 "", |
| 297 CONTENT_SETTING_BLOCK); | 302 value_block.get()); |
| 298 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 303 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 299 GetContentSetting( | 304 GetContentSetting( |
| 300 &pref_content_settings_provider, | 305 &pref_content_settings_provider, |
| 301 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 306 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 302 | 307 |
| 303 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 308 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 304 GetContentSetting(&pref_content_settings_provider, | 309 GetContentSetting(&pref_content_settings_provider, |
| 305 host4, host4, CONTENT_SETTINGS_TYPE_IMAGES, "", | 310 host4, host4, CONTENT_SETTINGS_TYPE_IMAGES, "", |
| 306 false)); | 311 false)); |
| 307 pref_content_settings_provider.SetContentSetting( | 312 pref_content_settings_provider.SetWebsiteSetting( |
| 308 pattern3, | 313 pattern3, |
| 309 pattern3, | 314 pattern3, |
| 310 CONTENT_SETTINGS_TYPE_IMAGES, | 315 CONTENT_SETTINGS_TYPE_IMAGES, |
| 311 "", | 316 "", |
| 312 CONTENT_SETTING_BLOCK); | 317 value_block.get()); |
| 313 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 318 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 314 GetContentSetting( | 319 GetContentSetting( |
| 315 &pref_content_settings_provider, | 320 &pref_content_settings_provider, |
| 316 host4, host4, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); | 321 host4, host4, CONTENT_SETTINGS_TYPE_IMAGES, "", false)); |
| 317 | 322 |
| 318 pref_content_settings_provider.ShutdownOnUIThread(); | 323 pref_content_settings_provider.ShutdownOnUIThread(); |
| 319 } | 324 } |
| 320 | 325 |
| 321 TEST_F(PrefProviderTest, ResourceIdentifier) { | 326 TEST_F(PrefProviderTest, ResourceIdentifier) { |
| 322 TestingProfile testing_profile; | 327 TestingProfile testing_profile; |
| 323 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), | 328 PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), |
| 324 false); | 329 false); |
| 325 | 330 |
| 326 GURL host("http://example.com/"); | 331 GURL host("http://example.com/"); |
| 327 ContentSettingsPattern pattern = | 332 ContentSettingsPattern pattern = |
| 328 ContentSettingsPattern::FromString("[*.]example.com"); | 333 ContentSettingsPattern::FromString("[*.]example.com"); |
| 329 std::string resource1("someplugin"); | 334 std::string resource1("someplugin"); |
| 330 std::string resource2("otherplugin"); | 335 std::string resource2("otherplugin"); |
| 331 | 336 |
| 332 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 337 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 333 GetContentSetting( | 338 GetContentSetting( |
| 334 &pref_content_settings_provider, | 339 &pref_content_settings_provider, |
| 335 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, | 340 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, |
| 336 resource1, false)); | 341 resource1, false)); |
| 337 pref_content_settings_provider.SetContentSetting( | 342 pref_content_settings_provider.SetWebsiteSetting( |
| 338 pattern, | 343 pattern, |
| 339 pattern, | 344 pattern, |
| 340 CONTENT_SETTINGS_TYPE_PLUGINS, | 345 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 341 resource1, | 346 resource1, |
| 342 CONTENT_SETTING_BLOCK); | 347 value_block.get()); |
| 343 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 348 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 344 GetContentSetting( | 349 GetContentSetting( |
| 345 &pref_content_settings_provider, | 350 &pref_content_settings_provider, |
| 346 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, | 351 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, |
| 347 resource1, false)); | 352 resource1, false)); |
| 348 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 353 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 349 GetContentSetting( | 354 GetContentSetting( |
| 350 &pref_content_settings_provider, | 355 &pref_content_settings_provider, |
| 351 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, | 356 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, |
| 352 resource2, false)); | 357 resource2, false)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 // Assert pre-condition. | 420 // Assert pre-condition. |
| 416 const DictionaryValue* patterns = | 421 const DictionaryValue* patterns = |
| 417 prefs->GetDictionary(prefs::kContentSettingsPatterns); | 422 prefs->GetDictionary(prefs::kContentSettingsPatterns); |
| 418 ASSERT_TRUE(patterns->empty()); | 423 ASSERT_TRUE(patterns->empty()); |
| 419 | 424 |
| 420 // Simulate a user setting a content setting. | 425 // Simulate a user setting a content setting. |
| 421 ContentSettingsPattern primary_pattern = | 426 ContentSettingsPattern primary_pattern = |
| 422 ContentSettingsPattern::FromString("[*.]example.com"); | 427 ContentSettingsPattern::FromString("[*.]example.com"); |
| 423 ContentSettingsPattern secondary_pattern = | 428 ContentSettingsPattern secondary_pattern = |
| 424 ContentSettingsPattern::Wildcard(); | 429 ContentSettingsPattern::Wildcard(); |
| 425 provider.SetContentSetting(primary_pattern, | 430 provider.SetWebsiteSetting(primary_pattern, |
| 426 secondary_pattern, | 431 secondary_pattern, |
| 427 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 432 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 428 std::string(), | 433 std::string(), |
| 429 CONTENT_SETTING_BLOCK); | 434 value_block.get()); |
| 430 | 435 |
| 431 // Test whether the obsolete preference is synced correctly. | 436 // Test whether the obsolete preference is synced correctly. |
| 432 patterns = prefs->GetDictionary(prefs::kContentSettingsPatterns); | 437 patterns = prefs->GetDictionary(prefs::kContentSettingsPatterns); |
| 433 EXPECT_EQ(1U, patterns->size()); | 438 EXPECT_EQ(1U, patterns->size()); |
| 434 DictionaryValue* settings = NULL; | 439 DictionaryValue* settings = NULL; |
| 435 patterns->GetDictionaryWithoutPathExpansion(primary_pattern.ToString(), | 440 patterns->GetDictionaryWithoutPathExpansion(primary_pattern.ToString(), |
| 436 &settings); | 441 &settings); |
| 437 ASSERT_TRUE(NULL != settings); | 442 ASSERT_TRUE(NULL != settings); |
| 438 ASSERT_EQ(1U, settings->size()); | 443 ASSERT_EQ(1U, settings->size()); |
| 439 int setting_value; | 444 int setting_value; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 | 686 |
| 682 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 687 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 683 GetContentSetting( | 688 GetContentSetting( |
| 684 &provider, | 689 &provider, |
| 685 primary_url, | 690 primary_url, |
| 686 primary_url, | 691 primary_url, |
| 687 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 692 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 688 std::string(), | 693 std::string(), |
| 689 false)); | 694 false)); |
| 690 | 695 |
| 691 provider.SetContentSetting( | 696 provider.SetWebsiteSetting( |
| 692 ContentSettingsPattern::FromURL(primary_url), | 697 ContentSettingsPattern::FromURL(primary_url), |
| 693 ContentSettingsPattern::Wildcard(), | 698 ContentSettingsPattern::Wildcard(), |
| 694 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 699 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 695 std::string(), | 700 std::string(), |
| 696 CONTENT_SETTING_ALLOW); | 701 value_allow.get()); |
| 697 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 702 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 698 GetContentSetting( | 703 GetContentSetting( |
| 699 &provider, | 704 &provider, |
| 700 primary_url, | 705 primary_url, |
| 701 secondary_url, | 706 secondary_url, |
| 702 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 707 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 703 std::string(), | 708 std::string(), |
| 704 false)); | 709 false)); |
| 705 provider.ShutdownOnUIThread(); | 710 provider.ShutdownOnUIThread(); |
| 706 } | 711 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 DictionaryValue* mutable_settings = update.Get(); | 876 DictionaryValue* mutable_settings = update.Get(); |
| 872 mutable_settings->SetWithoutPathExpansion("www.example.com,*", | 877 mutable_settings->SetWithoutPathExpansion("www.example.com,*", |
| 873 new base::DictionaryValue()); | 878 new base::DictionaryValue()); |
| 874 } | 879 } |
| 875 EXPECT_TRUE(observer.notification_received()); | 880 EXPECT_TRUE(observer.notification_received()); |
| 876 | 881 |
| 877 provider.ShutdownOnUIThread(); | 882 provider.ShutdownOnUIThread(); |
| 878 } | 883 } |
| 879 | 884 |
| 880 } // namespace content_settings | 885 } // namespace content_settings |
| OLD | NEW |