| 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/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 InstallTracker::InstallTracker(Profile* profile, | 15 InstallTracker::InstallTracker(Profile* profile, |
| 16 extensions::ExtensionPrefs* prefs) { | 16 extensions::ExtensionPrefs* prefs) { |
| 17 ExtensionSorting* sorting = prefs->extension_sorting(); | 17 AppListExtensionSorting* ordering = prefs->app_list_extension_sorting(); |
| 18 | 18 |
| 19 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 19 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 20 content::Source<Profile>(profile)); | 20 content::Source<Profile>(profile)); |
| 21 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 21 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 22 content::Source<Profile>(profile)); | 22 content::Source<Profile>(profile)); |
| 23 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 23 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 24 content::Source<Profile>(profile)); | 24 content::Source<Profile>(profile)); |
| 25 registrar_.Add(this, chrome::NOTIFICATION_APP_LIST_REORDERED, |
| 26 content::Source<AppListExtensionSorting>(ordering)); |
| 25 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 27 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 26 content::Source<Profile>(profile)); | 28 content::Source<Profile>(profile)); |
| 27 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | |
| 28 content::Source<ExtensionSorting>(sorting)); | |
| 29 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, | 29 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, |
| 30 content::Source<Profile>(profile)); | 30 content::Source<Profile>(profile)); |
| 31 | 31 |
| 32 pref_change_registrar_.Init(prefs->pref_service()); | 32 pref_change_registrar_.Init(prefs->pref_service()); |
| 33 pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, | 33 pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, |
| 34 base::Bind(&InstallTracker::OnAppsReordered, | 34 base::Bind(&InstallTracker::OnAppListReordered, |
| 35 base::Unretained(this))); | 35 base::Unretained(this))); |
| 36 } | 36 } |
| 37 | 37 |
| 38 InstallTracker::~InstallTracker() { | 38 InstallTracker::~InstallTracker() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void InstallTracker::AddObserver(InstallObserver* observer) { | 41 void InstallTracker::AddObserver(InstallObserver* observer) { |
| 42 observers_.AddObserver(observer); | 42 observers_.AddObserver(observer); |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 break; | 104 break; |
| 105 } | 105 } |
| 106 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { | 106 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
| 107 const Extension* extension = | 107 const Extension* extension = |
| 108 content::Details<const Extension>(details).ptr(); | 108 content::Details<const Extension>(details).ptr(); |
| 109 | 109 |
| 110 FOR_EACH_OBSERVER(InstallObserver, observers_, | 110 FOR_EACH_OBSERVER(InstallObserver, observers_, |
| 111 OnExtensionUninstalled(extension)); | 111 OnExtensionUninstalled(extension)); |
| 112 break; | 112 break; |
| 113 } | 113 } |
| 114 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { | 114 case chrome::NOTIFICATION_APP_LIST_REORDERED: { |
| 115 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); | 115 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppListReordered()); |
| 116 break; | 116 break; |
| 117 } | 117 } |
| 118 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { | 118 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { |
| 119 const std::string& extension_id( | 119 const std::string& extension_id( |
| 120 *content::Details<const std::string>(details).ptr()); | 120 *content::Details<const std::string>(details).ptr()); |
| 121 FOR_EACH_OBSERVER(InstallObserver, observers_, | 121 FOR_EACH_OBSERVER(InstallObserver, observers_, |
| 122 OnAppInstalledToAppList(extension_id)); | 122 OnAppInstalledToAppList(extension_id)); |
| 123 break; | 123 break; |
| 124 } | 124 } |
| 125 default: | 125 default: |
| 126 NOTREACHED(); | 126 NOTREACHED(); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 void InstallTracker::OnAppsReordered() { | 130 void InstallTracker::OnAppListReordered() { |
| 131 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); | 131 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppListReordered()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace extensions | 134 } // namespace extensions |
| OLD | NEW |