| 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/event_router.h" | 5 #include "chrome/browser/extensions/event_router.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return !listeners.empty(); | 327 return !listeners.empty(); |
| 328 | 328 |
| 329 for (std::set<ListenerProcess>::const_iterator listener = listeners.begin(); | 329 for (std::set<ListenerProcess>::const_iterator listener = listeners.begin(); |
| 330 listener != listeners.end(); ++listener) { | 330 listener != listeners.end(); ++listener) { |
| 331 if (listener->extension_id == extension_id) | 331 if (listener->extension_id == extension_id) |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 return false; | 334 return false; |
| 335 } | 335 } |
| 336 | 336 |
| 337 void EventRouter::DispatchEventToRenderers(const std::string& event_name, | |
| 338 scoped_ptr<ListValue> event_args, | |
| 339 Profile* restrict_to_profile, | |
| 340 const GURL& event_url, | |
| 341 EventFilteringInfo info) { | |
| 342 linked_ptr<Event> event(new Event(event_name, event_args.Pass(), | |
| 343 scoped_ptr<ListValue>(), | |
| 344 restrict_to_profile, event_url, | |
| 345 USER_GESTURE_UNKNOWN, info)); | |
| 346 DispatchEventImpl("", event); | |
| 347 } | |
| 348 | |
| 349 void EventRouter::DispatchEventToRenderers(const std::string& event_name, | |
| 350 scoped_ptr<ListValue> event_args, | |
| 351 Profile* restrict_to_profile, | |
| 352 const GURL& event_url) { | |
| 353 DispatchEventToRenderers(event_name, event_args.Pass(), restrict_to_profile, | |
| 354 event_url, EventFilteringInfo()); | |
| 355 } | |
| 356 | |
| 357 void EventRouter::DispatchEventToRenderers(const std::string& event_name, | |
| 358 scoped_ptr<ListValue> event_args, | |
| 359 Profile* restrict_to_profile, | |
| 360 const GURL& event_url, | |
| 361 UserGestureState user_gesture) { | |
| 362 EventFilteringInfo info; | |
| 363 linked_ptr<Event> event(new Event(event_name, event_args.Pass(), | |
| 364 scoped_ptr<ListValue>(), | |
| 365 restrict_to_profile, event_url, | |
| 366 user_gesture, info)); | |
| 367 DispatchEventImpl("", event); | |
| 368 } | |
| 369 | |
| 370 void EventRouter::DispatchEventToExtension(const std::string& extension_id, | |
| 371 const std::string& event_name, | |
| 372 scoped_ptr<ListValue> event_args, | |
| 373 Profile* restrict_to_profile, | |
| 374 const GURL& event_url) { | |
| 375 DCHECK(!extension_id.empty()); | |
| 376 linked_ptr<Event> event(new Event(event_name, event_args.Pass(), | |
| 377 scoped_ptr<ListValue>(), | |
| 378 restrict_to_profile, event_url, | |
| 379 USER_GESTURE_UNKNOWN, | |
| 380 EventFilteringInfo())); | |
| 381 DispatchEventImpl(extension_id, event); | |
| 382 } | |
| 383 | |
| 384 void EventRouter::DispatchEventToExtension(const std::string& extension_id, | |
| 385 const std::string& event_name, | |
| 386 scoped_ptr<ListValue> event_args, | |
| 387 Profile* restrict_to_profile, | |
| 388 const GURL& event_url, | |
| 389 UserGestureState user_gesture) { | |
| 390 DCHECK(!extension_id.empty()); | |
| 391 linked_ptr<Event> event(new Event(event_name, event_args.Pass(), | |
| 392 scoped_ptr<ListValue>(), | |
| 393 restrict_to_profile, event_url, | |
| 394 user_gesture, | |
| 395 EventFilteringInfo())); | |
| 396 DispatchEventImpl(extension_id, event); | |
| 397 } | |
| 398 | |
| 399 void EventRouter::BroadcastEvent(scoped_ptr<Event> event) { | 337 void EventRouter::BroadcastEvent(scoped_ptr<Event> event) { |
| 400 DispatchEventImpl("", linked_ptr<Event>(event.release())); | 338 DispatchEventImpl("", linked_ptr<Event>(event.release())); |
| 401 } | 339 } |
| 402 | 340 |
| 403 void EventRouter::DispatchEventToExtension(const std::string& extension_id, | 341 void EventRouter::DispatchEventToExtension(const std::string& extension_id, |
| 404 scoped_ptr<Event> event) { | 342 scoped_ptr<Event> event) { |
| 405 DCHECK(!extension_id.empty()); | 343 DCHECK(!extension_id.empty()); |
| 406 DispatchEventImpl(extension_id, linked_ptr<Event>(event.release())); | 344 DispatchEventImpl(extension_id, linked_ptr<Event>(event.release())); |
| 407 } | 345 } |
| 408 | 346 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 copy->will_dispatch_callback = will_dispatch_callback; | 677 copy->will_dispatch_callback = will_dispatch_callback; |
| 740 return copy; | 678 return copy; |
| 741 } | 679 } |
| 742 | 680 |
| 743 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 681 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
| 744 const std::string& extension_id) | 682 const std::string& extension_id) |
| 745 : event_name(event_name), | 683 : event_name(event_name), |
| 746 extension_id(extension_id) {} | 684 extension_id(extension_id) {} |
| 747 | 685 |
| 748 } // namespace extensions | 686 } // namespace extensions |
| OLD | NEW |