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

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_store.cc

Issue 10383303: Gracefully deal with clearing content settings for unregistered extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/api/content_settings/content_settings_store. h" 5 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return &(i->second->incognito_session_only_settings); 189 return &(i->second->incognito_session_only_settings);
190 } 190 }
191 } 191 }
192 return NULL; 192 return NULL;
193 } 193 }
194 194
195 const OriginIdentifierValueMap* ContentSettingsStore::GetValueMap( 195 const OriginIdentifierValueMap* ContentSettingsStore::GetValueMap(
196 const std::string& ext_id, 196 const std::string& ext_id,
197 ExtensionPrefsScope scope) const { 197 ExtensionPrefsScope scope) const {
198 ExtensionEntryMap::const_iterator i = FindEntry(ext_id); 198 ExtensionEntryMap::const_iterator i = FindEntry(ext_id);
199 if (i != entries_.end()) { 199 if (i == entries_.end())
200 switch (scope) { 200 return NULL;
201 case kExtensionPrefsScopeRegular: 201
202 return &(i->second->settings); 202 switch (scope) {
203 case kExtensionPrefsScopeIncognitoPersistent: 203 case kExtensionPrefsScopeRegular:
204 return &(i->second->incognito_persistent_settings); 204 return &(i->second->settings);
205 case kExtensionPrefsScopeIncognitoSessionOnly: 205 case kExtensionPrefsScopeIncognitoPersistent:
206 return &(i->second->incognito_session_only_settings); 206 return &(i->second->incognito_persistent_settings);
207 } 207 case kExtensionPrefsScopeIncognitoSessionOnly:
208 return &(i->second->incognito_session_only_settings);
208 } 209 }
210
211 NOTREACHED();
209 return NULL; 212 return NULL;
210 } 213 }
211 214
212 void ContentSettingsStore::ClearContentSettingsForExtension( 215 void ContentSettingsStore::ClearContentSettingsForExtension(
213 const std::string& ext_id, 216 const std::string& ext_id,
214 ExtensionPrefsScope scope) { 217 ExtensionPrefsScope scope) {
215 bool notify = false; 218 bool notify = false;
216 { 219 {
217 base::AutoLock lock(lock_); 220 base::AutoLock lock(lock_);
218 OriginIdentifierValueMap* map = GetValueMap(ext_id, scope); 221 OriginIdentifierValueMap* map = GetValueMap(ext_id, scope);
222 if (!map)
223 return;
219 notify = !map->empty(); 224 notify = !map->empty();
220 map->clear(); 225 map->clear();
221 } 226 }
222 if (notify) { 227 if (notify) {
223 NotifyOfContentSettingChanged(ext_id, scope != kExtensionPrefsScopeRegular); 228 NotifyOfContentSettingChanged(ext_id, scope != kExtensionPrefsScopeRegular);
224 } 229 }
225 } 230 }
226 231
227 base::ListValue* ContentSettingsStore::GetSettingsForExtension( 232 base::ListValue* ContentSettingsStore::GetSettingsForExtension(
228 const std::string& extension_id, 233 const std::string& extension_id,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 ContentSettingsStore::FindEntry(const std::string& ext_id) const { 354 ContentSettingsStore::FindEntry(const std::string& ext_id) const {
350 ExtensionEntryMap::const_iterator i; 355 ExtensionEntryMap::const_iterator i;
351 for (i = entries_.begin(); i != entries_.end(); ++i) { 356 for (i = entries_.begin(); i != entries_.end(); ++i) {
352 if (i->second->id == ext_id) 357 if (i->second->id == ext_id)
353 return i; 358 return i;
354 } 359 }
355 return entries_.end(); 360 return entries_.end();
356 } 361 }
357 362
358 } // namespace extensions 363 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698