Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/content_settings/content_settings_pref_provider.cc

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 DictionaryValue* default_settings_dictionary = update.Get(); 178 DictionaryValue* default_settings_dictionary = update.Get();
179 if ((setting == CONTENT_SETTING_DEFAULT) || 179 if ((setting == CONTENT_SETTING_DEFAULT) ||
180 (setting == kDefaultSettings[content_type])) { 180 (setting == kDefaultSettings[content_type])) {
181 default_content_settings_.settings[content_type] = 181 default_content_settings_.settings[content_type] =
182 kDefaultSettings[content_type]; 182 kDefaultSettings[content_type];
183 default_settings_dictionary->RemoveWithoutPathExpansion(dictionary_path, 183 default_settings_dictionary->RemoveWithoutPathExpansion(dictionary_path,
184 NULL); 184 NULL);
185 } else { 185 } else {
186 default_content_settings_.settings[content_type] = setting; 186 default_content_settings_.settings[content_type] = setting;
187 default_settings_dictionary->SetWithoutPathExpansion( 187 default_settings_dictionary->SetWithoutPathExpansion(
188 dictionary_path, Value::CreateIntegerValue(setting)); 188 dictionary_path, base::NumberValue::New(setting));
189 } 189 }
190 190
191 // Keep the obsolete pref in sync as long as backwards compatibility is 191 // Keep the obsolete pref in sync as long as backwards compatibility is
192 // required. This is required to keep sync working correctly. 192 // required. This is required to keep sync working correctly.
193 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 193 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
194 prefs_->SetInteger(prefs::kGeolocationDefaultContentSetting, 194 prefs_->SetInteger(prefs::kGeolocationDefaultContentSetting,
195 setting == CONTENT_SETTING_DEFAULT ? 195 setting == CONTENT_SETTING_DEFAULT ?
196 kDefaultSettings[content_type] : setting); 196 kDefaultSettings[content_type] : setting);
197 } 197 }
198 } 198 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 primary_pattern, 483 primary_pattern,
484 secondary_pattern, 484 secondary_pattern,
485 content_type, 485 content_type,
486 resource_identifier); 486 resource_identifier);
487 } else { 487 } else {
488 map_to_modify->SetValue( 488 map_to_modify->SetValue(
489 primary_pattern, 489 primary_pattern,
490 secondary_pattern, 490 secondary_pattern,
491 content_type, 491 content_type,
492 resource_identifier, 492 resource_identifier,
493 Value::CreateIntegerValue(setting)); 493 base::NumberValue::New(setting));
494 } 494 }
495 } 495 }
496 496
497 // Update the content settings preference. 497 // Update the content settings preference.
498 if (!is_incognito_) { 498 if (!is_incognito_) {
499 UpdatePref(primary_pattern, 499 UpdatePref(primary_pattern,
500 secondary_pattern, 500 secondary_pattern,
501 content_type, 501 content_type,
502 resource_identifier, 502 resource_identifier,
503 setting); 503 setting);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 int setting = CONTENT_SETTING_DEFAULT; 661 int setting = CONTENT_SETTING_DEFAULT;
662 found = resource_dictionary->GetIntegerWithoutPathExpansion( 662 found = resource_dictionary->GetIntegerWithoutPathExpansion(
663 resource_identifier, &setting); 663 resource_identifier, &setting);
664 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); 664 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
665 setting = ClickToPlayFixup(content_type, 665 setting = ClickToPlayFixup(content_type,
666 ContentSetting(setting)); 666 ContentSetting(setting));
667 value_map_.SetValue(pattern_pair.first, 667 value_map_.SetValue(pattern_pair.first,
668 pattern_pair.second, 668 pattern_pair.second,
669 content_type, 669 content_type,
670 resource_identifier, 670 resource_identifier,
671 Value::CreateIntegerValue(setting)); 671 base::NumberValue::New(setting));
672 } 672 }
673 } 673 }
674 } else if (kTypeNames[i]) { 674 } else if (kTypeNames[i]) {
675 const std::string content_type_str(kTypeNames[i]); 675 const std::string content_type_str(kTypeNames[i]);
676 int setting = CONTENT_SETTING_DEFAULT; 676 int setting = CONTENT_SETTING_DEFAULT;
677 if (settings_dictionary->GetIntegerWithoutPathExpansion( 677 if (settings_dictionary->GetIntegerWithoutPathExpansion(
678 content_type_str, &setting)) { 678 content_type_str, &setting)) {
679 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); 679 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
680 setting = FixObsoleteCookiePromptMode(content_type, 680 setting = FixObsoleteCookiePromptMode(content_type,
681 ContentSetting(setting)); 681 ContentSetting(setting));
682 setting = ClickToPlayFixup(content_type, 682 setting = ClickToPlayFixup(content_type,
683 ContentSetting(setting)); 683 ContentSetting(setting));
684 value_map_.SetValue(pattern_pair.first, 684 value_map_.SetValue(pattern_pair.first,
685 pattern_pair.second, 685 pattern_pair.second,
686 content_type, 686 content_type,
687 ResourceIdentifier(""), 687 ResourceIdentifier(""),
688 Value::CreateIntegerValue(setting)); 688 base::NumberValue::New(setting));
689 } 689 }
690 } 690 }
691 } 691 }
692 } 692 }
693 } 693 }
694 } 694 }
695 695
696 void PrefProvider::UpdatePatternsPref( 696 void PrefProvider::UpdatePatternsPref(
697 const ContentSettingsPattern& primary_pattern, 697 const ContentSettingsPattern& primary_pattern,
698 const ContentSettingsPattern& secondary_pattern, 698 const ContentSettingsPattern& secondary_pattern,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // Update resource dictionary. 731 // Update resource dictionary.
732 if (setting == CONTENT_SETTING_DEFAULT) { 732 if (setting == CONTENT_SETTING_DEFAULT) {
733 resource_dictionary->RemoveWithoutPathExpansion(resource_identifier, 733 resource_dictionary->RemoveWithoutPathExpansion(resource_identifier,
734 NULL); 734 NULL);
735 if (resource_dictionary->empty()) { 735 if (resource_dictionary->empty()) {
736 settings_dictionary->RemoveWithoutPathExpansion( 736 settings_dictionary->RemoveWithoutPathExpansion(
737 res_dictionary_path, NULL); 737 res_dictionary_path, NULL);
738 } 738 }
739 } else { 739 } else {
740 resource_dictionary->SetWithoutPathExpansion( 740 resource_dictionary->SetWithoutPathExpansion(
741 resource_identifier, Value::CreateIntegerValue(setting)); 741 resource_identifier, base::NumberValue::New(setting));
742 } 742 }
743 } else { 743 } else {
744 // Update settings dictionary. 744 // Update settings dictionary.
745 std::string setting_path(kTypeNames[content_type]); 745 std::string setting_path(kTypeNames[content_type]);
746 if (setting == CONTENT_SETTING_DEFAULT) { 746 if (setting == CONTENT_SETTING_DEFAULT) {
747 settings_dictionary->RemoveWithoutPathExpansion(setting_path, 747 settings_dictionary->RemoveWithoutPathExpansion(setting_path,
748 NULL); 748 NULL);
749 } else { 749 } else {
750 settings_dictionary->SetWithoutPathExpansion( 750 settings_dictionary->SetWithoutPathExpansion(
751 setting_path, Value::CreateIntegerValue(setting)); 751 setting_path, base::NumberValue::New(setting));
752 } 752 }
753 } 753 }
754 // Remove the settings dictionary if it is empty. 754 // Remove the settings dictionary if it is empty.
755 if (settings_dictionary->empty()) { 755 if (settings_dictionary->empty()) {
756 all_settings_dictionary->RemoveWithoutPathExpansion( 756 all_settings_dictionary->RemoveWithoutPathExpansion(
757 pattern_str, NULL); 757 pattern_str, NULL);
758 } 758 }
759 } 759 }
760 } 760 }
761 761
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // Update resource dictionary. 798 // Update resource dictionary.
799 if (setting == CONTENT_SETTING_DEFAULT) { 799 if (setting == CONTENT_SETTING_DEFAULT) {
800 resource_dictionary->RemoveWithoutPathExpansion(resource_identifier, 800 resource_dictionary->RemoveWithoutPathExpansion(resource_identifier,
801 NULL); 801 NULL);
802 if (resource_dictionary->empty()) { 802 if (resource_dictionary->empty()) {
803 settings_dictionary->RemoveWithoutPathExpansion( 803 settings_dictionary->RemoveWithoutPathExpansion(
804 res_dictionary_path, NULL); 804 res_dictionary_path, NULL);
805 } 805 }
806 } else { 806 } else {
807 resource_dictionary->SetWithoutPathExpansion( 807 resource_dictionary->SetWithoutPathExpansion(
808 resource_identifier, Value::CreateIntegerValue(setting)); 808 resource_identifier, base::NumberValue::New(setting));
809 } 809 }
810 } else { 810 } else {
811 // Update settings dictionary. 811 // Update settings dictionary.
812 std::string setting_path(kTypeNames[content_type]); 812 std::string setting_path(kTypeNames[content_type]);
813 if (setting == CONTENT_SETTING_DEFAULT) { 813 if (setting == CONTENT_SETTING_DEFAULT) {
814 settings_dictionary->RemoveWithoutPathExpansion(setting_path, 814 settings_dictionary->RemoveWithoutPathExpansion(setting_path,
815 NULL); 815 NULL);
816 } else { 816 } else {
817 settings_dictionary->SetWithoutPathExpansion( 817 settings_dictionary->SetWithoutPathExpansion(
818 setting_path, Value::CreateIntegerValue(setting)); 818 setting_path, base::NumberValue::New(setting));
819 } 819 }
820 } 820 }
821 // Remove the settings dictionary if it is empty. 821 // Remove the settings dictionary if it is empty.
822 if (settings_dictionary->empty()) { 822 if (settings_dictionary->empty()) {
823 all_settings_dictionary->RemoveWithoutPathExpansion( 823 all_settings_dictionary->RemoveWithoutPathExpansion(
824 pattern_str, NULL); 824 pattern_str, NULL);
825 } 825 }
826 } 826 }
827 } 827 }
828 828
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 DCHECK(found); 1076 DCHECK(found);
1077 std::string new_key = pattern_pair.first.ToString(); 1077 std::string new_key = pattern_pair.first.ToString();
1078 // Existing values are overwritten. 1078 // Existing values are overwritten.
1079 obsolete_settings_dictionary->SetWithoutPathExpansion( 1079 obsolete_settings_dictionary->SetWithoutPathExpansion(
1080 new_key, dictionary->DeepCopy()); 1080 new_key, dictionary->DeepCopy());
1081 } 1081 }
1082 } 1082 }
1083 } 1083 }
1084 1084
1085 } // namespace content_settings 1085 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698