Chromium Code Reviews| 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/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 NotifyOfContentSettingChanged(ext_id, | 116 NotifyOfContentSettingChanged(ext_id, |
| 117 scope != kExtensionPrefsScopeRegular); | 117 scope != kExtensionPrefsScopeRegular); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ContentSettingsStore::RegisterExtension( | 120 void ContentSettingsStore::RegisterExtension( |
| 121 const std::string& ext_id, | 121 const std::string& ext_id, |
| 122 const base::Time& install_time, | 122 const base::Time& install_time, |
| 123 bool is_enabled) { | 123 bool is_enabled) { |
| 124 base::AutoLock lock(lock_); | 124 base::AutoLock lock(lock_); |
| 125 ExtensionEntryMap::iterator i = FindEntry(ext_id); | 125 ExtensionEntryMap::iterator i = FindEntry(ext_id); |
| 126 if (i != entries_.end()) { | 126 if (i != entries_.end()) |
| 127 delete i->second; | 127 return; |
| 128 entries_.erase(i); | |
| 129 } | |
| 130 | 128 |
| 131 ExtensionEntry* entry = new ExtensionEntry; | 129 ExtensionEntry* entry = new ExtensionEntry; |
| 132 entry->id = ext_id; | 130 entry->id = ext_id; |
| 133 entry->enabled = is_enabled; | 131 entry->enabled = is_enabled; |
|
Jeffrey Yasskin
2013/09/06 21:31:56
Similarly here, do we need to update |enabled| or
Bernhard Bauer
2013/09/10 13:28:18
DCHECKed.
| |
| 134 entries_.insert(std::make_pair(install_time, entry)); | 132 entries_.insert(std::make_pair(install_time, entry)); |
| 135 } | 133 } |
| 136 | 134 |
| 137 void ContentSettingsStore::UnregisterExtension( | 135 void ContentSettingsStore::UnregisterExtension( |
| 138 const std::string& ext_id) { | 136 const std::string& ext_id) { |
| 139 bool notify = false; | 137 bool notify = false; |
| 140 bool notify_incognito = false; | 138 bool notify_incognito = false; |
| 141 { | 139 { |
| 142 base::AutoLock lock(lock_); | 140 base::AutoLock lock(lock_); |
| 143 ExtensionEntryMap::iterator i = FindEntry(ext_id); | 141 ExtensionEntryMap::iterator i = FindEntry(ext_id); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 ContentSettingsStore::FindEntry(const std::string& ext_id) const { | 365 ContentSettingsStore::FindEntry(const std::string& ext_id) const { |
| 368 ExtensionEntryMap::const_iterator i; | 366 ExtensionEntryMap::const_iterator i; |
| 369 for (i = entries_.begin(); i != entries_.end(); ++i) { | 367 for (i = entries_.begin(); i != entries_.end(); ++i) { |
| 370 if (i->second->id == ext_id) | 368 if (i->second->id == ext_id) |
| 371 return i; | 369 return i; |
| 372 } | 370 } |
| 373 return entries_.end(); | 371 return entries_.end(); |
| 374 } | 372 } |
| 375 | 373 |
| 376 } // namespace extensions | 374 } // namespace extensions |
| OLD | NEW |