Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: chrome/browser/extensions/install_tracker.cc

Issue 17038002: Separate the NTP app ordering from the app list app ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/extension_prefs.h" 8 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.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 AppListExtensionOrdering* ordering = prefs->app_list_extension_ordering();
18 18
19 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 19 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
20 content::Source<Profile>(profile)); 20 content::Source<Profile>(profile));
21 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 21 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
22 content::Source<Profile>(profile)); 22 content::Source<Profile>(profile));
23 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, 23 registrar_.Add(this, chrome::NOTIFICATION_APP_LIST_REORDERED,
24 content::Source<ExtensionSorting>(sorting)); 24 content::Source<AppListExtensionOrdering>(ordering));
25 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, 25 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST,
26 content::Source<Profile>(profile)); 26 content::Source<Profile>(profile));
27 27
28 pref_change_registrar_.Init(prefs->pref_service()); 28 pref_change_registrar_.Init(prefs->pref_service());
29 pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, 29 pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref,
30 base::Bind(&InstallTracker::OnAppsReordered, 30 base::Bind(&InstallTracker::OnAppListReordered,
31 base::Unretained(this))); 31 base::Unretained(this)));
32 } 32 }
33 33
34 InstallTracker::~InstallTracker() { 34 InstallTracker::~InstallTracker() {
35 } 35 }
36 36
37 void InstallTracker::AddObserver(InstallObserver* observer) { 37 void InstallTracker::AddObserver(InstallObserver* observer) {
38 observers_.AddObserver(observer); 38 observers_.AddObserver(observer);
39 } 39 }
40 40
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const Extension* extension = unload_info->extension; 89 const Extension* extension = unload_info->extension;
90 if (unload_info->reason == extension_misc::UNLOAD_REASON_UNINSTALL) { 90 if (unload_info->reason == extension_misc::UNLOAD_REASON_UNINSTALL) {
91 FOR_EACH_OBSERVER(InstallObserver, observers_, 91 FOR_EACH_OBSERVER(InstallObserver, observers_,
92 OnExtensionUninstalled(extension)); 92 OnExtensionUninstalled(extension));
93 } else { 93 } else {
94 FOR_EACH_OBSERVER(InstallObserver, observers_, 94 FOR_EACH_OBSERVER(InstallObserver, observers_,
95 OnExtensionDisabled(extension)); 95 OnExtensionDisabled(extension));
96 } 96 }
97 break; 97 break;
98 } 98 }
99 case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED: { 99 case chrome::NOTIFICATION_APP_LIST_REORDERED: {
100 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); 100 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppListReordered());
101 break; 101 break;
102 } 102 }
103 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: { 103 case chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST: {
104 const std::string& extension_id( 104 const std::string& extension_id(
105 *content::Details<const std::string>(details).ptr()); 105 *content::Details<const std::string>(details).ptr());
106 FOR_EACH_OBSERVER(InstallObserver, observers_, 106 FOR_EACH_OBSERVER(InstallObserver, observers_,
107 OnAppInstalledToAppList(extension_id)); 107 OnAppInstalledToAppList(extension_id));
108 break; 108 break;
109 } 109 }
110 default: 110 default:
111 NOTREACHED(); 111 NOTREACHED();
112 } 112 }
113 } 113 }
114 114
115 void InstallTracker::OnAppsReordered() { 115 void InstallTracker::OnAppListReordered() {
116 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); 116 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppListReordered());
117 } 117 }
118 118
119 } // namespace extensions 119 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698