| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "chrome/browser/content_settings/content_settings_mock_observer.h" | 12 #include "chrome/browser/content_settings/content_settings_mock_observer.h" |
| 13 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 13 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 14 #include "chrome/browser/content_settings/mock_settings_observer.h" | 15 #include "chrome/browser/content_settings/mock_settings_observer.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/test/base/testing_pref_service_syncable.h" | 18 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 19 #include "components/content_settings/core/browser/content_settings_details.h" | 20 #include "components/content_settings/core/browser/content_settings_details.h" |
| 20 #include "components/content_settings/core/browser/cookie_settings.h" | 21 #include "components/content_settings/core/browser/cookie_settings.h" |
| 21 #include "components/content_settings/core/browser/host_content_settings_map.h" | 22 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 22 #include "components/content_settings/core/browser/website_settings_info.h" | 23 #include "components/content_settings/core/browser/website_settings_info.h" |
| 23 #include "components/content_settings/core/browser/website_settings_registry.h" | 24 #include "components/content_settings/core/browser/website_settings_registry.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 ->pref_name(); | 43 ->pref_name(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 base::MessageLoop message_loop_; | 46 base::MessageLoop message_loop_; |
| 46 content::TestBrowserThread ui_thread_; | 47 content::TestBrowserThread ui_thread_; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 TEST_F(HostContentSettingsMapTest, DefaultValues) { | 50 TEST_F(HostContentSettingsMapTest, DefaultValues) { |
| 50 TestingProfile profile; | 51 TestingProfile profile; |
| 51 HostContentSettingsMap* host_content_settings_map = | 52 HostContentSettingsMap* host_content_settings_map = |
| 52 profile.GetHostContentSettingsMap(); | 53 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 53 | 54 |
| 54 // Check setting defaults. | 55 // Check setting defaults. |
| 55 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 56 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 56 host_content_settings_map->GetDefaultContentSetting( | 57 host_content_settings_map->GetDefaultContentSetting( |
| 57 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); | 58 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); |
| 58 host_content_settings_map->SetDefaultContentSetting( | 59 host_content_settings_map->SetDefaultContentSetting( |
| 59 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 60 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
| 60 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 61 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 61 host_content_settings_map->GetDefaultContentSetting( | 62 host_content_settings_map->GetDefaultContentSetting( |
| 62 CONTENT_SETTINGS_TYPE_IMAGES, NULL)); | 63 CONTENT_SETTINGS_TYPE_IMAGES, NULL)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 87 host_content_settings_map->SetDefaultContentSetting( | 88 host_content_settings_map->SetDefaultContentSetting( |
| 88 CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW); | 89 CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW); |
| 89 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 90 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 90 host_content_settings_map->GetDefaultContentSetting( | 91 host_content_settings_map->GetDefaultContentSetting( |
| 91 CONTENT_SETTINGS_TYPE_POPUPS, NULL)); | 92 CONTENT_SETTINGS_TYPE_POPUPS, NULL)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 TEST_F(HostContentSettingsMapTest, IndividualSettings) { | 95 TEST_F(HostContentSettingsMapTest, IndividualSettings) { |
| 95 TestingProfile profile; | 96 TestingProfile profile; |
| 96 HostContentSettingsMap* host_content_settings_map = | 97 HostContentSettingsMap* host_content_settings_map = |
| 97 profile.GetHostContentSettingsMap(); | 98 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 98 | 99 |
| 99 // Check returning individual settings. | 100 // Check returning individual settings. |
| 100 GURL host("http://example.com/"); | 101 GURL host("http://example.com/"); |
| 101 ContentSettingsPattern pattern = | 102 ContentSettingsPattern pattern = |
| 102 ContentSettingsPattern::FromString("[*.]example.com"); | 103 ContentSettingsPattern::FromString("[*.]example.com"); |
| 103 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 104 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 104 host_content_settings_map->GetContentSetting( | 105 host_content_settings_map->GetContentSetting( |
| 105 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 106 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 106 host_content_settings_map->SetContentSetting( | 107 host_content_settings_map->SetContentSetting( |
| 107 pattern, | 108 pattern, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 #endif | 205 #endif |
| 205 host_content_settings_map->GetSettingsForOneType( | 206 host_content_settings_map->GetSettingsForOneType( |
| 206 CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &host_settings); | 207 CONTENT_SETTINGS_TYPE_POPUPS, std::string(), &host_settings); |
| 207 // |host_settings| contains only the default setting. | 208 // |host_settings| contains only the default setting. |
| 208 EXPECT_EQ(1U, host_settings.size()); | 209 EXPECT_EQ(1U, host_settings.size()); |
| 209 } | 210 } |
| 210 | 211 |
| 211 TEST_F(HostContentSettingsMapTest, Clear) { | 212 TEST_F(HostContentSettingsMapTest, Clear) { |
| 212 TestingProfile profile; | 213 TestingProfile profile; |
| 213 HostContentSettingsMap* host_content_settings_map = | 214 HostContentSettingsMap* host_content_settings_map = |
| 214 profile.GetHostContentSettingsMap(); | 215 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 215 | 216 |
| 216 // Check clearing one type. | 217 // Check clearing one type. |
| 217 ContentSettingsPattern pattern = | 218 ContentSettingsPattern pattern = |
| 218 ContentSettingsPattern::FromString("[*.]example.org"); | 219 ContentSettingsPattern::FromString("[*.]example.org"); |
| 219 ContentSettingsPattern pattern2 = | 220 ContentSettingsPattern pattern2 = |
| 220 ContentSettingsPattern::FromString("[*.]example.net"); | 221 ContentSettingsPattern::FromString("[*.]example.net"); |
| 221 host_content_settings_map->SetContentSetting( | 222 host_content_settings_map->SetContentSetting( |
| 222 pattern2, | 223 pattern2, |
| 223 ContentSettingsPattern::Wildcard(), | 224 ContentSettingsPattern::Wildcard(), |
| 224 CONTENT_SETTINGS_TYPE_IMAGES, | 225 CONTENT_SETTINGS_TYPE_IMAGES, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 255 host_content_settings_map->GetSettingsForOneType( | 256 host_content_settings_map->GetSettingsForOneType( |
| 256 CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), &host_settings); | 257 CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), &host_settings); |
| 257 // |host_settings| contains the default setting and an exception. | 258 // |host_settings| contains the default setting and an exception. |
| 258 EXPECT_EQ(2U, host_settings.size()); | 259 EXPECT_EQ(2U, host_settings.size()); |
| 259 #endif | 260 #endif |
| 260 } | 261 } |
| 261 | 262 |
| 262 TEST_F(HostContentSettingsMapTest, Patterns) { | 263 TEST_F(HostContentSettingsMapTest, Patterns) { |
| 263 TestingProfile profile; | 264 TestingProfile profile; |
| 264 HostContentSettingsMap* host_content_settings_map = | 265 HostContentSettingsMap* host_content_settings_map = |
| 265 profile.GetHostContentSettingsMap(); | 266 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 266 | 267 |
| 267 GURL host1("http://example.com/"); | 268 GURL host1("http://example.com/"); |
| 268 GURL host2("http://www.example.com/"); | 269 GURL host2("http://www.example.com/"); |
| 269 GURL host3("http://example.org/"); | 270 GURL host3("http://example.org/"); |
| 270 ContentSettingsPattern pattern1 = | 271 ContentSettingsPattern pattern1 = |
| 271 ContentSettingsPattern::FromString("[*.]example.com"); | 272 ContentSettingsPattern::FromString("[*.]example.com"); |
| 272 ContentSettingsPattern pattern2 = | 273 ContentSettingsPattern pattern2 = |
| 273 ContentSettingsPattern::FromString("example.org"); | 274 ContentSettingsPattern::FromString("example.org"); |
| 274 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 275 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 275 host_content_settings_map->GetContentSetting( | 276 host_content_settings_map->GetContentSetting( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 296 std::string(), | 297 std::string(), |
| 297 CONTENT_SETTING_BLOCK); | 298 CONTENT_SETTING_BLOCK); |
| 298 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 299 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 299 host_content_settings_map->GetContentSetting( | 300 host_content_settings_map->GetContentSetting( |
| 300 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 301 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 301 } | 302 } |
| 302 | 303 |
| 303 TEST_F(HostContentSettingsMapTest, Observer) { | 304 TEST_F(HostContentSettingsMapTest, Observer) { |
| 304 TestingProfile profile; | 305 TestingProfile profile; |
| 305 HostContentSettingsMap* host_content_settings_map = | 306 HostContentSettingsMap* host_content_settings_map = |
| 306 profile.GetHostContentSettingsMap(); | 307 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 307 MockSettingsObserver observer(host_content_settings_map); | 308 MockSettingsObserver observer(host_content_settings_map); |
| 308 | 309 |
| 309 ContentSettingsPattern primary_pattern = | 310 ContentSettingsPattern primary_pattern = |
| 310 ContentSettingsPattern::FromString("[*.]example.com"); | 311 ContentSettingsPattern::FromString("[*.]example.com"); |
| 311 ContentSettingsPattern secondary_pattern = | 312 ContentSettingsPattern secondary_pattern = |
| 312 ContentSettingsPattern::Wildcard(); | 313 ContentSettingsPattern::Wildcard(); |
| 313 EXPECT_CALL(observer, | 314 EXPECT_CALL(observer, |
| 314 OnContentSettingsChanged(host_content_settings_map, | 315 OnContentSettingsChanged(host_content_settings_map, |
| 315 CONTENT_SETTINGS_TYPE_IMAGES, | 316 CONTENT_SETTINGS_TYPE_IMAGES, |
| 316 false, | 317 false, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 337 OnContentSettingsChanged(host_content_settings_map, | 338 OnContentSettingsChanged(host_content_settings_map, |
| 338 CONTENT_SETTINGS_TYPE_IMAGES, false, | 339 CONTENT_SETTINGS_TYPE_IMAGES, false, |
| 339 _, _, true)); | 340 _, _, true)); |
| 340 host_content_settings_map->SetDefaultContentSetting( | 341 host_content_settings_map->SetDefaultContentSetting( |
| 341 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 342 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
| 342 } | 343 } |
| 343 | 344 |
| 344 TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { | 345 TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { |
| 345 TestingProfile profile; | 346 TestingProfile profile; |
| 346 HostContentSettingsMap* host_content_settings_map = | 347 HostContentSettingsMap* host_content_settings_map = |
| 347 profile.GetHostContentSettingsMap(); | 348 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 348 | 349 |
| 349 PrefService* prefs = profile.GetPrefs(); | 350 PrefService* prefs = profile.GetPrefs(); |
| 350 GURL host("http://example.com"); | 351 GURL host("http://example.com"); |
| 351 | 352 |
| 352 host_content_settings_map->SetDefaultContentSetting( | 353 host_content_settings_map->SetDefaultContentSetting( |
| 353 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 354 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
| 354 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 355 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 355 host_content_settings_map->GetContentSetting( | 356 host_content_settings_map->GetContentSetting( |
| 356 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 357 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 357 | 358 |
| 358 const content_settings::WebsiteSettingsInfo* info = | 359 const content_settings::WebsiteSettingsInfo* info = |
| 359 content_settings::WebsiteSettingsRegistry::GetInstance()->Get( | 360 content_settings::WebsiteSettingsRegistry::GetInstance()->Get( |
| 360 CONTENT_SETTINGS_TYPE_IMAGES); | 361 CONTENT_SETTINGS_TYPE_IMAGES); |
| 361 // Clearing the backing pref should also clear the internal cache. | 362 // Clearing the backing pref should also clear the internal cache. |
| 362 prefs->ClearPref(info->default_value_pref_name()); | 363 prefs->ClearPref(info->default_value_pref_name()); |
| 363 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 364 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 364 host_content_settings_map->GetContentSetting( | 365 host_content_settings_map->GetContentSetting( |
| 365 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 366 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 366 | 367 |
| 367 // Reseting the pref to its previous value should update the cache. | 368 // Reseting the pref to its previous value should update the cache. |
| 368 prefs->SetInteger(info->default_value_pref_name(), CONTENT_SETTING_BLOCK); | 369 prefs->SetInteger(info->default_value_pref_name(), CONTENT_SETTING_BLOCK); |
| 369 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 370 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 370 host_content_settings_map->GetContentSetting( | 371 host_content_settings_map->GetContentSetting( |
| 371 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 372 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 372 } | 373 } |
| 373 | 374 |
| 374 TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { | 375 TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { |
| 375 TestingProfile profile; | 376 TestingProfile profile; |
| 376 HostContentSettingsMap* host_content_settings_map = | 377 HostContentSettingsMap* host_content_settings_map = |
| 377 profile.GetHostContentSettingsMap(); | 378 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 378 | 379 |
| 379 PrefService* prefs = profile.GetPrefs(); | 380 PrefService* prefs = profile.GetPrefs(); |
| 380 | 381 |
| 381 // Make a copy of the default pref value so we can reset it later. | 382 // Make a copy of the default pref value so we can reset it later. |
| 382 scoped_ptr<base::Value> default_value( | 383 scoped_ptr<base::Value> default_value( |
| 383 prefs->FindPreference(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES)) | 384 prefs->FindPreference(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES)) |
| 384 ->GetValue() | 385 ->GetValue() |
| 385 ->DeepCopy()); | 386 ->DeepCopy()); |
| 386 | 387 |
| 387 ContentSettingsPattern pattern = | 388 ContentSettingsPattern pattern = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 417 // Reseting the pref to its previous value should update the cache. | 418 // Reseting the pref to its previous value should update the cache. |
| 418 prefs->Set(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES), *new_value); | 419 prefs->Set(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES), *new_value); |
| 419 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 420 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 420 host_content_settings_map->GetContentSetting( | 421 host_content_settings_map->GetContentSetting( |
| 421 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 422 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 422 } | 423 } |
| 423 | 424 |
| 424 TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { | 425 TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { |
| 425 TestingProfile profile; | 426 TestingProfile profile; |
| 426 HostContentSettingsMap* host_content_settings_map = | 427 HostContentSettingsMap* host_content_settings_map = |
| 427 profile.GetHostContentSettingsMap(); | 428 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 428 content_settings::CookieSettings* cookie_settings = | 429 content_settings::CookieSettings* cookie_settings = |
| 429 CookieSettingsFactory::GetForProfile(&profile).get(); | 430 CookieSettingsFactory::GetForProfile(&profile).get(); |
| 430 | 431 |
| 431 ContentSettingsPattern pattern = | 432 ContentSettingsPattern pattern = |
| 432 ContentSettingsPattern::FromString("[*.]example.com"); | 433 ContentSettingsPattern::FromString("[*.]example.com"); |
| 433 GURL host_ending_with_dot("http://example.com./"); | 434 GURL host_ending_with_dot("http://example.com./"); |
| 434 | 435 |
| 435 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 436 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 436 host_content_settings_map->GetContentSetting( | 437 host_content_settings_map->GetContentSetting( |
| 437 host_ending_with_dot, | 438 host_ending_with_dot, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 CONTENT_SETTING_ALLOW, | 575 CONTENT_SETTING_ALLOW, |
| 575 host_content_settings_map->GetContentSetting(host_ending_with_dot, | 576 host_content_settings_map->GetContentSetting(host_ending_with_dot, |
| 576 host_ending_with_dot, | 577 host_ending_with_dot, |
| 577 CONTENT_SETTINGS_TYPE_POPUPS, | 578 CONTENT_SETTINGS_TYPE_POPUPS, |
| 578 std::string())); | 579 std::string())); |
| 579 } | 580 } |
| 580 | 581 |
| 581 TEST_F(HostContentSettingsMapTest, NestedSettings) { | 582 TEST_F(HostContentSettingsMapTest, NestedSettings) { |
| 582 TestingProfile profile; | 583 TestingProfile profile; |
| 583 HostContentSettingsMap* host_content_settings_map = | 584 HostContentSettingsMap* host_content_settings_map = |
| 584 profile.GetHostContentSettingsMap(); | 585 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 585 | 586 |
| 586 GURL host("http://a.b.example.com/"); | 587 GURL host("http://a.b.example.com/"); |
| 587 ContentSettingsPattern pattern1 = | 588 ContentSettingsPattern pattern1 = |
| 588 ContentSettingsPattern::FromString("[*.]example.com"); | 589 ContentSettingsPattern::FromString("[*.]example.com"); |
| 589 ContentSettingsPattern pattern2 = | 590 ContentSettingsPattern pattern2 = |
| 590 ContentSettingsPattern::FromString("[*.]b.example.com"); | 591 ContentSettingsPattern::FromString("[*.]b.example.com"); |
| 591 ContentSettingsPattern pattern3 = | 592 ContentSettingsPattern pattern3 = |
| 592 ContentSettingsPattern::FromString("a.b.example.com"); | 593 ContentSettingsPattern::FromString("a.b.example.com"); |
| 593 | 594 |
| 594 host_content_settings_map->SetContentSetting( | 595 host_content_settings_map->SetContentSetting( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 host_content_settings_map->GetContentSetting( | 641 host_content_settings_map->GetContentSetting( |
| 641 host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string())); | 642 host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string())); |
| 642 EXPECT_EQ(CONTENT_SETTING_ASK, | 643 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 643 host_content_settings_map->GetContentSetting( | 644 host_content_settings_map->GetContentSetting( |
| 644 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); | 645 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); |
| 645 } | 646 } |
| 646 | 647 |
| 647 TEST_F(HostContentSettingsMapTest, OffTheRecord) { | 648 TEST_F(HostContentSettingsMapTest, OffTheRecord) { |
| 648 TestingProfile profile; | 649 TestingProfile profile; |
| 649 HostContentSettingsMap* host_content_settings_map = | 650 HostContentSettingsMap* host_content_settings_map = |
| 650 profile.GetHostContentSettingsMap(); | 651 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 651 scoped_refptr<HostContentSettingsMap> otr_map( | 652 scoped_refptr<HostContentSettingsMap> otr_map( |
| 652 new HostContentSettingsMap(profile.GetPrefs(), | 653 new HostContentSettingsMap(profile.GetPrefs(), |
| 653 true)); | 654 true)); |
| 654 | 655 |
| 655 GURL host("http://example.com/"); | 656 GURL host("http://example.com/"); |
| 656 ContentSettingsPattern pattern = | 657 ContentSettingsPattern pattern = |
| 657 ContentSettingsPattern::FromString("[*.]example.com"); | 658 ContentSettingsPattern::FromString("[*.]example.com"); |
| 658 | 659 |
| 659 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 660 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 660 host_content_settings_map->GetContentSetting( | 661 host_content_settings_map->GetContentSetting( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 GetPrefName(CONTENT_SETTINGS_TYPE_PLUGINS)); | 708 GetPrefName(CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 708 base::DictionaryValue* all_settings_dictionary = update.Get(); | 709 base::DictionaryValue* all_settings_dictionary = update.Get(); |
| 709 ASSERT_TRUE(NULL != all_settings_dictionary); | 710 ASSERT_TRUE(NULL != all_settings_dictionary); |
| 710 | 711 |
| 711 base::DictionaryValue* dummy_payload = new base::DictionaryValue; | 712 base::DictionaryValue* dummy_payload = new base::DictionaryValue; |
| 712 dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW); | 713 dummy_payload->SetInteger("setting", CONTENT_SETTING_ALLOW); |
| 713 all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*", | 714 all_settings_dictionary->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*", |
| 714 dummy_payload); | 715 dummy_payload); |
| 715 } | 716 } |
| 716 | 717 |
| 717 profile.GetHostContentSettingsMap(); | 718 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 718 | 719 |
| 719 const base::DictionaryValue* all_settings_dictionary = | 720 const base::DictionaryValue* all_settings_dictionary = |
| 720 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_PLUGINS)); | 721 prefs->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_PLUGINS)); |
| 721 const base::DictionaryValue* result = NULL; | 722 const base::DictionaryValue* result = NULL; |
| 722 EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( | 723 EXPECT_FALSE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( |
| 723 "[*.]\xC4\x87ira.com,*", &result)); | 724 "[*.]\xC4\x87ira.com,*", &result)); |
| 724 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( | 725 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( |
| 725 "[*.]xn--ira-ppa.com,*", &result)); | 726 "[*.]xn--ira-ppa.com,*", &result)); |
| 726 } | 727 } |
| 727 | 728 |
| 728 // If both Unicode and its punycode pattern exist, make sure we don't touch the | 729 // If both Unicode and its punycode pattern exist, make sure we don't touch the |
| 729 // settings for the punycode, and that Unicode pattern gets deleted. | 730 // settings for the punycode, and that Unicode pattern gets deleted. |
| 730 TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { | 731 TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { |
| 731 TestingProfile profile; | 732 TestingProfile profile; |
| 732 | 733 |
| 733 scoped_ptr<base::Value> value = | 734 scoped_ptr<base::Value> value = |
| 734 base::JSONReader::Read("{\"[*.]\\xC4\\x87ira.com,*\":{\"setting\":1}}"); | 735 base::JSONReader::Read("{\"[*.]\\xC4\\x87ira.com,*\":{\"setting\":1}}"); |
| 735 profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES), *value); | 736 profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES), *value); |
| 736 | 737 |
| 737 // Set punycode equivalent, with different setting. | 738 // Set punycode equivalent, with different setting. |
| 738 scoped_ptr<base::Value> puny_value = | 739 scoped_ptr<base::Value> puny_value = |
| 739 base::JSONReader::Read("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}"); | 740 base::JSONReader::Read("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}"); |
| 740 profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES), | 741 profile.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES), |
| 741 *puny_value); | 742 *puny_value); |
| 742 | 743 |
| 743 // Initialize the content map. | 744 // Initialize the content map. |
| 744 profile.GetHostContentSettingsMap(); | 745 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 745 | 746 |
| 746 const base::DictionaryValue& content_setting_prefs = | 747 const base::DictionaryValue& content_setting_prefs = |
| 747 *profile.GetPrefs()->GetDictionary( | 748 *profile.GetPrefs()->GetDictionary( |
| 748 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); | 749 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES)); |
| 749 std::string prefs_as_json; | 750 std::string prefs_as_json; |
| 750 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); | 751 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); |
| 751 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}", | 752 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}", |
| 752 prefs_as_json.c_str()); | 753 prefs_as_json.c_str()); |
| 753 } | 754 } |
| 754 | 755 |
| 755 // If a default-content-setting is managed, the managed value should be used | 756 // If a default-content-setting is managed, the managed value should be used |
| 756 // instead of the default value. | 757 // instead of the default value. |
| 757 TEST_F(HostContentSettingsMapTest, ManagedDefaultContentSetting) { | 758 TEST_F(HostContentSettingsMapTest, ManagedDefaultContentSetting) { |
| 758 TestingProfile profile; | 759 TestingProfile profile; |
| 759 HostContentSettingsMap* host_content_settings_map = | 760 HostContentSettingsMap* host_content_settings_map = |
| 760 profile.GetHostContentSettingsMap(); | 761 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 761 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 762 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); |
| 762 | 763 |
| 763 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 764 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 764 host_content_settings_map->GetDefaultContentSetting( | 765 host_content_settings_map->GetDefaultContentSetting( |
| 765 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); | 766 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); |
| 766 | 767 |
| 767 // Set managed-default-content-setting through the coresponding preferences. | 768 // Set managed-default-content-setting through the coresponding preferences. |
| 768 prefs->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting, | 769 prefs->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting, |
| 769 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); | 770 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); |
| 770 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 771 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 790 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 791 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 791 host_content_settings_map->GetDefaultContentSetting( | 792 host_content_settings_map->GetDefaultContentSetting( |
| 792 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); | 793 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); |
| 793 #endif | 794 #endif |
| 794 } | 795 } |
| 795 | 796 |
| 796 TEST_F(HostContentSettingsMapTest, | 797 TEST_F(HostContentSettingsMapTest, |
| 797 GetNonDefaultContentSettingsIfTypeManaged) { | 798 GetNonDefaultContentSettingsIfTypeManaged) { |
| 798 TestingProfile profile; | 799 TestingProfile profile; |
| 799 HostContentSettingsMap* host_content_settings_map = | 800 HostContentSettingsMap* host_content_settings_map = |
| 800 profile.GetHostContentSettingsMap(); | 801 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 801 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 802 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); |
| 802 | 803 |
| 803 // Set pattern for JavaScript setting. | 804 // Set pattern for JavaScript setting. |
| 804 ContentSettingsPattern pattern = | 805 ContentSettingsPattern pattern = |
| 805 ContentSettingsPattern::FromString("[*.]example.com"); | 806 ContentSettingsPattern::FromString("[*.]example.com"); |
| 806 host_content_settings_map->SetContentSetting( | 807 host_content_settings_map->SetContentSetting( |
| 807 pattern, | 808 pattern, |
| 808 ContentSettingsPattern::Wildcard(), | 809 ContentSettingsPattern::Wildcard(), |
| 809 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 810 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 810 std::string(), | 811 std::string(), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 826 host_content_settings_map->GetContentSetting( | 827 host_content_settings_map->GetContentSetting( |
| 827 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 828 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
| 828 } | 829 } |
| 829 | 830 |
| 830 // Managed default content setting should have higher priority | 831 // Managed default content setting should have higher priority |
| 831 // than user defined patterns. | 832 // than user defined patterns. |
| 832 TEST_F(HostContentSettingsMapTest, | 833 TEST_F(HostContentSettingsMapTest, |
| 833 ManagedDefaultContentSettingIgnoreUserPattern) { | 834 ManagedDefaultContentSettingIgnoreUserPattern) { |
| 834 TestingProfile profile; | 835 TestingProfile profile; |
| 835 HostContentSettingsMap* host_content_settings_map = | 836 HostContentSettingsMap* host_content_settings_map = |
| 836 profile.GetHostContentSettingsMap(); | 837 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 837 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 838 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); |
| 838 | 839 |
| 839 // Block all JavaScript. | 840 // Block all JavaScript. |
| 840 host_content_settings_map->SetDefaultContentSetting( | 841 host_content_settings_map->SetDefaultContentSetting( |
| 841 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); | 842 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); |
| 842 | 843 |
| 843 // Set an exception to allow "[*.]example.com" | 844 // Set an exception to allow "[*.]example.com" |
| 844 ContentSettingsPattern pattern = | 845 ContentSettingsPattern pattern = |
| 845 ContentSettingsPattern::FromString("[*.]example.com"); | 846 ContentSettingsPattern::FromString("[*.]example.com"); |
| 846 | 847 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 871 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 872 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 872 host_content_settings_map->GetContentSetting( | 873 host_content_settings_map->GetContentSetting( |
| 873 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 874 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
| 874 } | 875 } |
| 875 | 876 |
| 876 // If a default-content-setting is set to managed setting, the user defined | 877 // If a default-content-setting is set to managed setting, the user defined |
| 877 // setting should be preserved. | 878 // setting should be preserved. |
| 878 TEST_F(HostContentSettingsMapTest, OverwrittenDefaultContentSetting) { | 879 TEST_F(HostContentSettingsMapTest, OverwrittenDefaultContentSetting) { |
| 879 TestingProfile profile; | 880 TestingProfile profile; |
| 880 HostContentSettingsMap* host_content_settings_map = | 881 HostContentSettingsMap* host_content_settings_map = |
| 881 profile.GetHostContentSettingsMap(); | 882 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 882 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 883 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); |
| 883 | 884 |
| 884 // Set user defined default-content-setting for Cookies. | 885 // Set user defined default-content-setting for Cookies. |
| 885 host_content_settings_map->SetDefaultContentSetting( | 886 host_content_settings_map->SetDefaultContentSetting( |
| 886 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); | 887 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); |
| 887 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 888 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 888 host_content_settings_map->GetDefaultContentSetting( | 889 host_content_settings_map->GetDefaultContentSetting( |
| 889 CONTENT_SETTINGS_TYPE_COOKIES, NULL)); | 890 CONTENT_SETTINGS_TYPE_COOKIES, NULL)); |
| 890 | 891 |
| 891 // Set preference to manage the default-content-setting for Cookies. | 892 // Set preference to manage the default-content-setting for Cookies. |
| 892 prefs->SetManagedPref(prefs::kManagedDefaultCookiesSetting, | 893 prefs->SetManagedPref(prefs::kManagedDefaultCookiesSetting, |
| 893 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); | 894 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); |
| 894 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 895 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 895 host_content_settings_map->GetDefaultContentSetting( | 896 host_content_settings_map->GetDefaultContentSetting( |
| 896 CONTENT_SETTINGS_TYPE_COOKIES, NULL)); | 897 CONTENT_SETTINGS_TYPE_COOKIES, NULL)); |
| 897 | 898 |
| 898 // Remove the preference to manage the default-content-setting for Cookies. | 899 // Remove the preference to manage the default-content-setting for Cookies. |
| 899 prefs->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting); | 900 prefs->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting); |
| 900 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 901 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 901 host_content_settings_map->GetDefaultContentSetting( | 902 host_content_settings_map->GetDefaultContentSetting( |
| 902 CONTENT_SETTINGS_TYPE_COOKIES, NULL)); | 903 CONTENT_SETTINGS_TYPE_COOKIES, NULL)); |
| 903 } | 904 } |
| 904 | 905 |
| 905 // If a setting for a default-content-setting-type is set while the type is | 906 // If a setting for a default-content-setting-type is set while the type is |
| 906 // managed, then the new setting should be preserved and used after the | 907 // managed, then the new setting should be preserved and used after the |
| 907 // default-content-setting-type is not managed anymore. | 908 // default-content-setting-type is not managed anymore. |
| 908 TEST_F(HostContentSettingsMapTest, SettingDefaultContentSettingsWhenManaged) { | 909 TEST_F(HostContentSettingsMapTest, SettingDefaultContentSettingsWhenManaged) { |
| 909 TestingProfile profile; | 910 TestingProfile profile; |
| 910 HostContentSettingsMap* host_content_settings_map = | 911 HostContentSettingsMap* host_content_settings_map = |
| 911 profile.GetHostContentSettingsMap(); | 912 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 912 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); | 913 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); |
| 913 | 914 |
| 914 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, | 915 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, |
| 915 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); | 916 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); |
| 916 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 917 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 917 host_content_settings_map->GetDefaultContentSetting( | 918 host_content_settings_map->GetDefaultContentSetting( |
| 918 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); | 919 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); |
| 919 | 920 |
| 920 host_content_settings_map->SetDefaultContentSetting( | 921 host_content_settings_map->SetDefaultContentSetting( |
| 921 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); | 922 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
| 922 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 923 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 923 host_content_settings_map->GetDefaultContentSetting( | 924 host_content_settings_map->GetDefaultContentSetting( |
| 924 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); | 925 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); |
| 925 | 926 |
| 926 prefs->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting); | 927 prefs->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting); |
| 927 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 928 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 928 host_content_settings_map->GetDefaultContentSetting( | 929 host_content_settings_map->GetDefaultContentSetting( |
| 929 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); | 930 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); |
| 930 } | 931 } |
| 931 | 932 |
| 932 TEST_F(HostContentSettingsMapTest, GetContentSetting) { | 933 TEST_F(HostContentSettingsMapTest, GetContentSetting) { |
| 933 TestingProfile profile; | 934 TestingProfile profile; |
| 934 HostContentSettingsMap* host_content_settings_map = | 935 HostContentSettingsMap* host_content_settings_map = |
| 935 profile.GetHostContentSettingsMap(); | 936 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 936 | 937 |
| 937 GURL host("http://example.com/"); | 938 GURL host("http://example.com/"); |
| 938 GURL embedder("chrome://foo"); | 939 GURL embedder("chrome://foo"); |
| 939 ContentSettingsPattern pattern = | 940 ContentSettingsPattern pattern = |
| 940 ContentSettingsPattern::FromString("[*.]example.com"); | 941 ContentSettingsPattern::FromString("[*.]example.com"); |
| 941 host_content_settings_map->SetContentSetting( | 942 host_content_settings_map->SetContentSetting( |
| 942 pattern, | 943 pattern, |
| 943 ContentSettingsPattern::Wildcard(), | 944 ContentSettingsPattern::Wildcard(), |
| 944 CONTENT_SETTINGS_TYPE_IMAGES, | 945 CONTENT_SETTINGS_TYPE_IMAGES, |
| 945 std::string(), | 946 std::string(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 prefs, CONTENT_SETTING_ALLOW, | 987 prefs, CONTENT_SETTING_ALLOW, |
| 987 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 988 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
| 988 | 989 |
| 989 // TODO(msramek): Add more checks for setting type - setting pairs where | 990 // TODO(msramek): Add more checks for setting type - setting pairs where |
| 990 // it is not obvious whether or not they are allowed. | 991 // it is not obvious whether or not they are allowed. |
| 991 } | 992 } |
| 992 | 993 |
| 993 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { | 994 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { |
| 994 TestingProfile profile; | 995 TestingProfile profile; |
| 995 HostContentSettingsMap* host_content_settings_map = | 996 HostContentSettingsMap* host_content_settings_map = |
| 996 profile.GetHostContentSettingsMap(); | 997 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 997 content_settings::MockObserver mock_observer; | 998 content_settings::MockObserver mock_observer; |
| 998 | 999 |
| 999 GURL host("http://example.com/"); | 1000 GURL host("http://example.com/"); |
| 1000 ContentSettingsPattern pattern = | 1001 ContentSettingsPattern pattern = |
| 1001 ContentSettingsPattern::FromString("[*.]example.com"); | 1002 ContentSettingsPattern::FromString("[*.]example.com"); |
| 1002 EXPECT_CALL(mock_observer, | 1003 EXPECT_CALL(mock_observer, |
| 1003 OnContentSettingChanged(pattern, | 1004 OnContentSettingChanged(pattern, |
| 1004 ContentSettingsPattern::Wildcard(), | 1005 ContentSettingsPattern::Wildcard(), |
| 1005 CONTENT_SETTINGS_TYPE_IMAGES, | 1006 CONTENT_SETTINGS_TYPE_IMAGES, |
| 1006 "")); | 1007 "")); |
| 1007 | 1008 |
| 1008 host_content_settings_map->AddObserver(&mock_observer); | 1009 host_content_settings_map->AddObserver(&mock_observer); |
| 1009 | 1010 |
| 1010 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1011 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1011 host_content_settings_map->GetContentSetting( | 1012 host_content_settings_map->GetContentSetting( |
| 1012 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1013 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 1013 host_content_settings_map->SetContentSetting( | 1014 host_content_settings_map->SetContentSetting( |
| 1014 pattern, | 1015 pattern, |
| 1015 ContentSettingsPattern::Wildcard(), | 1016 ContentSettingsPattern::Wildcard(), |
| 1016 CONTENT_SETTINGS_TYPE_IMAGES, | 1017 CONTENT_SETTINGS_TYPE_IMAGES, |
| 1017 std::string(), | 1018 std::string(), |
| 1018 CONTENT_SETTING_DEFAULT); | 1019 CONTENT_SETTING_DEFAULT); |
| 1019 } | 1020 } |
| OLD | NEW |