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 ExtensionEntry* entry; |
126 if (i != entries_.end()) { | 127 if (i != entries_.end()) { |
127 delete i->second; | 128 entry = i->second; |
128 entries_.erase(i); | 129 } else { |
| 130 entry = new ExtensionEntry; |
| 131 entries_.insert(std::make_pair(install_time, entry)); |
129 } | 132 } |
130 | 133 |
131 ExtensionEntry* entry = new ExtensionEntry; | |
132 entry->id = ext_id; | 134 entry->id = ext_id; |
133 entry->enabled = is_enabled; | 135 entry->enabled = is_enabled; |
134 entries_.insert(std::make_pair(install_time, entry)); | |
135 } | 136 } |
136 | 137 |
137 void ContentSettingsStore::UnregisterExtension( | 138 void ContentSettingsStore::UnregisterExtension( |
138 const std::string& ext_id) { | 139 const std::string& ext_id) { |
139 bool notify = false; | 140 bool notify = false; |
140 bool notify_incognito = false; | 141 bool notify_incognito = false; |
141 { | 142 { |
142 base::AutoLock lock(lock_); | 143 base::AutoLock lock(lock_); |
143 ExtensionEntryMap::iterator i = FindEntry(ext_id); | 144 ExtensionEntryMap::iterator i = FindEntry(ext_id); |
144 if (i == entries_.end()) | 145 if (i == entries_.end()) |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 ContentSettingsStore::FindEntry(const std::string& ext_id) const { | 368 ContentSettingsStore::FindEntry(const std::string& ext_id) const { |
368 ExtensionEntryMap::const_iterator i; | 369 ExtensionEntryMap::const_iterator i; |
369 for (i = entries_.begin(); i != entries_.end(); ++i) { | 370 for (i = entries_.begin(); i != entries_.end(); ++i) { |
370 if (i->second->id == ext_id) | 371 if (i->second->id == ext_id) |
371 return i; | 372 return i; |
372 } | 373 } |
373 return entries_.end(); | 374 return entries_.end(); |
374 } | 375 } |
375 | 376 |
376 } // namespace extensions | 377 } // namespace extensions |
OLD | NEW |