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