Chromium Code Reviews| Index: chrome/browser/ui/app_list/app_list_syncable_service.cc |
| diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.cc b/chrome/browser/ui/app_list/app_list_syncable_service.cc |
| index b62e7b223010496ad3bc7d02d747185d3dfe6f1d..caa2882a1c701acb339ad8d58792e15fdf52a1c4 100644 |
| --- a/chrome/browser/ui/app_list/app_list_syncable_service.cc |
| +++ b/chrome/browser/ui/app_list/app_list_syncable_service.cc |
| @@ -4,17 +4,38 @@ |
| #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/extensions/extension_system.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/app_list/app_list_service.h" |
| #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
| #include "chrome/browser/ui/host_desktop.h" |
| +#include "content/public/browser/notification_source.h" |
| #include "ui/app_list/app_list_model.h" |
| namespace app_list { |
| -AppListSyncableService::AppListSyncableService(Profile* profile) |
| +AppListSyncableService::AppListSyncableService( |
| + Profile* profile, |
| + extensions::ExtensionSystem* extension_system) |
|
benwells
2013/11/21 09:48:11
nit: can you make this an ExtensionService? Extens
tapted
2013/11/21 10:39:03
Done. (I felt too evil passing in something that c
|
| : profile_(profile), |
| model_(new AppListModel) { |
| + ExtensionService* extension_service = extension_system->extension_service(); |
| + if (extension_service && extension_service->is_ready()) { |
| + BuildModel(); |
| + return; |
| + } |
| + |
| + // The extensions for this profile have not yet all been loaded. |
| + registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
| + content::Source<Profile>(profile)); |
| +} |
| + |
| +AppListSyncableService::~AppListSyncableService() { |
| +} |
| + |
| +void AppListSyncableService::BuildModel() { |
| // For now, use the AppListControllerDelegate associated with the native |
| // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller |
| // dependency and move the dependent methods from AppListControllerDelegate |
| @@ -30,7 +51,14 @@ AppListSyncableService::AppListSyncableService(Profile* profile) |
| VLOG(1) << "AppListSyncableService Created."; |
| } |
| -AppListSyncableService::~AppListSyncableService() { |
| +void AppListSyncableService::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); |
| + DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| + registrar_.RemoveAll(); |
| + BuildModel(); |
| } |
| } // namespace app_list |