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

Side by Side Diff: chrome/browser/extensions/extension_content_settings_store.cc

Issue 10543109: Merge 141415 - Gracefully deal with clearing content settings for unregistered extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/src
Patch Set: 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) 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/extensions/extension_content_settings_store.h" 5 #include "chrome/browser/extensions/extension_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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return &(i->second->incognito_session_only_settings); 187 return &(i->second->incognito_session_only_settings);
188 } 188 }
189 } 189 }
190 return NULL; 190 return NULL;
191 } 191 }
192 192
193 const OriginIdentifierValueMap* ExtensionContentSettingsStore::GetValueMap( 193 const OriginIdentifierValueMap* ExtensionContentSettingsStore::GetValueMap(
194 const std::string& ext_id, 194 const std::string& ext_id,
195 ExtensionPrefsScope scope) const { 195 ExtensionPrefsScope scope) const {
196 ExtensionEntryMap::const_iterator i = FindEntry(ext_id); 196 ExtensionEntryMap::const_iterator i = FindEntry(ext_id);
197 if (i != entries_.end()) { 197 if (i == entries_.end())
198 switch (scope) { 198 return NULL;
199 case kExtensionPrefsScopeRegular: 199
200 return &(i->second->settings); 200 switch (scope) {
201 case kExtensionPrefsScopeIncognitoPersistent: 201 case kExtensionPrefsScopeRegular:
202 return &(i->second->incognito_persistent_settings); 202 return &(i->second->settings);
203 case kExtensionPrefsScopeIncognitoSessionOnly: 203 case kExtensionPrefsScopeIncognitoPersistent:
204 return &(i->second->incognito_session_only_settings); 204 return &(i->second->incognito_persistent_settings);
205 } 205 case kExtensionPrefsScopeIncognitoSessionOnly:
206 return &(i->second->incognito_session_only_settings);
206 } 207 }
208
209 NOTREACHED();
207 return NULL; 210 return NULL;
208 } 211 }
209 212
210 void ExtensionContentSettingsStore::ClearContentSettingsForExtension( 213 void ExtensionContentSettingsStore::ClearContentSettingsForExtension(
211 const std::string& ext_id, 214 const std::string& ext_id,
212 ExtensionPrefsScope scope) { 215 ExtensionPrefsScope scope) {
213 bool notify = false; 216 bool notify = false;
214 { 217 {
215 base::AutoLock lock(lock_); 218 base::AutoLock lock(lock_);
216 OriginIdentifierValueMap* map = GetValueMap(ext_id, scope); 219 OriginIdentifierValueMap* map = GetValueMap(ext_id, scope);
220 if (!map)
221 return;
217 notify = !map->empty(); 222 notify = !map->empty();
218 map->clear(); 223 map->clear();
219 } 224 }
220 if (notify) { 225 if (notify) {
221 NotifyOfContentSettingChanged(ext_id, scope != kExtensionPrefsScopeRegular); 226 NotifyOfContentSettingChanged(ext_id, scope != kExtensionPrefsScopeRegular);
222 } 227 }
223 } 228 }
224 229
225 base::ListValue* ExtensionContentSettingsStore::GetSettingsForExtension( 230 base::ListValue* ExtensionContentSettingsStore::GetSettingsForExtension(
226 const std::string& extension_id, 231 const std::string& extension_id,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 350
346 ExtensionContentSettingsStore::ExtensionEntryMap::const_iterator 351 ExtensionContentSettingsStore::ExtensionEntryMap::const_iterator
347 ExtensionContentSettingsStore::FindEntry(const std::string& ext_id) const { 352 ExtensionContentSettingsStore::FindEntry(const std::string& ext_id) const {
348 ExtensionEntryMap::const_iterator i; 353 ExtensionEntryMap::const_iterator i;
349 for (i = entries_.begin(); i != entries_.end(); ++i) { 354 for (i = entries_.begin(); i != entries_.end(); ++i) {
350 if (i->second->id == ext_id) 355 if (i->second->id == ext_id)
351 return i; 356 return i;
352 } 357 }
353 return entries_.end(); 358 return entries_.end();
354 } 359 }
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