| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/install_tracker.h" | 5 #include "chrome/browser/extensions/install_tracker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/install_tracker_factory.h" | 9 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "extensions/browser/extension_prefs.h" | 13 #include "extensions/browser/extension_prefs.h" |
| 14 #include "extensions/browser/extension_registry.h" | |
| 15 #include "extensions/browser/pref_names.h" | 14 #include "extensions/browser/pref_names.h" |
| 16 | 15 |
| 17 namespace extensions { | 16 namespace extensions { |
| 18 | 17 |
| 19 InstallTracker::InstallTracker(Profile* profile, | 18 InstallTracker::InstallTracker(Profile* profile, |
| 20 extensions::ExtensionPrefs* prefs) | 19 extensions::ExtensionPrefs* prefs) { |
| 21 : extension_registry_observer_(this) { | |
| 22 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | |
| 23 | |
| 24 registrar_.Add(this, | |
| 25 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | |
| 26 content::Source<Profile>(profile)); | |
| 27 registrar_.Add(this, | 20 registrar_.Add(this, |
| 28 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 21 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 29 content::Source<Profile>(profile)); | 22 content::Source<Profile>(profile)); |
| 30 AppSorting* sorting = prefs->app_sorting(); | 23 AppSorting* sorting = prefs->app_sorting(); |
| 31 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 24 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |
| 32 content::Source<AppSorting>(sorting)); | 25 content::Source<AppSorting>(sorting)); |
| 33 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, | 26 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, |
| 34 content::Source<Profile>(profile)); | 27 content::Source<Profile>(profile)); |
| 35 | 28 |
| 36 pref_change_registrar_.Init(prefs->pref_service()); | 29 pref_change_registrar_.Init(prefs->pref_service()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 84 } |
| 92 | 85 |
| 93 void InstallTracker::Shutdown() { | 86 void InstallTracker::Shutdown() { |
| 94 FOR_EACH_OBSERVER(InstallObserver, observers_, OnShutdown()); | 87 FOR_EACH_OBSERVER(InstallObserver, observers_, OnShutdown()); |
| 95 } | 88 } |
| 96 | 89 |
| 97 void InstallTracker::Observe(int type, | 90 void InstallTracker::Observe(int type, |
| 98 const content::NotificationSource& source, | 91 const content::NotificationSource& source, |
| 99 const content::NotificationDetails& details) { | 92 const content::NotificationDetails& details) { |
| 100 switch (type) { | 93 switch (type) { |
| 101 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { | |
| 102 const Extension* extension = | |
| 103 content::Details<const Extension>(details).ptr(); | |
| 104 | |
| 105 FOR_EACH_OBSERVER(InstallObserver, observers_, | |
| 106 OnExtensionUninstalled(extension)); | |
| 107 break; | |
| 108 } | |
| 109 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { | 94 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { |
| 110 const Extension* extension = | 95 const Extension* extension = |
| 111 content::Details<const Extension>(details).ptr(); | 96 content::Details<const Extension>(details).ptr(); |
| 112 FOR_EACH_OBSERVER( | 97 FOR_EACH_OBSERVER( |
| 113 InstallObserver, observers_, OnDisabledExtensionUpdated(extension)); | 98 InstallObserver, observers_, OnDisabledExtensionUpdated(extension)); |
| 114 break; | 99 break; |
| 115 } | 100 } |
| 116 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { | 101 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { |
| 117 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); | 102 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); |
| 118 break; | 103 break; |
| 119 } | 104 } |
| 120 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { | 105 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { |
| 121 const std::string& extension_id( | 106 const std::string& extension_id( |
| 122 *content::Details<const std::string>(details).ptr()); | 107 *content::Details<const std::string>(details).ptr()); |
| 123 FOR_EACH_OBSERVER(InstallObserver, observers_, | 108 FOR_EACH_OBSERVER(InstallObserver, observers_, |
| 124 OnAppInstalledToAppList(extension_id)); | 109 OnAppInstalledToAppList(extension_id)); |
| 125 break; | 110 break; |
| 126 } | 111 } |
| 127 default: | 112 default: |
| 128 NOTREACHED(); | 113 NOTREACHED(); |
| 129 } | 114 } |
| 130 } | 115 } |
| 131 | 116 |
| 132 void InstallTracker::OnExtensionWillBeInstalled( | |
| 133 content::BrowserContext* browser_context, | |
| 134 const Extension* extension, | |
| 135 bool is_update, | |
| 136 bool from_ephemeral, | |
| 137 const std::string& old_name) { | |
| 138 FOR_EACH_OBSERVER( | |
| 139 InstallObserver, observers_, OnExtensionInstalled(extension)); | |
| 140 } | |
| 141 | |
| 142 void InstallTracker::OnAppsReordered() { | 117 void InstallTracker::OnAppsReordered() { |
| 143 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); | 118 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); |
| 144 } | 119 } |
| 145 | 120 |
| 146 } // namespace extensions | 121 } // namespace extensions |
| OLD | NEW |