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 <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (!pattern.IsValid()) | 745 if (!pattern.IsValid()) |
746 LOG(WARNING) << "Invalid pattern stored in content settings"; | 746 LOG(WARNING) << "Invalid pattern stored in content settings"; |
747 | 747 |
748 // Get settings dictionary for the current pattern string, and read | 748 // Get settings dictionary for the current pattern string, and read |
749 // settings from the dictionary. | 749 // settings from the dictionary. |
750 DictionaryValue* settings_dictionary = NULL; | 750 DictionaryValue* settings_dictionary = NULL; |
751 bool found = mutable_settings->GetDictionaryWithoutPathExpansion( | 751 bool found = mutable_settings->GetDictionaryWithoutPathExpansion( |
752 pattern_str, &settings_dictionary); | 752 pattern_str, &settings_dictionary); |
753 DCHECK(found); | 753 DCHECK(found); |
754 | 754 |
755 for (DictionaryValue::key_iterator i(settings_dictionary->begin_keys()); | 755 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
756 i != settings_dictionary->end_keys(); | 756 ContentSettingsType content_type = static_cast<ContentSettingsType>(i); |
757 ++i) { | |
758 const std::string& content_type_str(*i); | |
759 ContentSettingsType content_type = StringToContentSettingsType( | |
760 content_type_str); | |
761 if (content_type == CONTENT_SETTINGS_TYPE_DEFAULT) { | |
762 NOTREACHED(); | |
763 LOG(WARNING) << "Skip settings for invalid content settings type '" | |
764 << content_type_str << "'"; | |
765 continue; | |
766 } | |
767 | 757 |
768 if (RequiresResourceIdentifier(content_type)) { | 758 if (RequiresResourceIdentifier(content_type)) { |
| 759 const std::string content_type_str = kResourceTypeNames[i]; |
769 DictionaryValue* resource_dictionary = NULL; | 760 DictionaryValue* resource_dictionary = NULL; |
770 bool found = settings_dictionary->GetDictionary( | 761 if (settings_dictionary->GetDictionary( |
771 content_type_str, &resource_dictionary); | 762 content_type_str, &resource_dictionary)) { |
772 DCHECK(found); | 763 for (DictionaryValue::key_iterator j( |
773 for (DictionaryValue::key_iterator j( | 764 resource_dictionary->begin_keys()); |
774 resource_dictionary->begin_keys()); | 765 j != resource_dictionary->end_keys(); |
775 j != resource_dictionary->end_keys(); | 766 ++j) { |
776 ++j) { | 767 const std::string& resource_identifier(*j); |
777 const std::string& resource_identifier(*j); | 768 int setting = CONTENT_SETTING_DEFAULT; |
778 int setting = CONTENT_SETTING_DEFAULT; | 769 found = resource_dictionary->GetIntegerWithoutPathExpansion( |
779 found = resource_dictionary->GetIntegerWithoutPathExpansion( | 770 resource_identifier, &setting); |
780 resource_identifier, &setting); | 771 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); |
781 DCHECK(found); | 772 setting = ClickToPlayFixup(content_type, |
| 773 ContentSetting(setting)); |
| 774 value_map_.SetValue(pattern, |
| 775 pattern, |
| 776 content_type, |
| 777 resource_identifier, |
| 778 Value::CreateIntegerValue(setting)); |
| 779 } |
| 780 } |
| 781 } else if (kTypeNames[i]) { |
| 782 const std::string content_type_str(kTypeNames[i]); |
| 783 int setting = CONTENT_SETTING_DEFAULT; |
| 784 if (settings_dictionary->GetIntegerWithoutPathExpansion( |
| 785 content_type_str, &setting)) { |
| 786 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); |
| 787 setting = FixObsoleteCookiePromptMode(content_type, |
| 788 ContentSetting(setting)); |
782 setting = ClickToPlayFixup(content_type, | 789 setting = ClickToPlayFixup(content_type, |
783 ContentSetting(setting)); | 790 ContentSetting(setting)); |
784 value_map_.SetValue(pattern, | 791 value_map_.SetValue(pattern, |
785 pattern, | 792 pattern, |
786 content_type, | 793 content_type, |
787 resource_identifier, | 794 ResourceIdentifier(""), |
788 Value::CreateIntegerValue(setting)); | 795 Value::CreateIntegerValue(setting)); |
789 } | 796 } |
790 } else { | |
791 int setting = CONTENT_SETTING_DEFAULT; | |
792 bool found = settings_dictionary->GetIntegerWithoutPathExpansion( | |
793 content_type_str, &setting); | |
794 DCHECK(found); | |
795 setting = FixObsoleteCookiePromptMode(content_type, | |
796 ContentSetting(setting)); | |
797 setting = ClickToPlayFixup(content_type, | |
798 ContentSetting(setting)); | |
799 value_map_.SetValue(pattern, | |
800 pattern, | |
801 content_type, | |
802 ResourceIdentifier(""), | |
803 Value::CreateIntegerValue(setting)); | |
804 } | 797 } |
805 } | 798 } |
806 } | 799 } |
807 } | 800 } |
808 updating_preferences_ = false; | 801 updating_preferences_ = false; |
809 } | 802 } |
810 | 803 |
811 void PrefProvider::CanonicalizeContentSettingsExceptions( | 804 void PrefProvider::CanonicalizeContentSettingsExceptions( |
812 DictionaryValue* all_settings_dictionary) { | 805 DictionaryValue* all_settings_dictionary) { |
813 DCHECK(all_settings_dictionary); | 806 DCHECK(all_settings_dictionary); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 ContentSettingsPattern::FromString(host), | 938 ContentSettingsPattern::FromString(host), |
946 CONTENT_SETTINGS_TYPE_POPUPS, | 939 CONTENT_SETTINGS_TYPE_POPUPS, |
947 "", | 940 "", |
948 CONTENT_SETTING_ALLOW); | 941 CONTENT_SETTING_ALLOW); |
949 } | 942 } |
950 prefs->ClearPref(prefs::kPopupWhitelistedHosts); | 943 prefs->ClearPref(prefs::kPopupWhitelistedHosts); |
951 } | 944 } |
952 } | 945 } |
953 | 946 |
954 } // namespace content_settings | 947 } // namespace content_settings |
OLD | NEW |