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/extension_event_router.h" | 5 #include "chrome/browser/extensions/extension_event_router.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/chrome_view_type.h" | 26 #include "chrome/common/chrome_view_type.h" |
27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
29 #include "chrome/common/extensions/api/extension_api.h" | 29 #include "chrome/common/extensions/api/extension_api.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
32 | 32 |
33 using content::BrowserThread; | 33 using content::BrowserThread; |
| 34 using extensions::Extension; |
34 using extensions::ExtensionAPI; | 35 using extensions::ExtensionAPI; |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 const char kDispatchEvent[] = "Event.dispatchJSON"; | 39 const char kDispatchEvent[] = "Event.dispatchJSON"; |
39 | 40 |
40 void NotifyEventListenerRemovedOnIOThread( | 41 void NotifyEventListenerRemovedOnIOThread( |
41 void* profile, | 42 void* profile, |
42 const std::string& extension_id, | 43 const std::string& extension_id, |
43 const std::string& sub_event_name) { | 44 const std::string& sub_event_name) { |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 GetRegisteredEvents(extension->id()); | 481 GetRegisteredEvents(extension->id()); |
481 ListenerProcess lazy_listener(NULL, extension->id()); | 482 ListenerProcess lazy_listener(NULL, extension->id()); |
482 for (std::set<std::string>::iterator it = registered_events.begin(); | 483 for (std::set<std::string>::iterator it = registered_events.begin(); |
483 it != registered_events.end(); ++it) { | 484 it != registered_events.end(); ++it) { |
484 lazy_listeners_[*it].insert(lazy_listener); | 485 lazy_listeners_[*it].insert(lazy_listener); |
485 } | 486 } |
486 break; | 487 break; |
487 } | 488 } |
488 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 489 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
489 // Remove all registered lazy listeners from our cache. | 490 // Remove all registered lazy listeners from our cache. |
490 UnloadedExtensionInfo* unloaded = | 491 extensions::UnloadedExtensionInfo* unloaded = |
491 content::Details<UnloadedExtensionInfo>(details).ptr(); | 492 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
492 ListenerProcess lazy_listener(NULL, unloaded->extension->id()); | 493 ListenerProcess lazy_listener(NULL, unloaded->extension->id()); |
493 for (ListenerMap::iterator it = lazy_listeners_.begin(); | 494 for (ListenerMap::iterator it = lazy_listeners_.begin(); |
494 it != lazy_listeners_.end(); ++it) { | 495 it != lazy_listeners_.end(); ++it) { |
495 it->second.erase(lazy_listener); | 496 it->second.erase(lazy_listener); |
496 } | 497 } |
497 break; | 498 break; |
498 } | 499 } |
499 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 500 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
500 // Dispatch the onInstalled event. | 501 // Dispatch the onInstalled event. |
501 const Extension* extension = | 502 const Extension* extension = |
502 content::Details<const Extension>(details).ptr(); | 503 content::Details<const Extension>(details).ptr(); |
503 MessageLoop::current()->PostTask(FROM_HERE, | 504 MessageLoop::current()->PostTask(FROM_HERE, |
504 base::Bind(&extensions::RuntimeEventRouter::DispatchOnInstalledEvent, | 505 base::Bind(&extensions::RuntimeEventRouter::DispatchOnInstalledEvent, |
505 profile_, extension->id())); | 506 profile_, extension->id())); |
506 break; | 507 break; |
507 } | 508 } |
508 default: | 509 default: |
509 NOTREACHED(); | 510 NOTREACHED(); |
510 return; | 511 return; |
511 } | 512 } |
512 } | 513 } |
OLD | NEW |