| 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 "chrome/browser/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 typedef std::vector<content_settings::Rule> Rules; | 43 typedef std::vector<content_settings::Rule> Rules; |
| 44 | 44 |
| 45 typedef std::pair<std::string, std::string> StringPair; | 45 typedef std::pair<std::string, std::string> StringPair; |
| 46 | 46 |
| 47 // TODO(bauerb): Expose constants. | 47 // TODO(bauerb): Expose constants. |
| 48 const char* kProviderNames[] = { | 48 const char* kProviderNames[] = { |
| 49 "platform_app", | 49 "platform_app", |
| 50 "policy", | 50 "policy", |
| 51 "extension", | 51 "extension", |
| 52 "override", |
| 52 "preference", | 53 "preference", |
| 53 "default" | 54 "default" |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 content_settings::SettingSource kProviderSourceMap[] = { | 57 content_settings::SettingSource kProviderSourceMap[] = { |
| 57 content_settings::SETTING_SOURCE_EXTENSION, | 58 content_settings::SETTING_SOURCE_EXTENSION, |
| 58 content_settings::SETTING_SOURCE_POLICY, | 59 content_settings::SETTING_SOURCE_POLICY, |
| 59 content_settings::SETTING_SOURCE_EXTENSION, | 60 content_settings::SETTING_SOURCE_EXTENSION, |
| 60 content_settings::SETTING_SOURCE_USER, | 61 content_settings::SETTING_SOURCE_USER, |
| 61 content_settings::SETTING_SOURCE_USER, | 62 content_settings::SETTING_SOURCE_USER, |
| 63 content_settings::SETTING_SOURCE_USER, |
| 62 }; | 64 }; |
| 63 COMPILE_ASSERT(arraysize(kProviderSourceMap) == | 65 COMPILE_ASSERT(arraysize(kProviderSourceMap) == |
| 64 HostContentSettingsMap::NUM_PROVIDER_TYPES, | 66 HostContentSettingsMap::NUM_PROVIDER_TYPES, |
| 65 kProviderSourceMap_has_incorrect_size); | 67 kProviderSourceMap_has_incorrect_size); |
| 66 | 68 |
| 67 // Returns true if the |content_type| supports a resource identifier. | 69 // Returns true if the |content_type| supports a resource identifier. |
| 68 // Resource identifiers are supported (but not required) for plug-ins. | 70 // Resource identifiers are supported (but not required) for plug-ins. |
| 69 bool SupportsResourceIdentifier(ContentSettingsType content_type) { | 71 bool SupportsResourceIdentifier(ContentSettingsType content_type) { |
| 70 return content_type == CONTENT_SETTINGS_TYPE_PLUGINS; | 72 return content_type == CONTENT_SETTINGS_TYPE_PLUGINS; |
| 71 } | 73 } |
| 72 | 74 |
| 73 } // namespace | 75 } // namespace |
| 74 | 76 |
| 75 HostContentSettingsMap::HostContentSettingsMap( | 77 HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs, |
| 76 PrefService* prefs, | 78 bool incognito) |
| 77 bool incognito) : | 79 : |
| 78 #ifndef NDEBUG | 80 #ifndef NDEBUG |
| 79 used_from_thread_id_(base::PlatformThread::CurrentId()), | 81 used_from_thread_id_(base::PlatformThread::CurrentId()), |
| 80 #endif | 82 #endif |
| 81 prefs_(prefs), | 83 prefs_(prefs), |
| 82 is_off_the_record_(incognito) { | 84 is_off_the_record_(incognito) { |
| 83 content_settings::ObservableProvider* policy_provider = | 85 content_settings::ObservableProvider* policy_provider = |
| 84 new content_settings::PolicyProvider(prefs_); | 86 new content_settings::PolicyProvider(prefs_); |
| 85 policy_provider->AddObserver(this); | 87 policy_provider->AddObserver(this); |
| 86 content_settings_providers_[POLICY_PROVIDER] = policy_provider; | 88 content_settings_providers_[POLICY_PROVIDER] = policy_provider; |
| 87 | 89 |
| 88 content_settings::ObservableProvider* pref_provider = | 90 content_settings::ObservableProvider* pref_provider = |
| 89 new content_settings::PrefProvider(prefs_, is_off_the_record_); | 91 new content_settings::PrefProvider(prefs_, is_off_the_record_); |
| 90 pref_provider->AddObserver(this); | 92 pref_provider->AddObserver(this); |
| 91 content_settings_providers_[PREF_PROVIDER] = pref_provider; | 93 content_settings_providers_[PREF_PROVIDER] = pref_provider; |
| 92 | 94 |
| 93 content_settings::ObservableProvider* default_provider = | 95 content_settings::ObservableProvider* default_provider = |
| 94 new content_settings::DefaultProvider(prefs_, is_off_the_record_); | 96 new content_settings::DefaultProvider(prefs_, is_off_the_record_); |
| 95 default_provider->AddObserver(this); | 97 default_provider->AddObserver(this); |
| 96 content_settings_providers_[DEFAULT_PROVIDER] = default_provider; | 98 content_settings_providers_[DEFAULT_PROVIDER] = default_provider; |
| 97 | 99 |
| 100 content_settings_providers_[OVERRIDE_PROVIDER] = |
| 101 new content_settings::OverrideProvider(prefs_, is_off_the_record_); |
| 102 |
| 98 if (!is_off_the_record_) { | 103 if (!is_off_the_record_) { |
| 99 // Migrate obsolete preferences. | 104 // Migrate obsolete preferences. |
| 100 MigrateObsoleteClearOnExitPref(); | 105 MigrateObsoleteClearOnExitPref(); |
| 101 } | 106 } |
| 102 } | 107 } |
| 103 | 108 |
| 104 // static | 109 // static |
| 105 void HostContentSettingsMap::RegisterProfilePrefs( | 110 void HostContentSettingsMap::RegisterProfilePrefs( |
| 106 user_prefs::PrefRegistrySyncable* registry) { | 111 user_prefs::PrefRegistrySyncable* registry) { |
| 107 registry->RegisterIntegerPref( | 112 registry->RegisterIntegerPref( |
| 108 prefs::kContentSettingsWindowLastTabIndex, | 113 prefs::kContentSettingsWindowLastTabIndex, |
| 109 0, | 114 0, |
| 110 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 115 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 111 registry->RegisterBooleanPref( | 116 registry->RegisterBooleanPref( |
| 112 prefs::kContentSettingsClearOnExitMigrated, | 117 prefs::kContentSettingsClearOnExitMigrated, |
| 113 false, | 118 false, |
| 114 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 119 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 115 | 120 |
| 116 // Register the prefs for the content settings providers. | 121 // Register the prefs for the content settings providers. |
| 117 content_settings::DefaultProvider::RegisterProfilePrefs(registry); | 122 content_settings::DefaultProvider::RegisterProfilePrefs(registry); |
| 118 content_settings::PrefProvider::RegisterProfilePrefs(registry); | 123 content_settings::PrefProvider::RegisterProfilePrefs(registry); |
| 119 content_settings::PolicyProvider::RegisterProfilePrefs(registry); | 124 content_settings::PolicyProvider::RegisterProfilePrefs(registry); |
| 125 content_settings::OverrideProvider::RegisterProfilePrefs(registry); |
| 120 } | 126 } |
| 121 | 127 |
| 122 void HostContentSettingsMap::RegisterProvider( | 128 void HostContentSettingsMap::RegisterProvider( |
| 123 ProviderType type, | 129 ProviderType type, |
| 124 scoped_ptr<content_settings::ObservableProvider> provider) { | 130 scoped_ptr<content_settings::ObservableProvider> provider) { |
| 125 DCHECK(!content_settings_providers_[type]); | 131 DCHECK(!content_settings_providers_[type]); |
| 126 provider->AddObserver(this); | 132 provider->AddObserver(this); |
| 127 content_settings_providers_[type] = provider.release(); | 133 content_settings_providers_[type] = provider.release(); |
| 128 | 134 |
| 129 #ifndef NDEBUG | 135 #ifndef NDEBUG |
| (...skipping 27 matching lines...) Expand all Loading... |
| 157 ContentSetting HostContentSettingsMap::GetDefaultContentSetting( | 163 ContentSetting HostContentSettingsMap::GetDefaultContentSetting( |
| 158 ContentSettingsType content_type, | 164 ContentSettingsType content_type, |
| 159 std::string* provider_id) const { | 165 std::string* provider_id) const { |
| 160 UsedContentSettingsProviders(); | 166 UsedContentSettingsProviders(); |
| 161 | 167 |
| 162 // Iterate through the list of providers and return the first non-NULL value | 168 // Iterate through the list of providers and return the first non-NULL value |
| 163 // that matches |primary_url| and |secondary_url|. | 169 // that matches |primary_url| and |secondary_url|. |
| 164 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 170 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| 165 provider != content_settings_providers_.end(); | 171 provider != content_settings_providers_.end(); |
| 166 ++provider) { | 172 ++provider) { |
| 167 if (provider->first == PREF_PROVIDER) | 173 if (provider->first == PREF_PROVIDER || |
| 174 provider->first == OVERRIDE_PROVIDER) |
| 168 continue; | 175 continue; |
| 169 ContentSetting default_setting = | 176 ContentSetting default_setting = |
| 170 GetDefaultContentSettingFromProvider(content_type, provider->second); | 177 GetDefaultContentSettingFromProvider(content_type, provider->second); |
| 171 if (default_setting != CONTENT_SETTING_DEFAULT) { | 178 if (default_setting != CONTENT_SETTING_DEFAULT) { |
| 172 if (provider_id) | 179 if (provider_id) |
| 173 *provider_id = kProviderNames[provider->first]; | 180 *provider_id = kProviderNames[provider->first]; |
| 174 return default_setting; | 181 return default_setting; |
| 175 } | 182 } |
| 176 } | 183 } |
| 177 | 184 |
| 178 return CONTENT_SETTING_DEFAULT; | 185 return CONTENT_SETTING_DEFAULT; |
| 179 } | 186 } |
| 180 | 187 |
| 181 ContentSetting HostContentSettingsMap::GetContentSetting( | 188 ContentSetting HostContentSettingsMap::GetContentSetting( |
| 182 const GURL& primary_url, | 189 const GURL& primary_url, |
| 183 const GURL& secondary_url, | 190 const GURL& secondary_url, |
| 184 ContentSettingsType content_type, | 191 ContentSettingsType content_type, |
| 185 const std::string& resource_identifier) const { | 192 const std::string& resource_identifier) const { |
| 186 DCHECK(!ContentTypeHasCompoundValue(content_type)); | 193 DCHECK(!ContentTypeHasCompoundValue(content_type)); |
| 187 scoped_ptr<base::Value> value(GetWebsiteSetting( | 194 scoped_ptr<base::Value> value = GetWebsiteSetting( |
| 188 primary_url, secondary_url, content_type, resource_identifier, NULL)); | 195 primary_url, secondary_url, content_type, resource_identifier, NULL); |
| 189 return content_settings::ValueToContentSetting(value.get()); | 196 return content_settings::ValueToContentSetting(value.get()); |
| 190 } | 197 } |
| 191 | 198 |
| 192 void HostContentSettingsMap::GetSettingsForOneType( | 199 void HostContentSettingsMap::GetSettingsForOneType( |
| 193 ContentSettingsType content_type, | 200 ContentSettingsType content_type, |
| 194 const std::string& resource_identifier, | 201 const std::string& resource_identifier, |
| 195 ContentSettingsForOneType* settings) const { | 202 ContentSettingsForOneType* settings) const { |
| 196 DCHECK(SupportsResourceIdentifier(content_type) || | 203 DCHECK(SupportsResourceIdentifier(content_type) || |
| 197 resource_identifier.empty()); | 204 resource_identifier.empty()); |
| 198 DCHECK(settings); | 205 DCHECK(settings); |
| 199 UsedContentSettingsProviders(); | 206 UsedContentSettingsProviders(); |
| 200 | 207 |
| 201 settings->clear(); | 208 settings->clear(); |
| 202 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 209 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| 203 provider != content_settings_providers_.end(); | 210 provider != content_settings_providers_.end(); |
| 204 ++provider) { | 211 ++provider) { |
| 212 if (provider->first == OVERRIDE_PROVIDER) |
| 213 continue; |
| 205 // For each provider, iterate first the incognito-specific rules, then the | 214 // For each provider, iterate first the incognito-specific rules, then the |
| 206 // normal rules. | 215 // normal rules. |
| 207 if (is_off_the_record_) { | 216 if (is_off_the_record_) { |
| 208 AddSettingsForOneType(provider->second, | 217 AddSettingsForOneType(provider->second, |
| 209 provider->first, | 218 provider->first, |
| 210 content_type, | 219 content_type, |
| 211 resource_identifier, | 220 resource_identifier, |
| 212 settings, | 221 settings, |
| 213 true); | 222 true); |
| 214 } | 223 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 base::Time HostContentSettingsMap::GetLastUsageByPattern( | 378 base::Time HostContentSettingsMap::GetLastUsageByPattern( |
| 370 const ContentSettingsPattern& primary_pattern, | 379 const ContentSettingsPattern& primary_pattern, |
| 371 const ContentSettingsPattern& secondary_pattern, | 380 const ContentSettingsPattern& secondary_pattern, |
| 372 ContentSettingsType content_type) { | 381 ContentSettingsType content_type) { |
| 373 UsedContentSettingsProviders(); | 382 UsedContentSettingsProviders(); |
| 374 | 383 |
| 375 return GetPrefProvider()->GetLastUsage( | 384 return GetPrefProvider()->GetLastUsage( |
| 376 primary_pattern, secondary_pattern, content_type); | 385 primary_pattern, secondary_pattern, content_type); |
| 377 } | 386 } |
| 378 | 387 |
| 388 ContentSetting HostContentSettingsMap::GetContentSettingWithoutOverride( |
| 389 const GURL& primary_url, |
| 390 const GURL& secondary_url, |
| 391 ContentSettingsType content_type, |
| 392 const std::string& resource_identifier) { |
| 393 scoped_ptr<base::Value> value(GetWebsiteSettingWithoutOverride( |
| 394 primary_url, secondary_url, content_type, resource_identifier, NULL)); |
| 395 return content_settings::ValueToContentSetting(value.get()); |
| 396 } |
| 397 |
| 398 scoped_ptr<base::Value> |
| 399 HostContentSettingsMap::GetWebsiteSettingWithoutOverride( |
| 400 const GURL& primary_url, |
| 401 const GURL& secondary_url, |
| 402 ContentSettingsType content_type, |
| 403 const std::string& resource_identifier, |
| 404 content_settings::SettingInfo* info) const { |
| 405 return GetWebsiteSettingInternal(primary_url, |
| 406 secondary_url, |
| 407 content_type, |
| 408 resource_identifier, |
| 409 info, |
| 410 false); |
| 411 } |
| 412 |
| 413 void HostContentSettingsMap::SetContentSettingOverride( |
| 414 ContentSettingsType content_type, |
| 415 bool is_enabled) { |
| 416 UsedContentSettingsProviders(); |
| 417 |
| 418 content_settings::OverrideProvider* override = |
| 419 static_cast<content_settings::OverrideProvider*>( |
| 420 content_settings_providers_[OVERRIDE_PROVIDER]); |
| 421 override->SetOverrideSetting(content_type, is_enabled); |
| 422 } |
| 423 |
| 424 bool HostContentSettingsMap::GetContentSettingOverride( |
| 425 ContentSettingsType content_type) { |
| 426 UsedContentSettingsProviders(); |
| 427 |
| 428 content_settings::OverrideProvider* override = |
| 429 static_cast<content_settings::OverrideProvider*>( |
| 430 content_settings_providers_[OVERRIDE_PROVIDER]); |
| 431 return override->IsEnabled(content_type); |
| 432 } |
| 433 |
| 379 void HostContentSettingsMap::AddObserver(content_settings::Observer* observer) { | 434 void HostContentSettingsMap::AddObserver(content_settings::Observer* observer) { |
| 380 observers_.AddObserver(observer); | 435 observers_.AddObserver(observer); |
| 381 } | 436 } |
| 382 | 437 |
| 383 void HostContentSettingsMap::RemoveObserver( | 438 void HostContentSettingsMap::RemoveObserver( |
| 384 content_settings::Observer* observer) { | 439 content_settings::Observer* observer) { |
| 385 observers_.RemoveObserver(observer); | 440 observers_.RemoveObserver(observer); |
| 386 } | 441 } |
| 387 | 442 |
| 388 void HostContentSettingsMap::SetPrefClockForTesting( | 443 void HostContentSettingsMap::SetPrefClockForTesting( |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 return secondary_url.SchemeIs(extensions::kExtensionScheme); | 710 return secondary_url.SchemeIs(extensions::kExtensionScheme); |
| 656 default: | 711 default: |
| 657 return true; | 712 return true; |
| 658 } | 713 } |
| 659 } | 714 } |
| 660 #endif | 715 #endif |
| 661 return primary_url.SchemeIs(content::kChromeDevToolsScheme) || | 716 return primary_url.SchemeIs(content::kChromeDevToolsScheme) || |
| 662 primary_url.SchemeIs(content::kChromeUIScheme); | 717 primary_url.SchemeIs(content::kChromeUIScheme); |
| 663 } | 718 } |
| 664 | 719 |
| 665 base::Value* HostContentSettingsMap::GetWebsiteSetting( | 720 scoped_ptr<base::Value> HostContentSettingsMap::GetWebsiteSetting( |
| 666 const GURL& primary_url, | 721 const GURL& primary_url, |
| 667 const GURL& secondary_url, | 722 const GURL& secondary_url, |
| 668 ContentSettingsType content_type, | 723 ContentSettingsType content_type, |
| 669 const std::string& resource_identifier, | 724 const std::string& resource_identifier, |
| 670 content_settings::SettingInfo* info) const { | 725 content_settings::SettingInfo* info) const { |
| 671 DCHECK(SupportsResourceIdentifier(content_type) || | 726 DCHECK(SupportsResourceIdentifier(content_type) || |
| 672 resource_identifier.empty()); | 727 resource_identifier.empty()); |
| 673 | 728 |
| 674 // Check if the scheme of the requesting url is whitelisted. | 729 // Check if the scheme of the requesting url is whitelisted. |
| 675 if (ShouldAllowAllContent(primary_url, secondary_url, content_type)) { | 730 if (ShouldAllowAllContent(primary_url, secondary_url, content_type)) { |
| 676 if (info) { | 731 if (info) { |
| 677 info->source = content_settings::SETTING_SOURCE_WHITELIST; | 732 info->source = content_settings::SETTING_SOURCE_WHITELIST; |
| 678 info->primary_pattern = ContentSettingsPattern::Wildcard(); | 733 info->primary_pattern = ContentSettingsPattern::Wildcard(); |
| 679 info->secondary_pattern = ContentSettingsPattern::Wildcard(); | 734 info->secondary_pattern = ContentSettingsPattern::Wildcard(); |
| 680 } | 735 } |
| 681 return new base::FundamentalValue(CONTENT_SETTING_ALLOW); | 736 return scoped_ptr<base::Value>( |
| 737 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); |
| 682 } | 738 } |
| 683 | 739 |
| 740 return GetWebsiteSettingInternal(primary_url, |
| 741 secondary_url, |
| 742 content_type, |
| 743 resource_identifier, |
| 744 info, |
| 745 true); |
| 746 } |
| 747 |
| 748 // static |
| 749 HostContentSettingsMap::ProviderType |
| 750 HostContentSettingsMap::GetProviderTypeFromSource(const std::string& source) { |
| 751 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { |
| 752 if (source == kProviderNames[i]) |
| 753 return static_cast<ProviderType>(i); |
| 754 } |
| 755 |
| 756 NOTREACHED(); |
| 757 return DEFAULT_PROVIDER; |
| 758 } |
| 759 |
| 760 content_settings::PrefProvider* HostContentSettingsMap::GetPrefProvider() { |
| 761 return static_cast<content_settings::PrefProvider*>( |
| 762 content_settings_providers_[PREF_PROVIDER]); |
| 763 } |
| 764 |
| 765 scoped_ptr<base::Value> HostContentSettingsMap::GetWebsiteSettingInternal( |
| 766 const GURL& primary_url, |
| 767 const GURL& secondary_url, |
| 768 ContentSettingsType content_type, |
| 769 const std::string& resource_identifier, |
| 770 content_settings::SettingInfo* info, |
| 771 bool get_override) const { |
| 772 UsedContentSettingsProviders(); |
| 684 ContentSettingsPattern* primary_pattern = NULL; | 773 ContentSettingsPattern* primary_pattern = NULL; |
| 685 ContentSettingsPattern* secondary_pattern = NULL; | 774 ContentSettingsPattern* secondary_pattern = NULL; |
| 686 if (info) { | 775 if (info) { |
| 687 primary_pattern = &info->primary_pattern; | 776 primary_pattern = &info->primary_pattern; |
| 688 secondary_pattern = &info->secondary_pattern; | 777 secondary_pattern = &info->secondary_pattern; |
| 689 } | 778 } |
| 690 | 779 |
| 691 // The list of |content_settings_providers_| is ordered according to their | 780 // The list of |content_settings_providers_| is ordered according to their |
| 692 // precedence. | 781 // precedence. |
| 693 for (ConstProviderIterator provider = content_settings_providers_.begin(); | 782 for (ConstProviderIterator provider = content_settings_providers_.begin(); |
| 694 provider != content_settings_providers_.end(); | 783 provider != content_settings_providers_.end(); |
| 695 ++provider) { | 784 ++provider) { |
| 696 base::Value* value = content_settings::GetContentSettingValueAndPatterns( | 785 if (!get_override && provider->first == OVERRIDE_PROVIDER) |
| 697 provider->second, primary_url, secondary_url, content_type, | 786 continue; |
| 698 resource_identifier, is_off_the_record_, | 787 |
| 699 primary_pattern, secondary_pattern); | 788 scoped_ptr<base::Value> value( |
| 789 content_settings::GetContentSettingValueAndPatterns(provider->second, |
| 790 primary_url, |
| 791 secondary_url, |
| 792 content_type, |
| 793 resource_identifier, |
| 794 is_off_the_record_, |
| 795 primary_pattern, |
| 796 secondary_pattern)); |
| 700 if (value) { | 797 if (value) { |
| 701 if (info) | 798 if (info) |
| 702 info->source = kProviderSourceMap[provider->first]; | 799 info->source = kProviderSourceMap[provider->first]; |
| 703 return value; | 800 return value.Pass(); |
| 704 } | 801 } |
| 705 } | 802 } |
| 706 | 803 |
| 707 if (info) { | 804 if (info) { |
| 708 info->source = content_settings::SETTING_SOURCE_NONE; | 805 info->source = content_settings::SETTING_SOURCE_NONE; |
| 709 info->primary_pattern = ContentSettingsPattern(); | 806 info->primary_pattern = ContentSettingsPattern(); |
| 710 info->secondary_pattern = ContentSettingsPattern(); | 807 info->secondary_pattern = ContentSettingsPattern(); |
| 711 } | 808 } |
| 712 return NULL; | 809 return scoped_ptr<base::Value>(); |
| 713 } | 810 } |
| 714 | |
| 715 // static | |
| 716 HostContentSettingsMap::ProviderType | |
| 717 HostContentSettingsMap::GetProviderTypeFromSource( | |
| 718 const std::string& source) { | |
| 719 for (size_t i = 0; i < arraysize(kProviderNames); ++i) { | |
| 720 if (source == kProviderNames[i]) | |
| 721 return static_cast<ProviderType>(i); | |
| 722 } | |
| 723 | |
| 724 NOTREACHED(); | |
| 725 return DEFAULT_PROVIDER; | |
| 726 } | |
| 727 | |
| 728 content_settings::PrefProvider* HostContentSettingsMap::GetPrefProvider() { | |
| 729 return static_cast<content_settings::PrefProvider*>( | |
| 730 content_settings_providers_[PREF_PROVIDER]); | |
| 731 } | |
| OLD | NEW |