| 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 EXTENSION_FUNCTION_VALIDATE(params.get()); | 641 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 642 | 642 |
| 643 bool show_confirm_dialog = false; | 643 bool show_confirm_dialog = false; |
| 644 if (params->options.get() && params->options->show_confirm_dialog.get()) | 644 if (params->options.get() && params->options->show_confirm_dialog.get()) |
| 645 show_confirm_dialog = *params->options->show_confirm_dialog; | 645 show_confirm_dialog = *params->options->show_confirm_dialog; |
| 646 return Uninstall(extension_->id(), show_confirm_dialog); | 646 return Uninstall(extension_->id(), show_confirm_dialog); |
| 647 } | 647 } |
| 648 | 648 |
| 649 ManagementEventRouter::ManagementEventRouter(Profile* profile) | 649 ManagementEventRouter::ManagementEventRouter(Profile* profile) |
| 650 : profile_(profile) { | 650 : profile_(profile) { |
| 651 int types[] = { | 651 int types[] = {chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 652 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 652 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 653 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 653 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 654 chrome::NOTIFICATION_EXTENSION_LOADED, | 654 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED}; |
| 655 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED | |
| 656 }; | |
| 657 | 655 |
| 658 CHECK(registrar_.IsEmpty()); | 656 CHECK(registrar_.IsEmpty()); |
| 659 for (size_t i = 0; i < arraysize(types); i++) { | 657 for (size_t i = 0; i < arraysize(types); i++) { |
| 660 registrar_.Add(this, | 658 registrar_.Add(this, |
| 661 types[i], | 659 types[i], |
| 662 content::Source<Profile>(profile_)); | 660 content::Source<Profile>(profile_)); |
| 663 } | 661 } |
| 664 } | 662 } |
| 665 | 663 |
| 666 ManagementEventRouter::~ManagementEventRouter() {} | 664 ManagementEventRouter::~ManagementEventRouter() {} |
| (...skipping 11 matching lines...) Expand all Loading... |
| 678 switch (type) { | 676 switch (type) { |
| 679 case chrome::NOTIFICATION_EXTENSION_INSTALLED: | 677 case chrome::NOTIFICATION_EXTENSION_INSTALLED: |
| 680 event_name = management::OnInstalled::kEventName; | 678 event_name = management::OnInstalled::kEventName; |
| 681 extension = | 679 extension = |
| 682 content::Details<const InstalledExtensionInfo>(details)->extension; | 680 content::Details<const InstalledExtensionInfo>(details)->extension; |
| 683 break; | 681 break; |
| 684 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 682 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
| 685 event_name = management::OnUninstalled::kEventName; | 683 event_name = management::OnUninstalled::kEventName; |
| 686 extension = content::Details<const Extension>(details).ptr(); | 684 extension = content::Details<const Extension>(details).ptr(); |
| 687 break; | 685 break; |
| 688 case chrome::NOTIFICATION_EXTENSION_LOADED: | 686 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
| 689 event_name = management::OnEnabled::kEventName; | 687 event_name = management::OnEnabled::kEventName; |
| 690 extension = content::Details<const Extension>(details).ptr(); | 688 extension = content::Details<const Extension>(details).ptr(); |
| 691 break; | 689 break; |
| 692 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | 690 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
| 693 event_name = management::OnDisabled::kEventName; | 691 event_name = management::OnDisabled::kEventName; |
| 694 extension = | 692 extension = |
| 695 content::Details<const UnloadedExtensionInfo>(details)->extension; | 693 content::Details<const UnloadedExtensionInfo>(details)->extension; |
| 696 break; | 694 break; |
| 697 default: | 695 default: |
| 698 NOTREACHED(); | 696 NOTREACHED(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 return g_factory.Pointer(); | 740 return g_factory.Pointer(); |
| 743 } | 741 } |
| 744 | 742 |
| 745 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 743 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 746 management_event_router_.reset( | 744 management_event_router_.reset( |
| 747 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); | 745 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); |
| 748 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 746 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 749 } | 747 } |
| 750 | 748 |
| 751 } // namespace extensions | 749 } // namespace extensions |
| OLD | NEW |