OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/app_list/apps_model_builder.h" | 5 #include "chrome/browser/ui/app_list/apps_model_builder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "chrome/browser/extensions/extension_prefs.h" | 11 #include "chrome/browser/extensions/extension_prefs.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_system.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/app_list/extension_app_item.h" | 16 #include "chrome/browser/ui/app_list/extension_app_item.h" |
16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 | 20 |
20 using extensions::Extension; | 21 using extensions::Extension; |
21 | 22 |
22 namespace { | 23 namespace { |
(...skipping 15 matching lines...) Expand all Loading... |
38 } // namespace | 39 } // namespace |
39 | 40 |
40 AppsModelBuilder::AppsModelBuilder(Profile* profile, | 41 AppsModelBuilder::AppsModelBuilder(Profile* profile, |
41 app_list::AppListModel::Apps* model, | 42 app_list::AppListModel::Apps* model, |
42 AppListControllerDelegate* controller) | 43 AppListControllerDelegate* controller) |
43 : profile_(profile), | 44 : profile_(profile), |
44 controller_(controller), | 45 controller_(controller), |
45 model_(model), | 46 model_(model), |
46 ignore_changes_(false) { | 47 ignore_changes_(false) { |
47 extensions::ExtensionPrefs* extension_prefs = | 48 extensions::ExtensionPrefs* extension_prefs = |
48 profile_->GetExtensionService()->extension_prefs(); | 49 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 50 extension_prefs(); |
49 | 51 |
50 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 52 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
51 content::Source<Profile>(profile_)); | 53 content::Source<Profile>(profile_)); |
52 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
53 content::Source<Profile>(profile_)); | 55 content::Source<Profile>(profile_)); |
54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 56 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |
55 content::Source<ExtensionSorting>(extension_prefs->extension_sorting())); | 57 content::Source<ExtensionSorting>(extension_prefs->extension_sorting())); |
56 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, | 58 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, |
57 content::Source<Profile>(profile_)); | 59 content::Source<Profile>(profile_)); |
58 | 60 |
(...skipping 10 matching lines...) Expand all Loading... |
69 } | 71 } |
70 | 72 |
71 void AppsModelBuilder::Build() { | 73 void AppsModelBuilder::Build() { |
72 DCHECK(model_ && model_->item_count() == 0); | 74 DCHECK(model_ && model_->item_count() == 0); |
73 | 75 |
74 PopulateApps(); | 76 PopulateApps(); |
75 HighlightApp(); | 77 HighlightApp(); |
76 } | 78 } |
77 | 79 |
78 void AppsModelBuilder::PopulateApps() { | 80 void AppsModelBuilder::PopulateApps() { |
79 ExtensionService* service = profile_->GetExtensionService(); | 81 ExtensionService* service = |
| 82 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
80 if (!service) | 83 if (!service) |
81 return; | 84 return; |
82 | 85 |
83 Apps apps; | 86 Apps apps; |
84 const ExtensionSet* extensions = service->extensions(); | 87 const ExtensionSet* extensions = service->extensions(); |
85 for (ExtensionSet::const_iterator app = extensions->begin(); | 88 for (ExtensionSet::const_iterator app = extensions->begin(); |
86 app != extensions->end(); ++app) { | 89 app != extensions->end(); ++app) { |
87 if ((*app)->ShouldDisplayInAppLauncher()) | 90 if ((*app)->ShouldDisplayInAppLauncher()) |
88 apps.push_back(new ExtensionAppItem(profile_, *app, controller_)); | 91 apps.push_back(new ExtensionAppItem(profile_, *app, controller_)); |
89 } | 92 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 230 |
228 ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; | 231 ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; |
229 ExtensionAppItem* next = target_index + 1 < model_->item_count() ? | 232 ExtensionAppItem* next = target_index + 1 < model_->item_count() ? |
230 GetAppAt(target_index + 1) : NULL; | 233 GetAppAt(target_index + 1) : NULL; |
231 GetAppAt(target_index)->Move(prev, next); | 234 GetAppAt(target_index)->Move(prev, next); |
232 } | 235 } |
233 | 236 |
234 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { | 237 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { |
235 NOTREACHED(); | 238 NOTREACHED(); |
236 } | 239 } |
OLD | NEW |