OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/automation/automation_extension_tracker.h" | 5 #include "chrome/browser/automation/automation_extension_tracker.h" |
6 #include "chrome/browser/extensions/extensions_service.h" | 6 #include "chrome/browser/extensions/extensions_service.h" |
7 #include "chrome/browser/profile.h" | 7 #include "chrome/browser/profile.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
10 | 10 |
11 AutomationExtensionTracker::AutomationExtensionTracker( | 11 AutomationExtensionTracker::AutomationExtensionTracker( |
12 IPC::Message::Sender* automation) | 12 IPC::Message::Sender* automation) |
13 : AutomationResourceTracker<Extension*>(automation) { | 13 : AutomationResourceTracker<Extension*>(automation) { |
14 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 14 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
15 NotificationService::AllSources()); | 15 NotificationService::AllSources()); |
16 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, | 16 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, |
17 NotificationService::AllSources()); | 17 NotificationService::AllSources()); |
18 } | 18 } |
19 | 19 |
20 AutomationExtensionTracker::~AutomationExtensionTracker() { | 20 AutomationExtensionTracker::~AutomationExtensionTracker() { |
21 } | 21 } |
22 | 22 |
| 23 void AutomationExtensionTracker::AddObserver(Extension* resource) {} |
| 24 |
| 25 void AutomationExtensionTracker::RemoveObserver(Extension* resource) {} |
| 26 |
23 void AutomationExtensionTracker::Observe(NotificationType type, | 27 void AutomationExtensionTracker::Observe(NotificationType type, |
24 const NotificationSource& source, | 28 const NotificationSource& source, |
25 const NotificationDetails& details) { | 29 const NotificationDetails& details) { |
26 if (type != NotificationType::EXTENSION_UNLOADED && | 30 if (type != NotificationType::EXTENSION_UNLOADED && |
27 type != NotificationType::EXTENSION_UNLOADED_DISABLED) | 31 type != NotificationType::EXTENSION_UNLOADED_DISABLED) |
28 return; | 32 return; |
29 | 33 |
30 Extension* extension = Details<Extension>(details).ptr(); | 34 Extension* extension = Details<Extension>(details).ptr(); |
31 Profile* profile = Source<Profile>(source).ptr(); | 35 Profile* profile = Source<Profile>(source).ptr(); |
32 if (profile) { | 36 if (profile) { |
33 ExtensionsService* service = profile->GetExtensionsService(); | 37 ExtensionsService* service = profile->GetExtensionsService(); |
34 if (service) { | 38 if (service) { |
35 // Remove this extension only if it is uninstalled, not just disabled. | 39 // Remove this extension only if it is uninstalled, not just disabled. |
36 // If it is being uninstalled, the extension will not be in the regular | 40 // If it is being uninstalled, the extension will not be in the regular |
37 // or disabled list. | 41 // or disabled list. |
38 if (!service->GetExtensionById(extension->id(), true)) | 42 if (!service->GetExtensionById(extension->id(), true)) |
39 CloseResource(extension); | 43 CloseResource(extension); |
40 } | 44 } |
41 } | 45 } |
42 } | 46 } |
OLD | NEW |