OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |