OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/event_listener_map.h" | 5 #include "extensions/browser/event_listener_map.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
9 #include "extensions/browser/event_router.h" | 9 #include "extensions/browser/event_router.h" |
10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 for (ListenerList::iterator it2 = it->second.begin(); | 169 for (ListenerList::iterator it2 = it->second.begin(); |
170 it2 != it->second.end(); it2++) { | 170 it2 != it->second.end(); it2++) { |
171 if ((*it2)->process() == process && | 171 if ((*it2)->process() == process && |
172 (*it2)->extension_id() == extension_id) | 172 (*it2)->extension_id() == extension_id) |
173 return true; | 173 return true; |
174 } | 174 } |
175 } | 175 } |
176 return false; | 176 return false; |
177 } | 177 } |
178 | 178 |
179 void EventListenerMap::RemoveLazyListenersForExtension( | 179 void EventListenerMap::RemoveListenersForExtension( |
180 const std::string& extension_id) { | 180 const std::string& extension_id) { |
181 for (ListenerMap::iterator it = listeners_.begin(); it != listeners_.end(); | 181 for (ListenerMap::iterator it = listeners_.begin(); it != listeners_.end(); |
182 it++) { | 182 it++) { |
183 for (ListenerList::iterator it2 = it->second.begin(); | 183 for (ListenerList::iterator it2 = it->second.begin(); |
184 it2 != it->second.end();) { | 184 it2 != it->second.end();) { |
185 if ((*it2)->IsLazy() && (*it2)->extension_id() == extension_id) { | 185 if ((*it2)->extension_id() == extension_id) { |
186 CleanupListener(it2->get()); | 186 linked_ptr<EventListener> listener(*it2); |
| 187 CleanupListener(listener.get()); |
187 it2 = it->second.erase(it2); | 188 it2 = it->second.erase(it2); |
| 189 delegate_->OnListenerRemoved(listener.get()); |
188 } else { | 190 } else { |
189 it2++; | 191 it2++; |
190 } | 192 } |
191 } | 193 } |
192 } | 194 } |
193 } | 195 } |
194 | 196 |
195 void EventListenerMap::LoadUnfilteredLazyListeners( | 197 void EventListenerMap::LoadUnfilteredLazyListeners( |
196 const std::string& extension_id, | 198 const std::string& extension_id, |
197 const std::set<std::string>& event_names) { | 199 const std::set<std::string>& event_names) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 return; | 272 return; |
271 event_filter_.RemoveEventMatcher(listener->matcher_id()); | 273 event_filter_.RemoveEventMatcher(listener->matcher_id()); |
272 CHECK_EQ(1u, listeners_by_matcher_id_.erase(listener->matcher_id())); | 274 CHECK_EQ(1u, listeners_by_matcher_id_.erase(listener->matcher_id())); |
273 } | 275 } |
274 | 276 |
275 bool EventListenerMap::IsFilteredEvent(const Event& event) const { | 277 bool EventListenerMap::IsFilteredEvent(const Event& event) const { |
276 return filtered_events_.count(event.event_name) > 0u; | 278 return filtered_events_.count(event.event_name) > 0u; |
277 } | 279 } |
278 | 280 |
279 } // namespace extensions | 281 } // namespace extensions |
OLD | NEW |