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 |
59 pref_change_registrar_.Init(extension_prefs->pref_service()); | 61 pref_change_registrar_.Init(extension_prefs->pref_service()); |
60 pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, this); | 62 pref_change_registrar_.Add(extensions::ExtensionPrefs::kExtensionsPref, this); |
61 | 63 |
62 model_->AddObserver(this); | 64 model_->AddObserver(this); |
63 } | 65 } |
64 | 66 |
65 AppsModelBuilder::~AppsModelBuilder() { | 67 AppsModelBuilder::~AppsModelBuilder() { |
66 model_->RemoveObserver(this); | 68 model_->RemoveObserver(this); |
67 } | 69 } |
68 | 70 |
69 void AppsModelBuilder::Build() { | 71 void AppsModelBuilder::Build() { |
70 DCHECK(model_ && model_->item_count() == 0); | 72 DCHECK(model_ && model_->item_count() == 0); |
71 | 73 |
72 PopulateApps(); | 74 PopulateApps(); |
73 HighlightApp(); | 75 HighlightApp(); |
74 } | 76 } |
75 | 77 |
76 void AppsModelBuilder::PopulateApps() { | 78 void AppsModelBuilder::PopulateApps() { |
77 ExtensionService* service = profile_->GetExtensionService(); | 79 ExtensionService* service = |
| 80 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
78 if (!service) | 81 if (!service) |
79 return; | 82 return; |
80 | 83 |
81 Apps apps; | 84 Apps apps; |
82 const ExtensionSet* extensions = service->extensions(); | 85 const ExtensionSet* extensions = service->extensions(); |
83 for (ExtensionSet::const_iterator app = extensions->begin(); | 86 for (ExtensionSet::const_iterator app = extensions->begin(); |
84 app != extensions->end(); ++app) { | 87 app != extensions->end(); ++app) { |
85 if ((*app)->ShouldDisplayInAppLauncher()) | 88 if ((*app)->ShouldDisplayInAppLauncher()) |
86 apps.push_back(new ExtensionAppItem(profile_, *app, controller_)); | 89 apps.push_back(new ExtensionAppItem(profile_, *app, controller_)); |
87 } | 90 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 233 |
231 ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; | 234 ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; |
232 ExtensionAppItem* next = target_index + 1 < model_->item_count() ? | 235 ExtensionAppItem* next = target_index + 1 < model_->item_count() ? |
233 GetAppAt(target_index + 1) : NULL; | 236 GetAppAt(target_index + 1) : NULL; |
234 GetAppAt(target_index)->Move(prev, next); | 237 GetAppAt(target_index)->Move(prev, next); |
235 } | 238 } |
236 | 239 |
237 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { | 240 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { |
238 NOTREACHED(); | 241 NOTREACHED(); |
239 } | 242 } |
OLD | NEW |