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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 return base::WrapUnique(new EventListener(event_name, extension_id, GURL(), | 30 return base::WrapUnique(new EventListener(event_name, extension_id, GURL(), |
31 process, std::move(filter))); | 31 process, std::move(filter))); |
32 } | 32 } |
33 | 33 |
34 // static | 34 // static |
35 std::unique_ptr<EventListener> EventListener::ForURL( | 35 std::unique_ptr<EventListener> EventListener::ForURL( |
36 const std::string& event_name, | 36 const std::string& event_name, |
37 const GURL& listener_url, | 37 const GURL& listener_url, |
38 content::RenderProcessHost* process, | 38 content::RenderProcessHost* process, |
39 std::unique_ptr<base::DictionaryValue> filter) { | 39 std::unique_ptr<base::DictionaryValue> filter) { |
40 return base::WrapUnique(new EventListener(event_name, "", listener_url, | 40 return base::WrapUnique(new EventListener( |
Dan Beam
2016/12/22 01:51:19
nit: MakeUnique<EventListener>(...)
stevenjb
2016/12/22 01:55:29
WrapUnique is used here because the constructor is
Dan Beam
2016/12/22 01:57:18
ah, fair
| |
41 process, std::move(filter))); | 41 event_name, "", listener_url.GetOrigin(), process, std::move(filter))); |
Devlin
2016/12/22 16:01:09
let's add a comment saying why we do this.
stevenjb
2016/12/22 19:06:05
Done.
| |
42 } | 42 } |
43 | 43 |
44 EventListener::~EventListener() {} | 44 EventListener::~EventListener() {} |
45 | 45 |
46 bool EventListener::Equals(const EventListener* other) const { | 46 bool EventListener::Equals(const EventListener* other) const { |
47 // We don't check matcher_id equality because we want a listener with a | 47 // We don't check matcher_id equality because we want a listener with a |
48 // filter that hasn't been added to EventFilter to match one that is | 48 // filter that hasn't been added to EventFilter to match one that is |
49 // equivalent but has. | 49 // equivalent but has. |
50 return event_name_ == other->event_name_ && | 50 return event_name_ == other->event_name_ && |
51 extension_id_ == other->extension_id_ && | 51 extension_id_ == other->extension_id_ && |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 return; | 278 return; |
279 event_filter_.RemoveEventMatcher(listener->matcher_id()); | 279 event_filter_.RemoveEventMatcher(listener->matcher_id()); |
280 CHECK_EQ(1u, listeners_by_matcher_id_.erase(listener->matcher_id())); | 280 CHECK_EQ(1u, listeners_by_matcher_id_.erase(listener->matcher_id())); |
281 } | 281 } |
282 | 282 |
283 bool EventListenerMap::IsFilteredEvent(const Event& event) const { | 283 bool EventListenerMap::IsFilteredEvent(const Event& event) const { |
284 return filtered_events_.count(event.event_name) > 0u; | 284 return filtered_events_.count(event.event_name) > 0u; |
285 } | 285 } |
286 | 286 |
287 } // namespace extensions | 287 } // namespace extensions |
OLD | NEW |