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