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/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/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<const Extension*>(automation) { | 13 : AutomationResourceTracker<const 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, | |
17 NotificationService::AllSources()); | |
18 } | 16 } |
19 | 17 |
20 AutomationExtensionTracker::~AutomationExtensionTracker() { | 18 AutomationExtensionTracker::~AutomationExtensionTracker() { |
21 } | 19 } |
22 | 20 |
23 void AutomationExtensionTracker::AddObserver(const Extension* resource) {} | 21 void AutomationExtensionTracker::AddObserver(const Extension* resource) {} |
24 | 22 |
25 void AutomationExtensionTracker::RemoveObserver(const Extension* resource) {} | 23 void AutomationExtensionTracker::RemoveObserver(const Extension* resource) {} |
26 | 24 |
27 void AutomationExtensionTracker::Observe(NotificationType type, | 25 void AutomationExtensionTracker::Observe(NotificationType type, |
28 const NotificationSource& source, | 26 const NotificationSource& source, |
29 const NotificationDetails& details) { | 27 const NotificationDetails& details) { |
30 if (type != NotificationType::EXTENSION_UNLOADED && | 28 if (type != NotificationType::EXTENSION_UNLOADED) |
Erik does not do reviews
2010/12/23 17:05:17
should this be NOTREACHED()?
asargent_no_longer_on_chrome
2010/12/23 18:53:04
Done.
| |
31 type != NotificationType::EXTENSION_UNLOADED_DISABLED) | |
32 return; | 29 return; |
33 | 30 |
34 const Extension* extension = Details<const Extension>(details).ptr(); | 31 const Extension* extension = |
32 Details<UnloadedExtensionInfo>(details)->extension; | |
Erik does not do reviews
2010/12/23 17:05:17
extension can be NULL right? so it looks like a c
asargent_no_longer_on_chrome
2010/12/23 18:53:04
It turns out it can't. See my response to comments
| |
35 Profile* profile = Source<Profile>(source).ptr(); | 33 Profile* profile = Source<Profile>(source).ptr(); |
36 if (profile) { | 34 if (profile) { |
37 ExtensionService* service = profile->GetExtensionService(); | 35 ExtensionService* service = profile->GetExtensionService(); |
38 if (service) { | 36 if (service) { |
39 // Remove this extension only if it is uninstalled, not just disabled. | 37 // Remove this extension only if it is uninstalled, not just disabled. |
40 // If it is being uninstalled, the extension will not be in the regular | 38 // If it is being uninstalled, the extension will not be in the regular |
41 // or disabled list. | 39 // or disabled list. |
42 if (!service->GetExtensionById(extension->id(), true)) | 40 if (!service->GetExtensionById(extension->id(), true)) |
Erik does not do reviews
2010/12/23 17:05:17
extension can be NULL right? so it looks like a c
asargent_no_longer_on_chrome
2010/12/23 18:53:04
It turns out it can't.
| |
43 CloseResource(extension); | 41 CloseResource(extension); |
44 } | 42 } |
45 } | 43 } |
46 } | 44 } |
OLD | NEW |