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

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

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 5 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
OLDNEW
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/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 10
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 // dictionary also contains a key that equals the primary |pattern| then 554 // dictionary also contains a key that equals the primary |pattern| then
555 // skip the current |key|. 555 // skip the current |key|.
556 if (sep_pos != std::string::npos && 556 if (sep_pos != std::string::npos &&
557 patterns_dictionary->HasKey(pattern.ToString())) { 557 patterns_dictionary->HasKey(pattern.ToString())) {
558 continue; 558 continue;
559 } 559 }
560 560
561 // Copy the legacy content settings for the current |key| from the 561 // Copy the legacy content settings for the current |key| from the
562 // obsolete pref prefs::kContentSettingsPatterns to the pref 562 // obsolete pref prefs::kContentSettingsPatterns to the pref
563 // prefs::kContentSettingsPatternPairs. 563 // prefs::kContentSettingsPatternPairs.
564 DictionaryValue* dictionary = NULL; 564 const DictionaryValue* dictionary = NULL;
565 bool found = patterns_dictionary->GetDictionaryWithoutPathExpansion( 565 bool found = patterns_dictionary->GetDictionaryWithoutPathExpansion(
566 key, &dictionary); 566 key, &dictionary);
567 DCHECK(found); 567 DCHECK(found);
568 std::string new_key = CreatePatternString( 568 std::string new_key = CreatePatternString(
569 pattern, ContentSettingsPattern::Wildcard()); 569 pattern, ContentSettingsPattern::Wildcard());
570 // Existing values are overwritten. 570 // Existing values are overwritten.
571 pattern_pairs_dictionary->SetWithoutPathExpansion( 571 pattern_pairs_dictionary->SetWithoutPathExpansion(
572 new_key, dictionary->DeepCopy()); 572 new_key, dictionary->DeepCopy());
573 } 573 }
574 } 574 }
(...skipping 17 matching lines...) Expand all
592 592
593 std::vector<std::pair<std::string, std::string> > corrupted_keys; 593 std::vector<std::pair<std::string, std::string> > corrupted_keys;
594 for (DictionaryValue::key_iterator i = 594 for (DictionaryValue::key_iterator i =
595 geolocation_settings->begin_keys(); 595 geolocation_settings->begin_keys();
596 i != geolocation_settings->end_keys(); 596 i != geolocation_settings->end_keys();
597 ++i) { 597 ++i) {
598 const std::string& primary_key(*i); 598 const std::string& primary_key(*i);
599 GURL primary_url(primary_key); 599 GURL primary_url(primary_key);
600 DCHECK(primary_url.is_valid()); 600 DCHECK(primary_url.is_valid());
601 601
602 DictionaryValue* requesting_origin_settings = NULL; 602 const DictionaryValue* requesting_origin_settings = NULL;
603 // The method GetDictionaryWithoutPathExpansion() returns false if the 603 // The method GetDictionaryWithoutPathExpansion() returns false if the
604 // value for the given key is not a |DictionaryValue|. If the value for the 604 // value for the given key is not a |DictionaryValue|. If the value for the
605 // |primary_key| is not a |DictionaryValue| then the location settings for 605 // |primary_key| is not a |DictionaryValue| then the location settings for
606 // this key are corrupted. Therefore they are ignored. 606 // this key are corrupted. Therefore they are ignored.
607 if (!geolocation_settings->GetDictionaryWithoutPathExpansion( 607 if (!geolocation_settings->GetDictionaryWithoutPathExpansion(
608 primary_key, &requesting_origin_settings)) 608 primary_key, &requesting_origin_settings))
609 continue; 609 continue;
610 610
611 for (DictionaryValue::key_iterator j = 611 for (DictionaryValue::key_iterator j =
612 requesting_origin_settings->begin_keys(); 612 requesting_origin_settings->begin_keys();
613 j != requesting_origin_settings->end_keys(); 613 j != requesting_origin_settings->end_keys();
614 ++j) { 614 ++j) {
615 const std::string& secondary_key(*j); 615 const std::string& secondary_key(*j);
616 GURL secondary_url(secondary_key); 616 GURL secondary_url(secondary_key);
617 // Save corrupted keys to remove them later. 617 // Save corrupted keys to remove them later.
618 if (!secondary_url.is_valid()) { 618 if (!secondary_url.is_valid()) {
619 corrupted_keys.push_back(std::make_pair(primary_key, secondary_key)); 619 corrupted_keys.push_back(std::make_pair(primary_key, secondary_key));
620 continue; 620 continue;
621 } 621 }
622 622
623 base::Value* value = NULL; 623 const base::Value* value = NULL;
624 bool found = requesting_origin_settings->GetWithoutPathExpansion( 624 bool found = requesting_origin_settings->GetWithoutPathExpansion(
625 secondary_key, &value); 625 secondary_key, &value);
626 DCHECK(found); 626 DCHECK(found);
627 627
628 ContentSettingsPattern primary_pattern = 628 ContentSettingsPattern primary_pattern =
629 ContentSettingsPattern::FromURLNoWildcard(primary_url); 629 ContentSettingsPattern::FromURLNoWildcard(primary_url);
630 ContentSettingsPattern secondary_pattern = 630 ContentSettingsPattern secondary_pattern =
631 ContentSettingsPattern::FromURLNoWildcard(secondary_url); 631 ContentSettingsPattern::FromURLNoWildcard(secondary_url);
632 DCHECK(primary_pattern.IsValid() && secondary_pattern.IsValid()); 632 DCHECK(primary_pattern.IsValid() && secondary_pattern.IsValid());
633 633
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 700
701 void PrefProvider::AssertLockNotHeld() const { 701 void PrefProvider::AssertLockNotHeld() const {
702 #if !defined(NDEBUG) 702 #if !defined(NDEBUG)
703 // |Lock::Acquire()| will assert if the lock is held by this thread. 703 // |Lock::Acquire()| will assert if the lock is held by this thread.
704 lock_.Acquire(); 704 lock_.Acquire();
705 lock_.Release(); 705 lock_.Release();
706 #endif 706 #endif
707 } 707 }
708 708
709 } // namespace content_settings 709 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698