| 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/api/management/management_api.h" | 5 #include "chrome/browser/extensions/api/management/management_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } else { | 732 } else { |
| 733 OnCloseShortcutPrompt(auto_confirm_for_test == PROCEED); | 733 OnCloseShortcutPrompt(auto_confirm_for_test == PROCEED); |
| 734 } | 734 } |
| 735 | 735 |
| 736 // Response is sent async in OnCloseShortcutPrompt(). | 736 // Response is sent async in OnCloseShortcutPrompt(). |
| 737 return true; | 737 return true; |
| 738 } | 738 } |
| 739 | 739 |
| 740 ManagementEventRouter::ManagementEventRouter(Profile* profile) | 740 ManagementEventRouter::ManagementEventRouter(Profile* profile) |
| 741 : profile_(profile) { | 741 : profile_(profile) { |
| 742 int types[] = {chrome::NOTIFICATION_EXTENSION_INSTALLED, | 742 int types[] = {chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, |
| 743 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 743 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 744 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 744 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 745 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED}; | 745 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED}; |
| 746 | 746 |
| 747 CHECK(registrar_.IsEmpty()); | 747 CHECK(registrar_.IsEmpty()); |
| 748 for (size_t i = 0; i < arraysize(types); i++) { | 748 for (size_t i = 0; i < arraysize(types); i++) { |
| 749 registrar_.Add(this, | 749 registrar_.Add(this, |
| 750 types[i], | 750 types[i], |
| 751 content::Source<Profile>(profile_)); | 751 content::Source<Profile>(profile_)); |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 ManagementEventRouter::~ManagementEventRouter() {} | 755 ManagementEventRouter::~ManagementEventRouter() {} |
| 756 | 756 |
| 757 void ManagementEventRouter::Observe( | 757 void ManagementEventRouter::Observe( |
| 758 int type, | 758 int type, |
| 759 const content::NotificationSource& source, | 759 const content::NotificationSource& source, |
| 760 const content::NotificationDetails& details) { | 760 const content::NotificationDetails& details) { |
| 761 const char* event_name = NULL; | 761 const char* event_name = NULL; |
| 762 const Extension* extension = NULL; | 762 const Extension* extension = NULL; |
| 763 Profile* profile = content::Source<Profile>(source).ptr(); | 763 Profile* profile = content::Source<Profile>(source).ptr(); |
| 764 CHECK(profile); | 764 CHECK(profile); |
| 765 CHECK(profile_->IsSameProfile(profile)); | 765 CHECK(profile_->IsSameProfile(profile)); |
| 766 | 766 |
| 767 switch (type) { | 767 switch (type) { |
| 768 case chrome::NOTIFICATION_EXTENSION_INSTALLED: | 768 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: |
| 769 event_name = management::OnInstalled::kEventName; | 769 event_name = management::OnInstalled::kEventName; |
| 770 extension = | 770 extension = |
| 771 content::Details<const InstalledExtensionInfo>(details)->extension; | 771 content::Details<const InstalledExtensionInfo>(details)->extension; |
| 772 break; | 772 break; |
| 773 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 773 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
| 774 event_name = management::OnUninstalled::kEventName; | 774 event_name = management::OnUninstalled::kEventName; |
| 775 extension = content::Details<const Extension>(details).ptr(); | 775 extension = content::Details<const Extension>(details).ptr(); |
| 776 break; | 776 break; |
| 777 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | 777 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
| 778 event_name = management::OnEnabled::kEventName; | 778 event_name = management::OnEnabled::kEventName; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 return g_factory.Pointer(); | 831 return g_factory.Pointer(); |
| 832 } | 832 } |
| 833 | 833 |
| 834 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 834 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 835 management_event_router_.reset( | 835 management_event_router_.reset( |
| 836 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); | 836 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); |
| 837 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 837 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 838 } | 838 } |
| 839 | 839 |
| 840 } // namespace extensions | 840 } // namespace extensions |
| OLD | NEW |