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

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

Issue 1605453003: Ensure content settings aren't persisted in the guest profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 resource_identifier, 136 resource_identifier,
137 value.get()); 137 value.get());
138 } 138 }
139 139
140 notify_callback_.Run( 140 notify_callback_.Run(
141 primary_pattern, secondary_pattern, content_type_, resource_identifier); 141 primary_pattern, secondary_pattern, content_type_, resource_identifier);
142 142
143 return true; 143 return true;
144 } 144 }
145 145
146 void ContentSettingsPref::ClearPref() {
147 DCHECK(thread_checker_.CalledOnValidThread());
148 DCHECK(prefs_);
149
150 {
151 base::AutoLock auto_lock(lock_);
152 value_map_.clear();
153 }
154
155 {
156 base::AutoReset<bool> auto_reset(&updating_preferences_, true);
157 DictionaryPrefUpdate update(prefs_, pref_name_);
158 base::DictionaryValue* pattern_pairs_settings = update.Get();
159 pattern_pairs_settings->Clear();
160 }
161 }
162
146 void ContentSettingsPref::ClearAllContentSettingsRules() { 163 void ContentSettingsPref::ClearAllContentSettingsRules() {
147 DCHECK(thread_checker_.CalledOnValidThread()); 164 DCHECK(thread_checker_.CalledOnValidThread());
148 DCHECK(prefs_); 165 DCHECK(prefs_);
149 166
150 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_; 167 if (is_incognito_) {
151 if (!is_incognito_)
152 map_to_modify = &value_map_;
153
154 {
155 base::AutoLock auto_lock(lock_); 168 base::AutoLock auto_lock(lock_);
156 map_to_modify->clear(); 169 incognito_value_map_.clear();
157 } 170 } else {
158 171 ClearPref();
159 if (!is_incognito_) {
160 // Clear the preference.
161 {
162 base::AutoReset<bool> auto_reset(&updating_preferences_, true);
163 DictionaryPrefUpdate update(prefs_, pref_name_);
164 base::DictionaryValue* pattern_pairs_settings = update.Get();
165 pattern_pairs_settings->Clear();
166 }
167 } 172 }
168 173
169 notify_callback_.Run(ContentSettingsPattern(), 174 notify_callback_.Run(ContentSettingsPattern(),
170 ContentSettingsPattern(), 175 ContentSettingsPattern(),
171 content_type_, 176 content_type_,
172 ResourceIdentifier()); 177 ResourceIdentifier());
173 } 178 }
174 179
175 void ContentSettingsPref::UpdateLastUsage( 180 void ContentSettingsPref::UpdateLastUsage(
176 const ContentSettingsPattern& primary_pattern, 181 const ContentSettingsPattern& primary_pattern,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 508
504 void ContentSettingsPref::AssertLockNotHeld() const { 509 void ContentSettingsPref::AssertLockNotHeld() const {
505 #if !defined(NDEBUG) 510 #if !defined(NDEBUG)
506 // |Lock::Acquire()| will assert if the lock is held by this thread. 511 // |Lock::Acquire()| will assert if the lock is held by this thread.
507 lock_.Acquire(); 512 lock_.Acquire();
508 lock_.Release(); 513 lock_.Release();
509 #endif 514 #endif
510 } 515 }
511 516
512 } // namespace content_settings 517 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698