OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_notification_types.h" | 8 #include "chrome/common/chrome_notification_types.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 10 #include "chrome/common/extensions/extension_constants.h" |
10 #include "content/common/notification_service.h" | 11 #include "content/common/notification_service.h" |
11 | 12 |
12 AutomationExtensionTracker::AutomationExtensionTracker( | 13 AutomationExtensionTracker::AutomationExtensionTracker( |
13 IPC::Message::Sender* automation) | 14 IPC::Message::Sender* automation) |
14 : AutomationResourceTracker<const Extension*>(automation) { | 15 : AutomationResourceTracker<const Extension*>(automation) { |
15 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 16 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
16 NotificationService::AllSources()); | 17 NotificationService::AllSources()); |
17 } | 18 } |
18 | 19 |
19 AutomationExtensionTracker::~AutomationExtensionTracker() { | 20 AutomationExtensionTracker::~AutomationExtensionTracker() { |
20 } | 21 } |
21 | 22 |
22 void AutomationExtensionTracker::AddObserver(const Extension* resource) {} | 23 void AutomationExtensionTracker::AddObserver(const Extension* resource) {} |
23 | 24 |
24 void AutomationExtensionTracker::RemoveObserver(const Extension* resource) {} | 25 void AutomationExtensionTracker::RemoveObserver(const Extension* resource) {} |
25 | 26 |
26 void AutomationExtensionTracker::Observe(int type, | 27 void AutomationExtensionTracker::Observe(int type, |
27 const NotificationSource& source, | 28 const NotificationSource& source, |
28 const NotificationDetails& details) { | 29 const NotificationDetails& details) { |
29 if (type != chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 30 if (type != chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
30 NOTREACHED(); | 31 NOTREACHED(); |
31 return; | 32 return; |
32 } | 33 } |
33 UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr(); | 34 UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr(); |
34 const Extension* extension = info->extension; | 35 const Extension* extension = info->extension; |
35 Profile* profile = Source<Profile>(source).ptr(); | 36 Profile* profile = Source<Profile>(source).ptr(); |
36 if (profile) { | 37 if (profile) { |
37 ExtensionService* service = profile->GetExtensionService(); | 38 ExtensionService* service = profile->GetExtensionService(); |
38 if (service && info->reason == UnloadedExtensionInfo::UNINSTALL) { | 39 if (service && info->reason == extension_misc::UNLOAD_REASON_UNINSTALL) { |
39 // Remove this extension only if it is uninstalled, not just disabled. | 40 // Remove this extension only if it is uninstalled, not just disabled. |
40 CloseResource(extension); | 41 CloseResource(extension); |
41 } | 42 } |
42 } | 43 } |
43 } | 44 } |
OLD | NEW |