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

Side by Side Diff: components/content_settings/core/browser/content_settings_pref.cc

Issue 2853983002: Ensure settings returned from Content Settings providers are valid (Closed)
Patch Set: Ensure settings returned from Content Settings providers are valid Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/content_settings/core/browser/content_settings_pref.h" 5 #include "components/content_settings/core/browser/content_settings_pref.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 base::Time last_modified = GetTimeStamp(settings_dictionary); 274 base::Time last_modified = GetTimeStamp(settings_dictionary);
275 for (base::DictionaryValue::Iterator j(*resource_dictionary); 275 for (base::DictionaryValue::Iterator j(*resource_dictionary);
276 !j.IsAtEnd(); 276 !j.IsAtEnd();
277 j.Advance()) { 277 j.Advance()) {
278 const std::string& resource_identifier(j.key()); 278 const std::string& resource_identifier(j.key());
279 int setting = CONTENT_SETTING_DEFAULT; 279 int setting = CONTENT_SETTING_DEFAULT;
280 bool is_integer = j.value().GetAsInteger(&setting); 280 bool is_integer = j.value().GetAsInteger(&setting);
281 DCHECK(is_integer); 281 DCHECK(is_integer);
282 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); 282 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
283 std::unique_ptr<base::Value> setting_ptr(new base::Value(setting)); 283 std::unique_ptr<base::Value> setting_ptr(new base::Value(setting));
284 DCHECK(IsValueAllowedForType(setting_ptr.get(), content_type_));
284 // Per resource settings store a single timestamps for all resources. 285 // Per resource settings store a single timestamps for all resources.
285 value_map_.SetValue(pattern_pair.first, pattern_pair.second, 286 value_map_.SetValue(pattern_pair.first, pattern_pair.second,
286 content_type_, resource_identifier, last_modified, 287 content_type_, resource_identifier, last_modified,
287 setting_ptr->DeepCopy()); 288 setting_ptr->DeepCopy());
288 } 289 }
289 } 290 }
290 } 291 }
291 292
292 const base::Value* value = nullptr; 293 const base::Value* value = nullptr;
293 settings_dictionary->GetWithoutPathExpansion(kSettingPath, &value); 294 settings_dictionary->GetWithoutPathExpansion(kSettingPath, &value);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 485
485 void ContentSettingsPref::AssertLockNotHeld() const { 486 void ContentSettingsPref::AssertLockNotHeld() const {
486 #if !defined(NDEBUG) 487 #if !defined(NDEBUG)
487 // |Lock::Acquire()| will assert if the lock is held by this thread. 488 // |Lock::Acquire()| will assert if the lock is held by this thread.
488 lock_.Acquire(); 489 lock_.Acquire();
489 lock_.Release(); 490 lock_.Release();
490 #endif 491 #endif
491 } 492 }
492 493
493 } // namespace content_settings 494 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698