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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 std::set<std::string> registered_events = | 764 std::set<std::string> registered_events = |
765 GetRegisteredEvents(extension->id()); | 765 GetRegisteredEvents(extension->id()); |
766 listeners_.LoadUnfilteredLazyListeners(extension->id(), | 766 listeners_.LoadUnfilteredLazyListeners(extension->id(), |
767 registered_events); | 767 registered_events); |
768 const DictionaryValue* filtered_events = | 768 const DictionaryValue* filtered_events = |
769 GetFilteredEvents(extension->id()); | 769 GetFilteredEvents(extension->id()); |
770 if (filtered_events) | 770 if (filtered_events) |
771 listeners_.LoadFilteredLazyListeners(extension->id(), *filtered_events); | 771 listeners_.LoadFilteredLazyListeners(extension->id(), *filtered_events); |
772 | 772 |
773 if (dispatch_chrome_updated_event_) { | 773 if (dispatch_chrome_updated_event_) { |
774 MessageLoop::current()->PostTask(FROM_HERE, | 774 base::MessageLoop::current()->PostTask(FROM_HERE, |
775 base::Bind(&DispatchOnInstalledEvent, profile_, extension->id(), | 775 base::Bind(&DispatchOnInstalledEvent, profile_, extension->id(), |
776 Version(), true)); | 776 Version(), true)); |
777 } | 777 } |
778 break; | 778 break; |
779 } | 779 } |
780 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 780 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
781 // Remove all registered lazy listeners from our cache. | 781 // Remove all registered lazy listeners from our cache. |
782 UnloadedExtensionInfo* unloaded = | 782 UnloadedExtensionInfo* unloaded = |
783 content::Details<UnloadedExtensionInfo>(details).ptr(); | 783 content::Details<UnloadedExtensionInfo>(details).ptr(); |
784 listeners_.RemoveLazyListenersForExtension(unloaded->extension->id()); | 784 listeners_.RemoveLazyListenersForExtension(unloaded->extension->id()); |
785 break; | 785 break; |
786 } | 786 } |
787 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 787 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
788 // Dispatch the onInstalled event. | 788 // Dispatch the onInstalled event. |
789 const Extension* extension = | 789 const Extension* extension = |
790 content::Details<const InstalledExtensionInfo>(details)->extension; | 790 content::Details<const InstalledExtensionInfo>(details)->extension; |
791 | 791 |
792 // Get the previous version, if this is an upgrade. | 792 // Get the previous version, if this is an upgrade. |
793 ExtensionService* service = | 793 ExtensionService* service = |
794 ExtensionSystem::Get(profile_)->extension_service(); | 794 ExtensionSystem::Get(profile_)->extension_service(); |
795 const Extension* old = service->GetExtensionById(extension->id(), true); | 795 const Extension* old = service->GetExtensionById(extension->id(), true); |
796 Version old_version; | 796 Version old_version; |
797 if (old) | 797 if (old) |
798 old_version = *old->version(); | 798 old_version = *old->version(); |
799 | 799 |
800 MessageLoop::current()->PostTask(FROM_HERE, | 800 base::MessageLoop::current()->PostTask(FROM_HERE, |
801 base::Bind(&DispatchOnInstalledEvent, profile_, extension->id(), | 801 base::Bind(&DispatchOnInstalledEvent, profile_, extension->id(), |
802 old_version, false)); | 802 old_version, false)); |
803 break; | 803 break; |
804 } | 804 } |
805 default: | 805 default: |
806 NOTREACHED(); | 806 NOTREACHED(); |
807 return; | 807 return; |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 copy->will_dispatch_callback = will_dispatch_callback; | 854 copy->will_dispatch_callback = will_dispatch_callback; |
855 return copy; | 855 return copy; |
856 } | 856 } |
857 | 857 |
858 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 858 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
859 const std::string& extension_id) | 859 const std::string& extension_id) |
860 : event_name(event_name), | 860 : event_name(event_name), |
861 extension_id(extension_id) {} | 861 extension_id(extension_id) {} |
862 | 862 |
863 } // namespace extensions | 863 } // namespace extensions |
OLD | NEW |