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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 ContentSettingsDetails details( | 595 ContentSettingsDetails details( |
596 requesting_pattern, content_type, std::string()); | 596 requesting_pattern, content_type, std::string()); |
597 NotifyObservers(details); | 597 NotifyObservers(details); |
598 } | 598 } |
599 | 599 |
600 void PrefProvider::ResetToDefaults() { | 600 void PrefProvider::ResetToDefaults() { |
601 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 601 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
602 | 602 |
603 { | 603 { |
604 base::AutoLock auto_lock(lock_); | 604 base::AutoLock auto_lock(lock_); |
605 value_map_.Clear(); | 605 value_map_.clear(); |
606 incognito_value_map_.Clear(); | 606 incognito_value_map_.clear(); |
607 } | 607 } |
608 | 608 |
609 if (!is_incognito_) { | 609 if (!is_incognito_) { |
610 PrefService* prefs = profile_->GetPrefs(); | 610 PrefService* prefs = profile_->GetPrefs(); |
611 updating_preferences_ = true; | 611 updating_preferences_ = true; |
612 prefs->ClearPref(prefs::kContentSettingsPatterns); | 612 prefs->ClearPref(prefs::kContentSettingsPatterns); |
613 updating_preferences_ = false; | 613 updating_preferences_ = false; |
614 } | 614 } |
615 } | 615 } |
616 | 616 |
(...skipping 15 matching lines...) Expand all Loading... |
632 | 632 |
633 { | 633 { |
634 base::AutoLock auto_lock(lock_); | 634 base::AutoLock auto_lock(lock_); |
635 | 635 |
636 OriginIdentifierValueMap::iterator entry(map_to_modify->begin()); | 636 OriginIdentifierValueMap::iterator entry(map_to_modify->begin()); |
637 while (entry != map_to_modify->end()) { | 637 while (entry != map_to_modify->end()) { |
638 if (entry->content_type == content_type) { | 638 if (entry->content_type == content_type) { |
639 std::string pattern_str = CreatePatternString( | 639 std::string pattern_str = CreatePatternString( |
640 entry->item_pattern, entry->top_level_frame_pattern); | 640 entry->item_pattern, entry->top_level_frame_pattern); |
641 // Delete current |entry| and set |entry| to the next value map entry. | 641 // Delete current |entry| and set |entry| to the next value map entry. |
642 entry = map_to_modify->DeleteValue(entry); | 642 entry = map_to_modify->erase(entry); |
643 | 643 |
644 // Update the content settings preference. | 644 // Update the content settings preference. |
645 if (all_settings_dictionary) { | 645 if (all_settings_dictionary) { |
646 // Update the settings dictionary. | 646 // Update the settings dictionary. |
647 DictionaryValue* settings_dictionary; | 647 DictionaryValue* settings_dictionary; |
648 bool found = | 648 bool found = |
649 all_settings_dictionary->GetDictionaryWithoutPathExpansion( | 649 all_settings_dictionary->GetDictionaryWithoutPathExpansion( |
650 pattern_str, &settings_dictionary); | 650 pattern_str, &settings_dictionary); |
651 DCHECK(found); | 651 DCHECK(found); |
652 settings_dictionary->RemoveWithoutPathExpansion( | 652 settings_dictionary->RemoveWithoutPathExpansion( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 // Private | 711 // Private |
712 | 712 |
713 void PrefProvider::ReadExceptions(bool overwrite) { | 713 void PrefProvider::ReadExceptions(bool overwrite) { |
714 base::AutoLock auto_lock(lock_); | 714 base::AutoLock auto_lock(lock_); |
715 | 715 |
716 PrefService* prefs = profile_->GetPrefs(); | 716 PrefService* prefs = profile_->GetPrefs(); |
717 const DictionaryValue* all_settings_dictionary = | 717 const DictionaryValue* all_settings_dictionary = |
718 prefs->GetDictionary(prefs::kContentSettingsPatterns); | 718 prefs->GetDictionary(prefs::kContentSettingsPatterns); |
719 | 719 |
720 if (overwrite) | 720 if (overwrite) |
721 value_map_.Clear(); | 721 value_map_.clear(); |
722 | 722 |
723 updating_preferences_ = true; | 723 updating_preferences_ = true; |
724 // Careful: The returned value could be NULL if the pref has never been set. | 724 // Careful: The returned value could be NULL if the pref has never been set. |
725 if (all_settings_dictionary != NULL) { | 725 if (all_settings_dictionary != NULL) { |
726 DictionaryPrefUpdate update(prefs, prefs::kContentSettingsPatterns); | 726 DictionaryPrefUpdate update(prefs, prefs::kContentSettingsPatterns); |
727 DictionaryValue* mutable_settings; | 727 DictionaryValue* mutable_settings; |
728 scoped_ptr<DictionaryValue> mutable_settings_scope; | 728 scoped_ptr<DictionaryValue> mutable_settings_scope; |
729 | 729 |
730 if (!is_incognito_) { | 730 if (!is_incognito_) { |
731 mutable_settings = update.Get(); | 731 mutable_settings = update.Get(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 ContentSettingsPattern::FromString(host), | 945 ContentSettingsPattern::FromString(host), |
946 CONTENT_SETTINGS_TYPE_POPUPS, | 946 CONTENT_SETTINGS_TYPE_POPUPS, |
947 "", | 947 "", |
948 CONTENT_SETTING_ALLOW); | 948 CONTENT_SETTING_ALLOW); |
949 } | 949 } |
950 prefs->ClearPref(prefs::kPopupWhitelistedHosts); | 950 prefs->ClearPref(prefs::kPopupWhitelistedHosts); |
951 } | 951 } |
952 } | 952 } |
953 | 953 |
954 } // namespace content_settings | 954 } // namespace content_settings |
OLD | NEW |