Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: extensions/browser/event_listener_map.cc

Issue 898743002: When an extension is unloaded, unregister all event listeners, not just the lazy ones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2272
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « extensions/browser/event_listener_map.h ('k') | extensions/browser/event_listener_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698