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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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[] = { |
652 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 652 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
653 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 653 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
654 chrome::NOTIFICATION_EXTENSION_LOADED, | 654 chrome::NOTIFICATION_EXTENSION_LOADED, |
655 chrome::NOTIFICATION_EXTENSION_UNLOADED | 655 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED |
656 }; | 656 }; |
657 | 657 |
658 CHECK(registrar_.IsEmpty()); | 658 CHECK(registrar_.IsEmpty()); |
659 for (size_t i = 0; i < arraysize(types); i++) { | 659 for (size_t i = 0; i < arraysize(types); i++) { |
660 registrar_.Add(this, | 660 registrar_.Add(this, |
661 types[i], | 661 types[i], |
662 content::Source<Profile>(profile_)); | 662 content::Source<Profile>(profile_)); |
663 } | 663 } |
664 } | 664 } |
665 | 665 |
(...skipping 16 matching lines...) Expand all Loading... |
682 content::Details<const InstalledExtensionInfo>(details)->extension; | 682 content::Details<const InstalledExtensionInfo>(details)->extension; |
683 break; | 683 break; |
684 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 684 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
685 event_name = management::OnUninstalled::kEventName; | 685 event_name = management::OnUninstalled::kEventName; |
686 extension = content::Details<const Extension>(details).ptr(); | 686 extension = content::Details<const Extension>(details).ptr(); |
687 break; | 687 break; |
688 case chrome::NOTIFICATION_EXTENSION_LOADED: | 688 case chrome::NOTIFICATION_EXTENSION_LOADED: |
689 event_name = management::OnEnabled::kEventName; | 689 event_name = management::OnEnabled::kEventName; |
690 extension = content::Details<const Extension>(details).ptr(); | 690 extension = content::Details<const Extension>(details).ptr(); |
691 break; | 691 break; |
692 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 692 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
693 event_name = management::OnDisabled::kEventName; | 693 event_name = management::OnDisabled::kEventName; |
694 extension = | 694 extension = |
695 content::Details<const UnloadedExtensionInfo>(details)->extension; | 695 content::Details<const UnloadedExtensionInfo>(details)->extension; |
696 break; | 696 break; |
697 default: | 697 default: |
698 NOTREACHED(); | 698 NOTREACHED(); |
699 return; | 699 return; |
700 } | 700 } |
701 DCHECK(event_name); | 701 DCHECK(event_name); |
702 DCHECK(extension); | 702 DCHECK(extension); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 } | 745 } |
746 | 746 |
747 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 747 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
748 management_event_router_.reset( | 748 management_event_router_.reset( |
749 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); | 749 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); |
750 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver( | 750 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver( |
751 this); | 751 this); |
752 } | 752 } |
753 | 753 |
754 } // namespace extensions | 754 } // namespace extensions |
OLD | NEW |